@@ -15,6 +15,7 @@ import (
1515 "github.com/google/osv-scalibr/enricher"
1616 "github.com/google/osv-scalibr/enricher/packagedeprecation"
1717 "github.com/google/osv-scalibr/enricher/reachability/java"
18+ transitivedependencypomxml "github.com/google/osv-scalibr/enricher/transitivedependency/pomxml"
1819 transitivedependencyrequirements "github.com/google/osv-scalibr/enricher/transitivedependency/requirements"
1920 "github.com/google/osv-scalibr/extractor"
2021 "github.com/google/osv-scalibr/extractor/filesystem"
@@ -27,7 +28,6 @@ import (
2728 "github.com/google/osv-scanner/v2/internal/cmdlogger"
2829 "github.com/google/osv-scanner/v2/internal/imodels"
2930 "github.com/google/osv-scanner/v2/internal/scalibrextract/filesystem/vendored"
30- "github.com/google/osv-scanner/v2/internal/scalibrextract/language/java/pomxmlenhanceable"
3131 "github.com/google/osv-scanner/v2/internal/scalibrextract/vcs/gitcommitdirect"
3232 "github.com/google/osv-scanner/v2/internal/scalibrextract/vcs/gitrepo"
3333 "github.com/google/osv-scanner/v2/internal/scalibrplugin"
@@ -39,25 +39,6 @@ var ErrExtractorNotFound = errors.New("could not determine extractor suitable to
3939
4040func configurePlugins (plugins []plugin.Plugin , accessors ExternalAccessors , actions ScannerActions ) {
4141 for _ , plug := range plugins {
42- if ! actions .TransitiveScanning .Disabled {
43- err := pomxmlenhanceable .EnhanceIfPossible (plug , & cpb.PluginConfig {
44- UserAgent : actions .RequestUserAgent ,
45- PluginSpecific : []* cpb.PluginSpecificConfig {
46- {
47- Config : & cpb.PluginSpecificConfig_PomXmlNet {
48- PomXmlNet : & cpb.POMXMLNetConfig {
49- UpstreamRegistry : actions .TransitiveScanning .MavenRegistry ,
50- DepsDevRequirements : ! actions .TransitiveScanning .NativeDataSource ,
51- },
52- },
53- },
54- },
55- })
56- if err != nil {
57- log .Errorf ("Failed to enhance pomxml extractor: %v" , err )
58- }
59- }
60-
6142 vendored .Configure (plug , vendored.Config {
6243 // Only attempt to vendor check git directories if we are not skipping scanning root git directories
6344 ScanGitDir : ! actions .IncludeGitRoot ,
@@ -78,6 +59,18 @@ func isRequirementsExtractorEnabled(plugins []plugin.Plugin) bool {
7859 return false
7960}
8061
62+ func isPomXmlExtractorEnabled (plugins []plugin.Plugin ) bool {
63+ for _ , plug := range plugins {
64+ _ , ok := plug .(* requirements.Extractor )
65+
66+ if ok {
67+ return true
68+ }
69+ }
70+
71+ return false
72+ }
73+
8174func getPlugins (defaultPlugins []string , accessors ExternalAccessors , actions ScannerActions ) []plugin.Plugin {
8275 if ! actions .PluginsNoDefaults {
8376 actions .PluginsEnabled = append (actions .PluginsEnabled , defaultPlugins ... )
@@ -93,15 +86,39 @@ func getPlugins(defaultPlugins []string, accessors ExternalAccessors, actions Sc
9386
9487 plugins := scalibrplugin .Resolve (actions .PluginsEnabled , actions .PluginsDisabled )
9588
96- // TODO: Use Enricher.RequiredPlugins to check this generically
97- if ! actions .TransitiveScanning .Disabled && isRequirementsExtractorEnabled (plugins ) {
98- p , err := transitivedependencyrequirements .New (& cpb.PluginConfig {
99- UserAgent : actions .RequestUserAgent ,
100- })
101- if err != nil {
102- log .Errorf ("Failed to make transitivedependencyrequirements enricher: %v" , err )
103- } else {
104- plugins = append (plugins , p )
89+ if ! actions .TransitiveScanning .Disabled {
90+ // TODO: Use Enricher.RequiredPlugins to check this generically
91+ if isRequirementsExtractorEnabled (plugins ) {
92+ p , err := transitivedependencyrequirements .New (& cpb.PluginConfig {
93+ UserAgent : actions .RequestUserAgent ,
94+ })
95+ if err != nil {
96+ log .Errorf ("Failed to make transitivedependencyrequirements enricher: %v" , err )
97+ } else {
98+ plugins = append (plugins , p )
99+ }
100+ }
101+
102+ // TODO: Use Enricher.RequiredPlugins to check this generically
103+ if isPomXmlExtractorEnabled (plugins ) {
104+ p , err := transitivedependencypomxml .New (& cpb.PluginConfig {
105+ UserAgent : actions .RequestUserAgent ,
106+ PluginSpecific : []* cpb.PluginSpecificConfig {
107+ {
108+ Config : & cpb.PluginSpecificConfig_PomXmlNet {
109+ PomXmlNet : & cpb.POMXMLNetConfig {
110+ UpstreamRegistry : actions .TransitiveScanning .MavenRegistry ,
111+ DepsDevRequirements : ! actions .TransitiveScanning .NativeDataSource ,
112+ },
113+ },
114+ },
115+ },
116+ })
117+ if err != nil {
118+ log .Errorf ("Failed to make transitivedependencypomxml enricher: %v" , err )
119+ } else {
120+ plugins = append (plugins , p )
121+ }
105122 }
106123 }
107124
0 commit comments