Skip to content

Commit

Permalink
chore(k8s): Fix a flaky test (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
simar7 authored Aug 5, 2023
1 parent aa6bb16 commit 85c168b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/scanners/kubernetes/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"io/fs"
"path/filepath"
"sort"
"sync"

"github.com/aquasecurity/defsec/pkg/types"
Expand Down Expand Up @@ -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
}
1 change: 0 additions & 1 deletion pkg/scanners/kubernetes/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85c168b

Please sign in to comment.