Skip to content

Commit 751e3f3

Browse files
authored
feat: replace pomxmlenhanceable extractor with transitive enricher (#2466)
~Blocked by #2461~ ~Blocked by google/osv-scalibr#1674 Resolves #2465
1 parent 89cc4b4 commit 751e3f3

File tree

8 files changed

+81
-148
lines changed

8 files changed

+81
-148
lines changed

cmd/osv-scanner/scan/source/__snapshots__/command_test.snap

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ Scanned <rootdir>/testdata/locks-many-with-insecure/alpine.cdx.xml file and foun
430430
Scanned <rootdir>/testdata/locks-many-with-insecure/composer.lock file and found 6 packages
431431
Scanned <rootdir>/testdata/locks-many-with-insecure/package-lock.json file and found 1 package
432432
Scanned <rootdir>/testdata/locks-many-with-insecure/yarn.lock file and found 1 package
433-
Scanned <rootdir>/testdata/maven-transitive/pom.xml file and found 3 packages
433+
Scanned <rootdir>/testdata/maven-transitive/pom.xml file and found 1 package
434434
Filtered 1 local/unscannable package/s from the scan.
435435
Package npm/has-flag/4.0.0 has been filtered out because: (no reason given)
436436
Package npm/wrappy/1.0.2 has been filtered out because: (no reason given)
@@ -5444,7 +5444,7 @@ Fetching response from: https://repo.maven.apache.org/maven2/org/apache/logging/
54445444
Fetching response from: https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j-web/2.14.1/log4j-web-2.14.1.pom
54455445
Fetching response from: https://repo.maven.apache.org/maven2/org/apache/logging/log4j/log4j/2.14.1/log4j-2.14.1.pom
54465446
Fetching response from: https://repo.maven.apache.org/maven2/org/apache/logging/logging-parent/3/logging-parent-3.pom
5447-
Scanned <rootdir>/testdata/maven-transitive/registry.xml file and found 59 packages
5447+
Scanned <rootdir>/testdata/maven-transitive/registry.xml file and found 2 packages
54485448
Total 2 packages affected by 6 known vulnerabilities (2 Critical, 1 High, 3 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
54495449
6 vulnerabilities can be fixed.
54505450

@@ -5499,7 +5499,7 @@ Total 3 packages affected by 11 known vulnerabilities (1 Critical, 4 High, 6 Med
54995499
---
55005500

55015501
[TestCommand_Transitive/scans_dependencies_from_multiple_registries - 1]
5502-
Scanned <rootdir>/testdata/maven-transitive/registry.xml file and found 59 packages
5502+
Scanned <rootdir>/testdata/maven-transitive/registry.xml file and found 2 packages
55035503
Total 2 packages affected by 6 known vulnerabilities (2 Critical, 1 High, 3 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
55045504
6 vulnerabilities can be fixed.
55055505

@@ -5522,7 +5522,7 @@ Total 2 packages affected by 6 known vulnerabilities (2 Critical, 1 High, 3 Medi
55225522
---
55235523

55245524
[TestCommand_Transitive/scans_pom.xml_with_non_UTF-8_encoding - 1]
5525-
Scanned <rootdir>/testdata/maven-transitive/encoding.xml file and found 2 packages
5525+
Scanned <rootdir>/testdata/maven-transitive/encoding.xml file and found 1 package
55265526
Total 1 package affected by 1 known vulnerability (0 Critical, 0 High, 1 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
55275527
1 vulnerability can be fixed.
55285528

@@ -5540,7 +5540,7 @@ Total 1 package affected by 1 known vulnerability (0 Critical, 0 High, 1 Medium,
55405540
---
55415541

55425542
[TestCommand_Transitive/scans_transitive_dependencies_by_specifying_pom.xml - 1]
5543-
Scanned <rootdir>/testdata/maven-transitive/abc.xml file and found 3 packages
5543+
Scanned <rootdir>/testdata/maven-transitive/abc.xml file and found 1 package
55445544
Total 1 package affected by 5 known vulnerabilities (2 Critical, 1 High, 2 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
55455545
5 vulnerabilities can be fixed.
55465546

@@ -5563,7 +5563,7 @@ Total 1 package affected by 5 known vulnerabilities (2 Critical, 1 High, 2 Mediu
55635563

55645564
[TestCommand_Transitive/scans_transitive_dependencies_for_pom.xml_by_default - 1]
55655565
Scanning dir ./testdata/maven-transitive/pom.xml
5566-
Scanned <rootdir>/testdata/maven-transitive/pom.xml file and found 3 packages
5566+
Scanned <rootdir>/testdata/maven-transitive/pom.xml file and found 1 package
55675567
Total 1 package affected by 5 known vulnerabilities (2 Critical, 1 High, 2 Medium, 0 Low, 0 Unknown) from 1 ecosystem.
55685568
5 vulnerabilities can be fixed.
55695569

@@ -5584,6 +5584,16 @@ Total 1 package affected by 5 known vulnerabilities (2 Critical, 1 High, 2 Mediu
55845584

55855585
---
55865586

5587+
[TestCommand_Transitive/transitive_pomxml_enricher_requires_enabled_pomxml_extractor - 1]
5588+
Scanning dir ./testdata/maven-transitive/abc.xml
5589+
5590+
---
5591+
5592+
[TestCommand_Transitive/transitive_pomxml_enricher_requires_enabled_pomxml_extractor - 2]
5593+
No package sources found, --help for usage information.
5594+
5595+
---
5596+
55875597
[TestCommand_Transitive/transitive_requirements_enricher_requires_enabled_requirements_extractor - 1]
55885598
Scanning dir ./testdata/locks-requirements/requirements-transitive.txt
55895599

cmd/osv-scanner/scan/source/command_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,11 @@ func TestCommand_Transitive(t *testing.T) {
13351335
Args: []string{"", "source", "--experimental-disable-plugins=python/requirements", "./testdata/locks-requirements/requirements-transitive.txt"},
13361336
Exit: 128,
13371337
},
1338+
{
1339+
Name: "transitive_pomxml_enricher_requires_enabled_pomxml_extractor",
1340+
Args: []string{"", "source", "--experimental-disable-plugins=java/pomxml", "./testdata/maven-transitive/abc.xml"},
1341+
Exit: 128,
1342+
},
13381343
}
13391344

13401345
for _, tt := range tests {

internal/scalibrextract/language/java/pomxmlenhanceable/pomxmlenhanceable.go

Lines changed: 0 additions & 103 deletions
This file was deleted.

internal/scalibrplugin/__snapshots__/resolve_test.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ haskell/cabal
5353
haskell/stacklock
5454
java/gradlelockfile
5555
java/gradleverificationmetadataxml
56-
java/pomxmlenhanceable
56+
java/pomxml
5757
javascript/bunlock
5858
javascript/packagelockjson
5959
javascript/pnpmlock

internal/scalibrplugin/presets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/google/osv-scalibr/extractor/filesystem/language/java/archive"
2525
"github.com/google/osv-scalibr/extractor/filesystem/language/java/gradlelockfile"
2626
"github.com/google/osv-scalibr/extractor/filesystem/language/java/gradleverificationmetadataxml"
27+
"github.com/google/osv-scalibr/extractor/filesystem/language/java/pomxml"
2728
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/bunlock"
2829
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/packagelockjson"
2930
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/pnpmlock"
@@ -48,7 +49,6 @@ import (
4849
"github.com/google/osv-scanner/v2/internal/datasource"
4950
"github.com/google/osv-scanner/v2/internal/depsdev"
5051
"github.com/google/osv-scanner/v2/internal/scalibrextract/filesystem/vendored"
51-
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/java/pomxmlenhanceable"
5252
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/javascript/nodemodules"
5353
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/osv/osvscannerjson"
5454
"github.com/google/osv-scanner/v2/internal/scalibrextract/vcs/gitrepo"
@@ -83,7 +83,7 @@ var ExtractorPresets = map[string]extractors.InitMap{
8383
// Java
8484
gradlelockfile.Name: {gradlelockfile.New},
8585
gradleverificationmetadataxml.Name: {gradleverificationmetadataxml.New},
86-
pomxmlenhanceable.Name: {pomxmlenhanceable.New},
86+
pomxml.Name: {pomxml.New},
8787

8888
// Javascript
8989
packagelockjson.Name: {packagelockjson.New},

internal/scalibrplugin/resolve.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/google/osv-scalibr/plugin/list"
1010
"github.com/google/osv-scanner/v2/internal/cmdlogger"
1111
"github.com/google/osv-scanner/v2/internal/scalibrextract/filesystem/vendored"
12-
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/java/pomxmlenhanceable"
1312
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/javascript/nodemodules"
1413
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/osv/osvscannerjson"
1514
"github.com/google/osv-scanner/v2/internal/scalibrextract/vcs/gitrepo"
@@ -23,9 +22,6 @@ func resolveFromName(name string) (plugin.Plugin, error) {
2322
}
2423

2524
switch name {
26-
// Java
27-
case pomxmlenhanceable.Name:
28-
return pomxmlenhanceable.New(&cpb.PluginConfig{})
2925
// Javascript
3026
case nodemodules.Name:
3127
return nodemodules.New(&cpb.PluginConfig{})

pkg/osvscanner/internal/scanners/lockfile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/google/osv-scalibr/extractor/filesystem/language/haskell/stacklock"
2222
"github.com/google/osv-scalibr/extractor/filesystem/language/java/gradlelockfile"
2323
"github.com/google/osv-scalibr/extractor/filesystem/language/java/gradleverificationmetadataxml"
24+
"github.com/google/osv-scalibr/extractor/filesystem/language/java/pomxml"
2425
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/bunlock"
2526
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/packagelockjson"
2627
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/pnpmlock"
@@ -38,7 +39,6 @@ import (
3839
"github.com/google/osv-scalibr/extractor/filesystem/os/apk"
3940
"github.com/google/osv-scalibr/extractor/filesystem/os/dpkg"
4041
"github.com/google/osv-scalibr/plugin"
41-
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/java/pomxmlenhanceable"
4242
"github.com/google/osv-scanner/v2/internal/scalibrextract/language/osv/osvscannerjson"
4343
)
4444

@@ -50,7 +50,7 @@ var osvscannerScalibrExtractionMapping = map[string][]string{
5050
"pnpm-lock.yaml": {pnpmlock.Name},
5151
"yarn.lock": {yarnlock.Name},
5252
"package-lock.json": {packagelockjson.Name},
53-
"pom.xml": {pomxmlenhanceable.Name},
53+
"pom.xml": {pomxml.Name},
5454
"buildscript-gradle.lockfile": {gradlelockfile.Name},
5555
"gradle.lockfile": {gradlelockfile.Name},
5656
"verification-metadata.xml": {gradleverificationmetadataxml.Name},

0 commit comments

Comments
 (0)