@@ -37,7 +37,6 @@ import (
3737 "github.com/google/osv-scanner/v2/pkg/models"
3838 "github.com/google/osv-scanner/v2/pkg/osvscanner/internal/imagehelpers"
3939 "github.com/ossf/osv-schema/bindings/go/osvconstants"
40- "github.com/ossf/osv-schema/bindings/go/osvschema"
4140 "osv.dev/bindings/go/osvdev"
4241)
4342
@@ -422,11 +421,7 @@ func finalizeScanResult(scanResult results.ScanResults, actions ScannerActions)
422421 // - c: filtering removes vulns from results, so need to account for that
423422 if actions .UpdateConfigIgnores == "all" {
424423 // todo: add output about having ignored vulns
425- err := updateConfigs (& vulnerabilityResults , & scanResult .ConfigManager )
426-
427- if err != nil {
428- return models.VulnerabilityResults {}, err
429- }
424+ addVulnConfigIgnores (& vulnerabilityResults , & scanResult .ConfigManager )
430425 }
431426
432427 filtered := filterResults (& vulnerabilityResults , & scanResult .ConfigManager , actions .ShowAllPackages )
@@ -440,7 +435,11 @@ func finalizeScanResult(scanResult results.ScanResults, actions ScannerActions)
440435
441436 if actions .UpdateConfigIgnores == "unused" {
442437 // todo: add output about having ignored vulns
443- err := updateConfigsToRemoveUnusedIgnores (& scanResult .ConfigManager )
438+ removeAllUnusedConfigIgnores (& scanResult .ConfigManager )
439+ }
440+
441+ if actions .UpdateConfigIgnores != "" && actions .UpdateConfigIgnores != "none" {
442+ err := saveAllConfigs (& scanResult .ConfigManager )
444443
445444 if err != nil {
446445 return models.VulnerabilityResults {}, err
@@ -463,68 +462,6 @@ func finalizeScanResult(scanResult results.ScanResults, actions ScannerActions)
463462 return vulnerabilityResults , determineReturnErr (vulnerabilityResults , actions .ShowAllVulns )
464463}
465464
466- func updateConfigs (vulnResults * models.VulnerabilityResults , configManager * config.Manager ) error {
467- configVulns := make (map [string ][]* osvschema.Vulnerability )
468- configPaths := make (map [string ]config.Config )
469-
470- for _ , pkgSrc := range vulnResults .Results {
471- c := configManager .Get (pkgSrc .Source .Path )
472-
473- // skip the default config
474- if c .LoadPath == "" {
475- continue
476- }
477-
478- configPaths [c .LoadPath ] = c
479-
480- for _ , pkgVulns := range pkgSrc .Packages {
481- configVulns [c .LoadPath ] = append (configVulns [c .LoadPath ], pkgVulns .Vulnerabilities ... )
482- }
483- }
484-
485- // update each config to ignore all the vulnerabilities
486- // found across all packages that are using that config
487- for p , vulns := range configVulns {
488- c := configPaths [p ]
489-
490- c .IgnoreVulns (vulns )
491-
492- err := c .Save ()
493- if err != nil {
494- return err
495- }
496- }
497-
498- return nil
499- }
500-
501- func updateConfigsToRemoveUnusedIgnores (configManager * config.Manager ) error {
502- if configManager .OverrideConfig != nil {
503- configManager .OverrideConfig .RemoveUnusedIgnores ()
504-
505- err := configManager .OverrideConfig .Save ()
506- if err != nil {
507- return err
508- }
509- }
510-
511- for _ , c := range configManager .ConfigMap {
512- // skip the default config
513- if c .LoadPath == "" {
514- continue
515- }
516-
517- c .RemoveUnusedIgnores ()
518-
519- err := c .Save ()
520- if err != nil {
521- return err
522- }
523- }
524-
525- return nil
526- }
527-
528465func buildLicenseSummary (scanResult * results.ScanResults ) []models.LicenseCount {
529466 var licenseSummary []models.LicenseCount
530467
0 commit comments