@@ -418,7 +418,6 @@ func disabledAnalyzers(opts flag.Options) []analyzer.Type {
418
418
// Specified analyzers to be disabled depending on scanning modes
419
419
// e.g. The 'image' subcommand should disable the lock file scanning.
420
420
analyzers := opts .DisabledAnalyzers
421
-
422
421
// It doesn't analyze apk commands by default.
423
422
if ! opts .ScanRemovedPkgs {
424
423
analyzers = append (analyzers , analyzer .TypeApkCommand )
@@ -434,18 +433,16 @@ func disabledAnalyzers(opts flag.Options) []analyzer.Type {
434
433
analyzers = append (analyzers , analyzer .TypeSecret )
435
434
}
436
435
437
- // Filter only enabled misconfiguration scanners
438
- ma , err := filterMisconfigAnalyzers (opts .MisconfigScanners , analyzer .TypeConfigFiles )
439
- if err != nil {
440
- log .Error ("Invalid misconfiguration scanners specified, defaulting to use all misconfig scanners" ,
441
- log .Any ("scanners" , opts .MisconfigScanners ))
442
- } else {
443
- analyzers = append (analyzers , ma ... )
444
- }
445
-
446
436
// Do not perform misconfiguration scanning when it is not specified.
447
437
if ! opts .Scanners .AnyEnabled (types .MisconfigScanner , types .RBACScanner ) {
448
438
analyzers = append (analyzers , analyzer .TypeConfigFiles ... )
439
+ } else {
440
+ // Filter only enabled misconfiguration scanners
441
+ ma := disabledMisconfigAnalyzers (opts .MisconfigScanners )
442
+ analyzers = append (analyzers , ma ... )
443
+
444
+ log .Debug ("Enabling misconfiguration scanners" ,
445
+ log .Any ("scanners" , lo .Without (analyzer .TypeConfigFiles , ma ... )))
449
446
}
450
447
451
448
// Scanning file headers and license files is expensive.
@@ -482,14 +479,17 @@ func disabledAnalyzers(opts flag.Options) []analyzer.Type {
482
479
return analyzers
483
480
}
484
481
485
- func filterMisconfigAnalyzers (included , all []analyzer.Type ) ( []analyzer.Type , error ) {
486
- _ , missing := lo .Difference (all , included )
482
+ func disabledMisconfigAnalyzers (included []analyzer.Type ) []analyzer.Type {
483
+ _ , missing := lo .Difference (analyzer . TypeConfigFiles , included )
487
484
if len (missing ) > 0 {
488
- return nil , xerrors .Errorf ("invalid misconfiguration scanner specified %s valid scanners: %s" , missing , all )
485
+ log .Error (
486
+ "Invalid misconfiguration scanners provided, using default scanners" ,
487
+ log .Any ("invalid_scanners" , missing ), log .Any ("default_scanners" , analyzer .TypeConfigFiles ),
488
+ )
489
+ return nil
489
490
}
490
491
491
- log .Debug ("Enabling misconfiguration scanners" , log .Any ("scanners" , included ))
492
- return lo .Without (all , included ... ), nil
492
+ return lo .Without (analyzer .TypeConfigFiles , included ... )
493
493
}
494
494
495
495
func (r * runner ) initScannerConfig (ctx context.Context , opts flag.Options ) (ScannerConfig , types.ScanOptions , error ) {
0 commit comments