Skip to content

Commit 535b5a9

Browse files
authored
feat(java): add dependency location support for gradle files (aquasecurity#6083)
1 parent 428420e commit 535b5a9

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

docs/docs/coverage/language/java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The following table provides an outline of the features Trivy offers.
1515
|------------------|:---------------------:|:----------------:|:------------------------------------:|:--------:|
1616
| JAR/WAR/PAR/EAR | Trivy Java DB | Include | - | - |
1717
| pom.xml | Maven repository [^1] | Exclude ||[^7] |
18-
| *gradle.lockfile | - | Exclude | - | - |
18+
| *gradle.lockfile | - | Exclude | - | |
1919

2020
These may be enabled or disabled depending on the target.
2121
See [here](./index.md) for the detail.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/alicebob/miniredis/v2 v2.31.1
1515
github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986
1616
github.com/aquasecurity/defsec v0.94.1
17-
github.com/aquasecurity/go-dep-parser v0.0.0-20240202105001-4f19ab402b0b
17+
github.com/aquasecurity/go-dep-parser v0.0.0-20240208080026-8cc7d408bce4
1818
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce
1919
github.com/aquasecurity/go-npm-version v0.0.0-20201110091526-0b796d180798
2020
github.com/aquasecurity/go-pep440-version v0.0.0-20210121094942-22b2f8951d46

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986 h1:2a30
325325
github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986/go.mod h1:NT+jyeCzXk6vXR5MTkdn4z64TgGfE5HMLC8qfj5unl8=
326326
github.com/aquasecurity/defsec v0.94.1 h1:lk44bfUltm0f0Dw4DbO3Ka9d/bf3N8cWclSdHXMyKF4=
327327
github.com/aquasecurity/defsec v0.94.1/go.mod h1:wiX9BX0SOG0ZWjVIPYGPl46fyO3Gu8lJnk4rmhFR7IA=
328-
github.com/aquasecurity/go-dep-parser v0.0.0-20240202105001-4f19ab402b0b h1:GEwxQO0+OcZ4wgmtqU+8qBK179BXhz+WHTWahZA5dfM=
329-
github.com/aquasecurity/go-dep-parser v0.0.0-20240202105001-4f19ab402b0b/go.mod h1:P0PmelcN1ABKJrDzRbPnn6hK7RvgI+xmjiV/9uPaNnY=
328+
github.com/aquasecurity/go-dep-parser v0.0.0-20240208080026-8cc7d408bce4 h1:6qs80w4qPbPnF6GhbIifSANqfCrq90CKtSUBaw6p0z0=
329+
github.com/aquasecurity/go-dep-parser v0.0.0-20240208080026-8cc7d408bce4/go.mod h1:P0PmelcN1ABKJrDzRbPnn6hK7RvgI+xmjiV/9uPaNnY=
330330
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce h1:QgBRgJvtEOBtUXilDb1MLi1p1MWoyFDXAu5DEUl5nwM=
331331
github.com/aquasecurity/go-gem-version v0.0.0-20201115065557-8eed6fe000ce/go.mod h1:HXgVzOPvXhVGLJs4ZKO817idqr/xhwsTcj17CLYY74s=
332332
github.com/aquasecurity/go-mock-aws v0.0.0-20240109054747-49e4b5da33cb h1:dNxUB2bSbiLGNYcXkbBKrrfuY96+dXhA9FahEFZ4THQ=

integration/testdata/gradle.json.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"Vulnerabilities": [
2424
{
2525
"VulnerabilityID": "CVE-2020-9548",
26+
"PkgID": "com.fasterxml.jackson.core:jackson-databind:2.9.1",
2627
"PkgName": "com.fasterxml.jackson.core:jackson-databind",
2728
"PkgIdentifier": {
2829
"PURL": "pkg:maven/com.fasterxml.jackson.core/[email protected]"
@@ -87,6 +88,7 @@
8788
},
8889
{
8990
"VulnerabilityID": "CVE-2021-20190",
91+
"PkgID": "com.fasterxml.jackson.core:jackson-databind:2.9.1",
9092
"PkgName": "com.fasterxml.jackson.core:jackson-databind",
9193
"PkgIdentifier": {
9294
"PURL": "pkg:maven/com.fasterxml.jackson.core/[email protected]"

pkg/fanal/analyzer/language/java/gradle/lockfile_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ func Test_gradleLockAnalyzer_Analyze(t *testing.T) {
2727
FilePath: "testdata/happy.lockfile",
2828
Libraries: types.Packages{
2929
{
30+
ID: "com.example:example:0.0.1",
3031
Name: "com.example:example",
3132
Version: "0.0.1",
33+
Locations: []types.Location{
34+
{
35+
StartLine: 4,
36+
EndLine: 4,
37+
},
38+
},
3239
},
3340
},
3441
},

0 commit comments

Comments
 (0)