@@ -15,6 +15,7 @@ import (
1515 transitivedependencyrequirements "github.com/google/osv-scalibr/enricher/transitivedependency/requirements"
1616 "github.com/google/osv-scalibr/extractor"
1717 "github.com/google/osv-scalibr/extractor/filesystem/language/java/pomxmlnet"
18+ "github.com/google/osv-scalibr/extractor/filesystem/language/python/requirements"
1819 "github.com/google/osv-scalibr/fs"
1920 "github.com/google/osv-scalibr/inventory"
2021 "github.com/google/osv-scalibr/plugin"
@@ -47,6 +48,18 @@ func configurePlugins(plugins []plugin.Plugin, accessors ExternalAccessors, acti
4748 }
4849}
4950
51+ func isRequirementsExtractorEnabled (plugins []plugin.Plugin ) bool {
52+ for _ , plug := range plugins {
53+ _ , ok := plug .(* requirements.Extractor )
54+
55+ if ok {
56+ return true
57+ }
58+ }
59+
60+ return false
61+ }
62+
5063func getPlugins (defaultPlugins []string , accessors ExternalAccessors , actions ScannerActions ) []plugin.Plugin {
5164 if ! actions .PluginsNoDefaults {
5265 actions .PluginsEnabled = append (actions .PluginsEnabled , defaultPlugins ... )
@@ -62,7 +75,8 @@ func getPlugins(defaultPlugins []string, accessors ExternalAccessors, actions Sc
6275
6376 plugins := scalibrplugin .Resolve (actions .PluginsEnabled , actions .PluginsDisabled )
6477
65- if accessors .DependencyClients [osvschema .EcosystemPyPI ] != nil {
78+ // todo: use Enricher.RequiredPlugins to check this generically
79+ if accessors .DependencyClients [osvschema .EcosystemPyPI ] != nil && isRequirementsExtractorEnabled (plugins ) {
6680 plugins = append (plugins , transitivedependencyrequirements .NewEnricher (accessors .DependencyClients [osvschema .EcosystemPyPI ]))
6781 }
6882
0 commit comments