-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(java): check if a version exists when determining GAV by file name for jar
files
#5630
Merged
knqyf263
merged 9 commits into
aquasecurity:main
from
DmitriyLewen:fix-jar/check-version-when-search-gav-by-filename
Jan 10, 2024
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e1f0df7
fix(jar): check if a version exists when determining gav by file name
DmitriyLewen 5f790bf
chore(deps): bump go-dep-parser
DmitriyLewen 2f10ed1
Merge branch 'main' into 'fix-jar/check-version-when-search-gav-by-f…
DmitriyLewen 65927d5
Merge branch 'main' of github.com:DmitriyLewen/trivy into fix-jar/che…
DmitriyLewen ee0ac38
refactor: move logic to trivy-java-db
DmitriyLewen e362ed8
refactor: update trivy-java-db
DmitriyLewen 61f0a31
Merge branch 'main' into 'fix-jar/check-version-when-search-gav-by-f…
DmitriyLewen a762dc9
chore(deps): bump trivy-java-db
DmitriyLewen 17babda
Merge branch 'main' of github.com:DmitriyLewen/trivy into fix-jar/che…
DmitriyLewen File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package javadb | ||
|
||
import ( | ||
"github.com/aquasecurity/trivy-java-db/pkg/types" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestFoundGroupID(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
indexes []types.Index | ||
version string | ||
wantGroupID string | ||
}{ | ||
{ | ||
name: "Only one groupID has required version", | ||
indexes: []types.Index{ | ||
{ | ||
GroupID: "com.example1", | ||
Version: "1.0.0", | ||
}, | ||
{ | ||
GroupID: "com.example1", | ||
Version: "1.0.1", | ||
}, | ||
{ | ||
GroupID: "com.example2", | ||
Version: "2.0.0", | ||
}, | ||
}, | ||
version: "2.0.0", | ||
wantGroupID: "com.example2", | ||
}, | ||
{ | ||
name: "Two groupIDs have required version", | ||
indexes: []types.Index{ | ||
{ | ||
GroupID: "com.example1", | ||
Version: "1.0.0", | ||
}, | ||
{ | ||
GroupID: "com.example2", | ||
Version: "1.0.1", | ||
}, | ||
{ | ||
GroupID: "com.example2", | ||
Version: "1.0.0", | ||
}, | ||
}, | ||
version: "1.0.0", | ||
wantGroupID: "com.example2", | ||
}, | ||
{ | ||
name: "There are no groupIDs with required version", | ||
indexes: []types.Index{ | ||
{ | ||
GroupID: "com.example1", | ||
Version: "1.0.0", | ||
}, | ||
{ | ||
GroupID: "com.example1", | ||
Version: "2.0.0", | ||
}, | ||
{ | ||
GroupID: "com.example2", | ||
Version: "2.0.0", | ||
}, | ||
}, | ||
version: "3.0.0", | ||
wantGroupID: "", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotGroupID := foundGroupID(tt.version, tt.indexes) | ||
assert.Equal(t, tt.wantGroupID, gotGroupID) | ||
}) | ||
} | ||
} |
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.
What if changing this method to match the version as well as the artifact ID?
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.
Do you mean just to move the following logic to
trivy-java-db
?trivy/pkg/javadb/client.go
Lines 157 to 188 in 2f10ed1
Or update our sql query in
trivy-java-db
?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.
I meant SQL query. Is it possible?
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.
I need more knowledge on SQL.
I will try to do this and then write to you.
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.
I created aquasecurity/trivy-java-db#23 and updated this PR.
Take a look, when you have time, please.