Skip to content

Commit 4401998

Browse files
authored
feat(java): add graph support for pom.xml (#4902)
* add graph support * update docs * bump go-dep-parser * remove replace for go-dep-parser * update docs
1 parent 9c211d0 commit 4401998

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

docs/docs/configuration/reporting.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ The following packages/languages are currently supported:
6262
- Modules: go.mod
6363
- PHP
6464
- Composer
65+
- Java
66+
- Maven: pom.xml
6567

6668
This tree is the reverse of the npm list command.
6769
However, if you want to resolve a vulnerability in a particular indirect dependency, the reversed tree is useful to know where that dependency comes from and identify which package you actually need to update.

docs/docs/coverage/language/java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The following table provides an outline of the features Trivy offers.
1414
| Artifact | Internet access | Dev dependencies | [Dependency graph][dependency-graph] |
1515
|------------------|:---------------------:|:----------------:|:------------------------------------:|
1616
| JAR/WAR/PAR/EAR | Trivy Java DB | Include | - |
17-
| pom.xml | Maven repository [^1] | Exclude | - |
17+
| pom.xml | Maven repository [^1] | Exclude | |
1818
| *gradle.lockfile | - | Exclude | - |
1919

2020
These may be enabled or disabled depending on the target.

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.30.4
1515
github.com/aquasecurity/bolt-fixtures v0.0.0-20200903104109-d34e7f983986
1616
github.com/aquasecurity/defsec v0.91.1
17-
github.com/aquasecurity/go-dep-parser v0.0.0-20230825043456-df72a286b673
17+
github.com/aquasecurity/go-dep-parser v0.0.0-20230828120518-ef5e9409fc43
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.91.1 h1:dBIPm6Tva9I+ZTQv+6t9wob3ZlMSu8NFqMJr4mgJC5A=
327327
github.com/aquasecurity/defsec v0.91.1/go.mod h1:l/srzxtuuyb6c6FlqUvMp3xw2ZbvuZ0l9972MNJM7V8=
328-
github.com/aquasecurity/go-dep-parser v0.0.0-20230825043456-df72a286b673 h1:RMhUzr2ZfQ8OAO26aUkqbwfxK7d3ieFtPqUhiwTxOe0=
329-
github.com/aquasecurity/go-dep-parser v0.0.0-20230825043456-df72a286b673/go.mod h1:0+GvQF0gL4YEAAUPpNeLeGpFDxMvvIHLMd7vk9bpwko=
328+
github.com/aquasecurity/go-dep-parser v0.0.0-20230828120518-ef5e9409fc43 h1:/F4aNnwyFNyAemjKtHznfRdeWUEENOZYOnx+smPPpAE=
329+
github.com/aquasecurity/go-dep-parser v0.0.0-20230828120518-ef5e9409fc43/go.mod h1:0+GvQF0gL4YEAAUPpNeLeGpFDxMvvIHLMd7vk9bpwko=
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-20230328195059-5bf52338aec3 h1:Vt9y1gZS5JGY3tsL9zc++Cg4ofX51CG7PaMyC5SXWPg=

integration/testdata/pom.json.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"Vulnerabilities": [
2323
{
2424
"VulnerabilityID": "CVE-2020-9548",
25+
"PkgID": "com.fasterxml.jackson.core:jackson-databind:2.9.1",
2526
"PkgName": "com.fasterxml.jackson.core:jackson-databind",
2627
"InstalledVersion": "2.9.1",
2728
"FixedVersion": "2.9.10.4",
@@ -78,6 +79,7 @@
7879
},
7980
{
8081
"VulnerabilityID": "CVE-2021-20190",
82+
"PkgID": "com.fasterxml.jackson.core:jackson-databind:2.9.1",
8183
"PkgName": "com.fasterxml.jackson.core:jackson-databind",
8284
"InstalledVersion": "2.9.1",
8385
"FixedVersion": "2.9.10.7",

pkg/fanal/analyzer/language/java/pom/pom_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func Test_pomAnalyzer_Analyze(t *testing.T) {
3131
FilePath: "testdata/happy/pom.xml",
3232
Libraries: types.Packages{
3333
{
34+
ID: "com.example:example:1.0.0",
3435
Name: "com.example:example",
3536
Version: "1.0.0",
3637
Licenses: []string{"Apache-2.0"},
@@ -51,6 +52,7 @@ func Test_pomAnalyzer_Analyze(t *testing.T) {
5152
FilePath: "pom.xml",
5253
Libraries: types.Packages{
5354
{
55+
ID: "com.example:example:1.0.0",
5456
Name: "com.example:example",
5557
Version: "1.0.0",
5658
Licenses: []string{"Apache-2.0"},
@@ -70,6 +72,7 @@ func Test_pomAnalyzer_Analyze(t *testing.T) {
7072
FilePath: "testdata/requirements/pom.xml",
7173
Libraries: types.Packages{
7274
{
75+
ID: "com.example:example:2.0.0",
7376
Name: "com.example:example",
7477
Version: "2.0.0",
7578
Licenses: []string{"Apache-2.0"},

0 commit comments

Comments
 (0)