-
-
Couldn't load subscription status.
- Fork 217
feat: Dependency track tags reporting #2473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gschafra
wants to merge
16
commits into
CycloneDX:master
Choose a base branch
from
gschafra:dependency-track-tags-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d3afc75
feat: Dependency track tags reporting
89c2627
test(cli): Started implementing unit test for SBOM reporting params
gschafra ee85a6f
Merge branch 'master' into dependency-track-tags-support
gschafra 068be9a
docs(cli): Docs concerning tag feature on SBOM reporting
gschafra c3fc454
test(cli): First SBOM reporting test
gschafra 10c6f7c
build(deps): Package fixed versions and overrides
gschafra 9777208
build(deps): Package overrides
gschafra ef52e56
test(cli): Added another test case
gschafra a99782e
Merge branch 'master' into dependency-track-tags-support
gschafra d6e797e
style(cli): Biome fix/format
df3d26b
build(deps): Reverted overrides, only keeping direct packages
09a2613
test(utils): Adapted parsePnpmLock test
24b69ca
style: Biome fix/format
e58f46d
Merge branch 'master' into dependency-track-tags-support
gschafra a4efbe0
Merge remote-tracking branch 'origin/dependency-track-tags-support' i…
gschafra a0661b6
test(cli): Code style
gschafra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import quibble from "quibble"; | ||
| import sinon from "sinon"; | ||
| import { assert, beforeEach, afterEach, describe, it } from "poku"; | ||
|
|
||
| describe("CLI tests", () => { | ||
| let gotStub; | ||
| let submitBom; | ||
|
|
||
| beforeEach(async () => { | ||
| // Create a sinon stub that mimics got() | ||
| const fakeGotResponse = { | ||
| json: sinon.stub().resolves({ success: true }), | ||
| }; | ||
|
|
||
| gotStub = sinon.stub().returns(fakeGotResponse); | ||
|
|
||
| // Attach extend to the function itself | ||
| gotStub.extend = sinon.stub().returns(gotStub); | ||
|
|
||
| // Replace the real 'got' module with our stub | ||
| await quibble.esm("got", { | ||
| default: gotStub, | ||
| }); | ||
|
|
||
| // Import the module under test AFTER quibble | ||
| ({ submitBom } = await import("./index.js")); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| quibble.reset(); // Restore real modules | ||
| }); | ||
|
|
||
| it("should successfully report the SBOM with given project id, name, version and a single tag", async () => { | ||
| const serverUrl = "https://dtrack.example.com"; | ||
| const projectId = "f7cb9f02-8041-4991-9101-b01fa07a6522"; | ||
| const projectName = "cdxgen-test-project"; | ||
| const projectVersion = "1.0.0"; | ||
| const projectTag = "tag1"; | ||
| const bomContent = { | ||
| bom: "test" | ||
| }; | ||
| const apiKey = "TEST_API_KEY"; | ||
| const skipDtTlsCheck = false; | ||
|
|
||
| const expectedRequestPayload = { | ||
| autoCreate: "true", | ||
| bom: "eyJib20iOiJ0ZXN0In0=", // stringified and base64 encoded bomContent | ||
| project: projectId, | ||
| projectName, | ||
| projectVersion, | ||
| projectTags: [{ name: projectTag }], | ||
| }; | ||
|
|
||
| await submitBom( | ||
| { serverUrl, projectId, projectName, projectVersion, apiKey, skipDtTlsCheck, projectTag }, | ||
| bomContent, | ||
| ); | ||
|
|
||
| // Verify got was called exactly once | ||
| sinon.assert.calledOnce(gotStub); | ||
|
|
||
| // Grab call arguments | ||
| const [calledUrl, options] = gotStub.firstCall.args; | ||
|
|
||
| // Assert call arguments against expectations | ||
| assert.equal(calledUrl, serverUrl + "/api/v1/bom"); | ||
| assert.equal(options.method, "PUT"); | ||
| assert.equal(options.https.rejectUnauthorized, !skipDtTlsCheck); | ||
| assert.equal(options.headers["X-Api-Key"], apiKey); | ||
| assert.match(options.headers["user-agent"], /@CycloneDX\/cdxgen/); | ||
| assert.deepEqual(options.json, expectedRequestPayload); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,6 +139,17 @@ | |
| "@npmcli/package-json": "7.0.1", | ||
| "@npmcli/query": "4.0.1", | ||
| "@npmcli/redact": "3.2.2", | ||
| "@sec-ant/readable-stream": "0.4.1", | ||
| "@sindresorhus/is": "7.1.0", | ||
| "@sinonjs/commons": "3.0.1", | ||
| "@sinonjs/fake-timers": "13.0.5", | ||
| "@sinonjs/samsam": "8.0.3", | ||
| "@szmarczak/http-timer": "5.0.1", | ||
| "@types/debug": "4.1.12", | ||
| "@types/http-cache-semantics": "4.0.4", | ||
| "@types/ms": "2.1.0", | ||
| "@types/node": "24.5.1", | ||
| "@types/validator": "13.15.3", | ||
| "abbrev": "3.0.1", | ||
| "ajv": "8.17.1", | ||
| "ajv-formats": "3.0.1", | ||
|
|
@@ -151,7 +162,22 @@ | |
| "compression": "1.8.1", | ||
| "connect": "3.7.0", | ||
| "debug": "4.4.1", | ||
| "decompress-response": "7.0.0", | ||
| "decompress-response": "6.0.0", | ||
| "deep-extend": "0.6.0", | ||
| "defer-to-connect": "2.0.1", | ||
| "define-data-property": "1.1.4", | ||
| "define-properties": "1.2.1", | ||
| "depd": "2.0.0", | ||
| "detect-libc": "2.1.0", | ||
| "detect-node": "2.1.0", | ||
| "diff": "7.0.0", | ||
| "dom-serializer": "2.0.0", | ||
| "domelementtype": "2.3.0", | ||
| "domhandler": "5.0.3", | ||
| "domutils": "3.2.2", | ||
| "dottie": "2.0.6", | ||
| "dunder-proto": "1.0.1", | ||
| "ecdsa-sig-formatter": "1.0.11", | ||
| "edn-data": "1.1.2", | ||
| "encoding": "0.1.13", | ||
| "escape-string-regexp": "4.0.0", | ||
|
|
@@ -161,6 +187,9 @@ | |
| "hosted-git-info": "9.0.2", | ||
| "iconv-lite": "0.7.0", | ||
| "ini": "5.0.0", | ||
| "ip-address": "10.0.1", | ||
| "is-core-module": "2.16.1", | ||
| "is-fullwidth-code-point": "3.0.0", | ||
| "is-stream": "4.0.1", | ||
| "isexe": "3.1.1", | ||
| "json-parse-even-better-errors": "4.0.0", | ||
|
|
@@ -184,26 +213,61 @@ | |
| "on-finished": "2.4.1", | ||
| "packageurl-js": "1.0.2", | ||
| "parse-conflict-json": "4.0.0", | ||
| "parse5": "7.3.0", | ||
| "parse5-htmlparser2-tree-adapter": "7.1.0", | ||
| "parse5-parser-stream": "7.1.2", | ||
| "parseurl": "1.3.3", | ||
| "path-key": "3.1.1", | ||
| "path-parse": "1.0.7", | ||
| "path-scurry": "2.0.0", | ||
| "pg-connection-string": "2.9.1", | ||
| "picocolors": "1.1.1", | ||
| "picomatch": "4.0.3", | ||
| "poku": "3.0.2", | ||
| "prettify-xml": "1.2.0", | ||
| "proc-log": "5.0.0", | ||
| "proggy": "3.0.0", | ||
| "promise-all-reject-late": "1.0.1", | ||
| "promise-call-limit": "3.0.2", | ||
| "properties-reader": "2.3.0", | ||
| "pump": "3.0.3", | ||
| "qs": "6.14.0", | ||
| "quibble": "0.9.2", | ||
| "quick-lru": "5.1.1", | ||
| "raw-body": "3.0.1", | ||
| "rc": "1.2.8", | ||
| "read-cmd-shim": "5.0.0", | ||
| "read-package-json-fast": "4.0.0", | ||
| "require-directory": "2.1.1", | ||
| "require-from-string": "2.0.2", | ||
| "resolve-alpn": "1.2.1", | ||
| "resolve": "1.22.10", | ||
| "responselike": "4.0.2", | ||
| "semver": "7.7.3", | ||
| "sequelize": "6.37.7", | ||
| "signal-exit": "4.1.0", | ||
| "simple-concat": "1.0.1", | ||
| "simple-get": "4.0.1", | ||
| "sinon": "21.0.0", | ||
| "slice-ansi": "4.0.0", | ||
| "smart-buffer": "4.2.0", | ||
| "socks": "2.8.7", | ||
| "socks-proxy-agent": "8.0.5", | ||
| "spdx-correct": "3.2.0", | ||
| "spdx-exceptions": "2.5.0", | ||
| "spdx-expression-parse": "3.0.1", | ||
| "spdx-license-ids": "3.0.22", | ||
| "sprintf-js": "1.1.3", | ||
| "sqlite3": "npm:@appthreat/[email protected]", | ||
| "ssri": "12.0.0", | ||
| "statuses": "2.0.2", | ||
| "strip-json-comments": "3.1.1", | ||
| "supports-preserve-symlinks-flag": "1.0.0", | ||
| "table": "6.9.0", | ||
| "tar": "7.5.1", | ||
| "treeverse": "3.0.0", | ||
| "tunnel-agent": "0.6.0", | ||
| "type-detect": "4.1.0", | ||
| "type-fest": "4.41.0", | ||
| "typescript": "5.9.3", | ||
| "unique-filename": "4.0.0", | ||
|
|
@@ -273,6 +337,8 @@ | |
| "devDependencies": { | ||
| "@biomejs/biome": "2.2.6", | ||
| "poku": "3.0.2", | ||
| "quibble": "0.9.2", | ||
| "sinon": "21.0.0", | ||
| "typescript": "5.9.3" | ||
| }, | ||
| "optionalDependencies": { | ||
|
|
@@ -335,6 +401,17 @@ | |
| "@npmcli/package-json": "7.0.1", | ||
| "@npmcli/query": "4.0.1", | ||
| "@npmcli/redact": "3.2.2", | ||
| "@sec-ant/readable-stream": "0.4.1", | ||
| "@sindresorhus/is": "7.1.0", | ||
| "@sinonjs/commons": "3.0.1", | ||
| "@sinonjs/fake-timers": "13.0.5", | ||
| "@sinonjs/samsam": "8.0.3", | ||
| "@szmarczak/http-timer": "5.0.1", | ||
| "@types/debug": "4.1.12", | ||
| "@types/http-cache-semantics": "4.0.4", | ||
| "@types/ms": "2.1.0", | ||
| "@types/node": "24.5.1", | ||
| "@types/validator": "13.15.3", | ||
| "abbrev": "3.0.1", | ||
| "ajv": "8.17.1", | ||
| "ajv-formats": "3.0.1", | ||
|
|
@@ -347,7 +424,22 @@ | |
| "compression": "1.8.1", | ||
| "connect": "3.7.0", | ||
| "debug": "4.4.1", | ||
| "decompress-response": "7.0.0", | ||
| "decompress-response": "6.0.0", | ||
| "deep-extend": "0.6.0", | ||
| "defer-to-connect": "2.0.1", | ||
| "define-data-property": "1.1.4", | ||
| "define-properties": "1.2.1", | ||
| "depd": "2.0.0", | ||
| "detect-libc": "2.1.0", | ||
| "detect-node": "2.1.0", | ||
| "diff": "7.0.0", | ||
| "dom-serializer": "2.0.0", | ||
| "domelementtype": "2.3.0", | ||
| "domhandler": "5.0.3", | ||
| "domutils": "3.2.2", | ||
| "dottie": "2.0.6", | ||
| "dunder-proto": "1.0.1", | ||
| "ecdsa-sig-formatter": "1.0.11", | ||
| "edn-data": "1.1.2", | ||
| "encoding": "0.1.13", | ||
| "escape-string-regexp": "4.0.0", | ||
|
|
@@ -357,6 +449,9 @@ | |
| "hosted-git-info": "9.0.2", | ||
| "iconv-lite": "0.7.0", | ||
| "ini": "5.0.0", | ||
| "ip-address": "10.0.1", | ||
| "is-core-module": "2.16.1", | ||
| "is-fullwidth-code-point": "3.0.0", | ||
| "is-stream": "4.0.1", | ||
| "isexe": "3.1.1", | ||
| "json-parse-even-better-errors": "4.0.0", | ||
|
|
@@ -380,27 +475,62 @@ | |
| "on-finished": "2.4.1", | ||
| "packageurl-js": "1.0.2", | ||
| "parse-conflict-json": "4.0.0", | ||
| "parse5": "7.3.0", | ||
| "parse5-htmlparser2-tree-adapter": "7.1.0", | ||
| "parse5-parser-stream": "7.1.2", | ||
| "parseurl": "1.3.3", | ||
| "path-key": "3.1.1", | ||
| "path-parse": "1.0.7", | ||
| "path-scurry": "2.0.0", | ||
| "pg-connection-string": "2.9.1", | ||
| "picocolors": "1.1.1", | ||
| "picomatch": "4.0.3", | ||
| "poku": "3.0.2", | ||
| "prettify-xml": "1.2.0", | ||
| "proc-log": "5.0.0", | ||
| "proggy": "3.0.0", | ||
| "promise-all-reject-late": "1.0.1", | ||
| "promise-call-limit": "3.0.2", | ||
| "properties-reader": "2.3.0", | ||
| "pump": "3.0.3", | ||
| "qs": "6.14.0", | ||
| "quibble": "0.9.2", | ||
| "quick-lru": "5.1.1", | ||
| "raw-body": "3.0.1", | ||
| "rc": "1.2.8", | ||
| "read-cmd-shim": "5.0.0", | ||
| "read-package-json-fast": "4.0.0", | ||
| "require-directory": "2.1.1", | ||
| "require-from-string": "2.0.2", | ||
| "resolve-alpn": "1.2.1", | ||
| "resolve": "1.22.10", | ||
| "responselike": "4.0.2", | ||
| "semver": "7.7.3", | ||
| "sequelize": "6.37.7", | ||
| "signal-exit": "4.1.0", | ||
| "simple-concat": "1.0.1", | ||
| "simple-get": "4.0.1", | ||
| "sinon": "21.0.0", | ||
| "slice-ansi": "4.0.0", | ||
| "smart-buffer": "4.2.0", | ||
| "socks": "2.8.7", | ||
| "socks-proxy-agent": "8.0.5", | ||
| "spdx-correct": "3.2.0", | ||
| "spdx-exceptions": "2.5.0", | ||
| "spdx-expression-parse": "3.0.1", | ||
| "spdx-license-ids": "3.0.22", | ||
| "sprintf-js": "1.1.3", | ||
| "sqlite3": "npm:@appthreat/[email protected]", | ||
| "ssri": "12.0.0", | ||
| "statuses": "2.0.2", | ||
| "strip-json-comments": "3.1.1", | ||
| "supports-preserve-symlinks-flag": "1.0.0", | ||
| "table": "6.9.0", | ||
| "tar": "7.5.1", | ||
| "tar-fs": "3.1.1", | ||
| "treeverse": "3.0.0", | ||
| "tunnel-agent": "0.6.0", | ||
| "type-detect": "4.1.0", | ||
| "type-fest": "4.41.0", | ||
| "typescript": "5.9.3", | ||
| "unique-filename": "4.0.0", | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.