@@ -11,17 +11,18 @@ import (
1111 "strings"
1212
1313 scalibr "github.com/google/osv-scalibr"
14+ cpb "github.com/google/osv-scalibr/binary/proto/config_go_proto"
1415 "github.com/google/osv-scalibr/enricher"
1516 "github.com/google/osv-scalibr/enricher/packagedeprecation"
1617 "github.com/google/osv-scalibr/enricher/reachability/java"
1718 transitivedependencyrequirements "github.com/google/osv-scalibr/enricher/transitivedependency/requirements"
1819 "github.com/google/osv-scalibr/extractor"
1920 "github.com/google/osv-scalibr/extractor/filesystem"
20- "github.com/google/osv-scalibr/extractor/filesystem/language/java/pomxmlnet"
2121 "github.com/google/osv-scalibr/extractor/filesystem/language/python/requirements"
2222 "github.com/google/osv-scalibr/extractor/filesystem/simplefileapi"
2323 "github.com/google/osv-scalibr/fs"
2424 "github.com/google/osv-scalibr/inventory"
25+ "github.com/google/osv-scalibr/log"
2526 "github.com/google/osv-scalibr/plugin"
2627 "github.com/google/osv-scanner/v2/internal/cmdlogger"
2728 "github.com/google/osv-scanner/v2/internal/imodels"
@@ -32,18 +33,29 @@ import (
3233 "github.com/google/osv-scanner/v2/internal/scalibrplugin"
3334 "github.com/google/osv-scanner/v2/internal/testlogger"
3435 "github.com/google/osv-scanner/v2/pkg/osvscanner/internal/scanners"
35- "github.com/ossf/osv-schema/bindings/go/osvconstants"
3636)
3737
3838var ErrExtractorNotFound = errors .New ("could not determine extractor suitable to this file" )
3939
4040func configurePlugins (plugins []plugin.Plugin , accessors ExternalAccessors , actions ScannerActions ) {
4141 for _ , plug := range plugins {
42- if accessors .DependencyClients [osvconstants .EcosystemMaven ] != nil && accessors .MavenRegistryAPIClient != nil {
43- pomxmlenhanceable .EnhanceIfPossible (plug , pomxmlnet.Config {
44- DependencyClient : accessors .DependencyClients [osvconstants .EcosystemMaven ],
45- MavenRegistryAPIClient : accessors .MavenRegistryAPIClient ,
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+ },
4655 })
56+ if err != nil {
57+ log .Errorf ("Failed to enhance pomxml extractor: %v" , err )
58+ }
4759 }
4860
4961 vendored .Configure (plug , vendored.Config {
@@ -81,9 +93,16 @@ func getPlugins(defaultPlugins []string, accessors ExternalAccessors, actions Sc
8193
8294 plugins := scalibrplugin .Resolve (actions .PluginsEnabled , actions .PluginsDisabled )
8395
84- // todo: use Enricher.RequiredPlugins to check this generically
85- if accessors .DependencyClients [osvconstants .EcosystemPyPI ] != nil && isRequirementsExtractorEnabled (plugins ) {
86- plugins = append (plugins , transitivedependencyrequirements .NewEnricher (accessors .DependencyClients [osvconstants .EcosystemPyPI ]))
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 )
105+ }
87106 }
88107
89108 configurePlugins (plugins , accessors , actions )
@@ -126,7 +145,14 @@ func scan(accessors ExternalAccessors, actions ScannerActions) (*imodels.ScanRes
126145 }
127146
128147 if actions .FlagDeprecatedPackages {
129- plugins = append (plugins , packagedeprecation .New ())
148+ p , err := packagedeprecation .New (& cpb.PluginConfig {
149+ UserAgent : actions .RequestUserAgent ,
150+ })
151+ if err != nil {
152+ log .Errorf ("Failed to make packagedeprecation enricher: %v" , err )
153+ } else {
154+ plugins = append (plugins , p )
155+ }
130156 }
131157
132158 scanner := scalibr .New ()
0 commit comments