refactor: move setting scanners when using compliance reports to flag parsing (#6619)

This commit is contained in:
DmitriyLewen
2024-05-03 17:27:37 +06:00
committed by GitHub
parent 998f750432
commit 14c1024b47
3 changed files with 74 additions and 21 deletions

View File

@@ -533,25 +533,6 @@ func initScannerConfig(opts flag.Options, cacheClient cache.Cache) (ScannerConfi
target = opts.Input
}
if opts.Compliance.Spec.ID != "" {
// set scanners types by spec
scanners, err := opts.Compliance.Scanners()
if err != nil {
return ScannerConfig{}, types.ScanOptions{}, xerrors.Errorf("scanner error: %w", err)
}
opts.Scanners = scanners
opts.ImageConfigScanners = nil
// TODO: define image-config-scanners in the spec
if opts.Compliance.Spec.ID == "docker-cis" {
opts.Scanners = types.Scanners{types.VulnerabilityScanner}
opts.ImageConfigScanners = types.Scanners{
types.MisconfigScanner,
types.SecretScanner,
}
}
}
scanOptions := types.ScanOptions{
VulnType: opts.VulnType,
Scanners: opts.Scanners,