-
Notifications
You must be signed in to change notification settings - Fork 2
Add package.json extractor for lockfile-less JS projects #126
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f8349db
Add PackageJSONFilePath constant and extractor types
jbcibois-ddhq 7a5753c
Add VersionRange to PackageDetails and export as SBOM property
jbcibois-ddhq 2a1c6fe
Add package.json extractor
jbcibois-ddhq dfbf795
Add package.json extractor tests and fixtures
jbcibois-ddhq 852fe17
Update README and integration snapshots
jbcibois-ddhq bf89b16
Drop duplicate PURL range entries, first alias key wins
jbcibois-ddhq aeaa065
Fix node_modules path check to use segment boundaries
jbcibois-ddhq 22c6ecf
Handle =1.2.3 exact pin syntax
jbcibois-ddhq c0ceae5
Gate package.json extractor under --manifest-parsers flag
jbcibois-ddhq e63b049
Make resolveNpmAlias private
jbcibois-ddhq 762f1ad
Add comments explaining magic numbers in package.json extractor
jbcibois-ddhq 29bed5c
Set LocationRole to manifest on package.json packages
jbcibois-ddhq 272cc05
Run prettier on README
jbcibois-ddhq 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
5 changes: 5 additions & 0 deletions
5
cmd/datadog-sbom-generator/fixtures/integration-package-json/package.json
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,5 @@ | ||
| { | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } |
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
7 changes: 7 additions & 0 deletions
7
pkg/lockfile/fixtures/package-json-extractor/alias-collision/package.json
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,7 @@ | ||
| { | ||
| "name": "alias-collision", | ||
| "dependencies": { | ||
| "react": "17.0.2", | ||
| "react18": "npm:react@18.3.1" | ||
| } | ||
| } | ||
6 changes: 6 additions & 0 deletions
6
pkg/lockfile/fixtures/package-json-extractor/alias-range-collision/package.json
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,6 @@ | ||
| { | ||
| "dependencies": { | ||
| "react17": "npm:react@^17", | ||
| "react18": "npm:react@^18" | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
pkg/lockfile/fixtures/package-json-extractor/all-dep-types/package.json
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,12 @@ | ||
| { | ||
| "name": "all-dep-types", | ||
| "dependencies": { | ||
| "express": "^4.18.0" | ||
| }, | ||
| "devDependencies": { | ||
| "jest": "~29.7.0" | ||
| }, | ||
| "optionalDependencies": { | ||
| "fsevents": "2.3.3" | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
pkg/lockfile/fixtures/package-json-extractor/basic/package.json
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,6 @@ | ||
| { | ||
| "name": "basic-project", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
pkg/lockfile/fixtures/package-json-extractor/complex-versions/package.json
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,14 @@ | ||
| { | ||
| "name": "complex-versions", | ||
| "dependencies": { | ||
| "pinned": "1.0.0", | ||
| "eq-pinned": "=2.0.0", | ||
| "caret": "^2.3.4", | ||
| "tilde": "~1.5.3", | ||
| "range": ">=1.0.0 <2.0.0", | ||
| "aliased": "npm:real-pkg@3.0.0", | ||
| "local-file": "file:../local", | ||
| "url-dep": "http://example.com/pkg.tgz", | ||
| "tag-dep": "latest" | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
pkg/lockfile/fixtures/package-json-extractor/empty/package.json
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,3 @@ | ||
| { | ||
| "name": "empty-project" | ||
| } |
1 change: 1 addition & 0 deletions
1
pkg/lockfile/fixtures/package-json-extractor/invalid/package.json
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 @@ | ||
| {this is not valid json |
3 changes: 3 additions & 0 deletions
3
pkg/lockfile/fixtures/package-json-extractor/with-npm-lockfile/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
pkg/lockfile/fixtures/package-json-extractor/with-npm-lockfile/package.json
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,6 @@ | ||
| { | ||
| "name": "has-lockfile", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
pkg/lockfile/fixtures/package-json-extractor/with-pnpm-lock/package.json
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,6 @@ | ||
| { | ||
| "name": "has-pnpm-lock", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } |
Empty file.
6 changes: 6 additions & 0 deletions
6
pkg/lockfile/fixtures/package-json-extractor/with-yarn-lock/package.json
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,6 @@ | ||
| { | ||
| "name": "has-yarn-lock", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } |
Empty file.
1 change: 1 addition & 0 deletions
1
pkg/lockfile/fixtures/package-json-extractor/workspace-with-root-lockfile/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...le/fixtures/package-json-extractor/workspace-with-root-lockfile/packages/foo/package.json
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,6 @@ | ||
| { | ||
| "name": "foo", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to complete it at least with the cases included here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit with LocationRole added 29bed5c