@@ -48,10 +48,11 @@ type ScannerActions struct {
4848 ManifestParsers bool
4949 DDEnvVars DDEnvVars
5050 ExitOnConfigFailure bool
51- // ExtractMavenPomArtifactIds controls whether Maven pom.xml artifact IDs
52- // and parent dependency relationships are extracted and included in the SBOM.
51+ // ExtractArtifactIds controls whether build file artifact IDs and dependency
52+ // relationships are extracted and included in the SBOM. When true, extractors
53+ // that implement ArtifactExtractor produce ScannedArtifact entries.
5354 // When false, ScannedArtifact entries are never produced.
54- ExtractMavenPomArtifactIds bool
55+ ExtractArtifactIds bool
5556}
5657
5758type DDEnvVars struct {
@@ -82,7 +83,7 @@ var ErrAPIFailed = models.ErrAPIFailed
8283// scanDir walks through the given directory to try to find any relevant files
8384// These include:
8485// - Any lockfiles with scanLockfile
85- func scanDir (r reporter.Reporter , dir string , repoRoot string , recursive bool , useGitIgnore bool , enabledParsers map [string ]bool , cliExcludePaths []string , configExcludePaths []string , extractMavenPomArtifactIds bool ) ([]extractor.PackageDetails , []models.ScannedArtifact , error ) {
86+ func scanDir (r reporter.Reporter , dir string , repoRoot string , recursive bool , useGitIgnore bool , enabledParsers map [string ]bool , cliExcludePaths []string , configExcludePaths []string , extractArtifacts bool ) ([]extractor.PackageDetails , []models.ScannedArtifact , error ) {
8687 scanRoot := dir
8788 // Normalize the scan root once before exclusion matching.
8889 if absPath , err := filepath .Abs (dir ); err == nil {
@@ -154,7 +155,7 @@ func scanDir(r reporter.Reporter, dir string, repoRoot string, recursive bool, u
154155 return nil
155156 }
156157
157- context := extractor.ScanContext {EnabledParsers : enabledParsers , RootDir : dir , Reporter : r , ExtractMavenPomArtifactIds : extractMavenPomArtifactIds }
158+ context := extractor.ScanContext {EnabledParsers : enabledParsers , RootDir : dir , Reporter : r , ExtractArtifactIds : extractArtifacts }
158159 pkgs , artifact , err := scanLockfile (path , context )
159160 if err != nil {
160161 r .Warnf ("Attempted to scan lockfile but failed: %s (%v)\n " , path , err .Error ())
@@ -303,7 +304,7 @@ func DoScan(actions ScannerActions, r reporter.Reporter) (models.VulnerabilityRe
303304 absolutePath = absPath
304305 }
305306 r .Infof ("Scanning directory '%s', resolved absolute path '%s'\n " , dir , absolutePath )
306- pkgs , artifacts , err := scanDir (r , dir , repoRoot , actions .Recursive , ! actions .NoIgnore , enabledParsers , actions .ExcludePaths , configExcludePaths , actions .ExtractMavenPomArtifactIds )
307+ pkgs , artifacts , err := scanDir (r , dir , repoRoot , actions .Recursive , ! actions .NoIgnore , enabledParsers , actions .ExcludePaths , configExcludePaths , actions .ExtractArtifactIds )
307308 if err != nil {
308309 return models.VulnerabilityResults {}, err
309310 }
0 commit comments