forked from aquasecurity/trivy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nodejs): find licenses for packages with slash (aquasecurity#5836)
- Loading branch information
1 parent
c75143f
commit f90d4ee
Showing
4 changed files
with
93 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -34,6 +34,19 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Type: types.Npm, | ||
FilePath: "package-lock.json", | ||
Libraries: types.Packages{ | ||
{ | ||
ID: "@babel/[email protected]", | ||
Name: "@babel/parser", | ||
Version: "7.23.6", | ||
Indirect: true, | ||
Licenses: []string{"MIT"}, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 6, | ||
EndLine: 10, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "ansi-colors", | ||
|
@@ -42,8 +55,8 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 6, | ||
EndLine: 11, | ||
StartLine: 11, | ||
EndLine: 16, | ||
}, | ||
}, | ||
}, | ||
|
@@ -54,8 +67,8 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 12, | ||
EndLine: 16, | ||
StartLine: 17, | ||
EndLine: 21, | ||
}, | ||
}, | ||
}, | ||
|
@@ -68,8 +81,8 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Licenses: []string{"MIT"}, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 17, | ||
EndLine: 39, | ||
StartLine: 22, | ||
EndLine: 44, | ||
}, | ||
}, | ||
}, | ||
|
@@ -82,12 +95,12 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Licenses: []string{"MIT"}, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 25, | ||
EndLine: 32, | ||
StartLine: 30, | ||
EndLine: 37, | ||
}, | ||
{ | ||
StartLine: 48, | ||
EndLine: 55, | ||
StartLine: 53, | ||
EndLine: 60, | ||
}, | ||
}, | ||
}, | ||
|
@@ -100,8 +113,8 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Licenses: []string{"MIT"}, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 40, | ||
EndLine: 62, | ||
StartLine: 45, | ||
EndLine: 67, | ||
}, | ||
}, | ||
}, | ||
|
@@ -113,12 +126,12 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Licenses: []string{"MIT"}, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 33, | ||
EndLine: 37, | ||
StartLine: 38, | ||
EndLine: 42, | ||
}, | ||
{ | ||
StartLine: 56, | ||
EndLine: 60, | ||
StartLine: 61, | ||
EndLine: 65, | ||
}, | ||
}, | ||
}, | ||
|
@@ -130,8 +143,8 @@ func Test_npmLibraryAnalyzer_Analyze(t *testing.T) { | |
Licenses: []string{"MIT"}, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 63, | ||
EndLine: 67, | ||
StartLine: 68, | ||
EndLine: 72, | ||
}, | ||
}, | ||
}, | ||
|
@@ -206,9 +219,14 @@ func Test_nodePkgLibraryAnalyzer_Required(t *testing.T) { | |
filePath: "npm/node_modules/ms/package.json", | ||
want: true, | ||
}, | ||
{ | ||
name: "package.json with `/` in name", | ||
filePath: "npm/node_modules/@babel/parser/package.json", | ||
want: true, | ||
}, | ||
{ | ||
name: "sad path", | ||
filePath: "npm/node_modules/package.json", | ||
filePath: "npm/package.json", | ||
want: false, | ||
}, | ||
{ | ||
|
46 changes: 46 additions & 0 deletions
46
...fanal/analyzer/language/nodejs/npm/testdata/happy/node_modules/@babel/parser/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
pkg/fanal/analyzer/language/nodejs/npm/testdata/happy/package-lock.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.