diff --git a/pkg/scanners/kubernetes/scanner.go b/pkg/scanners/kubernetes/scanner.go index 2b51f0164..0d5fb6edc 100644 --- a/pkg/scanners/kubernetes/scanner.go +++ b/pkg/scanners/kubernetes/scanner.go @@ -5,6 +5,7 @@ import ( "io" "io/fs" "path/filepath" + "sort" "sync" "github.com/aquasecurity/defsec/pkg/types" @@ -174,5 +175,9 @@ func (s *Scanner) ScanFS(ctx context.Context, target fs.FS, dir string) (scan.Re return nil, err } results.SetSourceAndFilesystem("", target, false) + + sort.Slice(results, func(i, j int) bool { + return results[i].Rule().AVDID < results[j].Rule().AVDID + }) return results, nil } diff --git a/pkg/scanners/kubernetes/scanner_test.go b/pkg/scanners/kubernetes/scanner_test.go index e87aeec95..f782c7ded 100644 --- a/pkg/scanners/kubernetes/scanner_test.go +++ b/pkg/scanners/kubernetes/scanner_test.go @@ -543,7 +543,6 @@ func Test_FileScanExampleWithResultFunction(t *testing.T) { results, err := NewScanner( options.ScannerWithDebug(os.Stdout), - options.ScannerWithTrace(os.Stdout), options.ScannerWithEmbeddedPolicies(true), options.ScannerWithEmbeddedLibraries(true), options.ScannerWithPolicyReader(strings.NewReader(`package defsec