From 48b1209d6b009b577c843cdada4cb3bb2c73317d Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Tue, 1 Oct 2024 08:46:15 +0200 Subject: [PATCH] sort dynamic opens on path Signed-off-by: Matthias Bertschy --- pkg/registry/file/dynamicpathdetector/analyze_opens.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/registry/file/dynamicpathdetector/analyze_opens.go b/pkg/registry/file/dynamicpathdetector/analyze_opens.go index 5cad50d6..387dcc83 100644 --- a/pkg/registry/file/dynamicpathdetector/analyze_opens.go +++ b/pkg/registry/file/dynamicpathdetector/analyze_opens.go @@ -3,6 +3,7 @@ package dynamicpathdetector import ( "maps" "slices" + "strings" mapset "github.com/deckarep/golang-set/v2" types "github.com/kubescape/storage/pkg/apis/softwarecomposition" @@ -33,7 +34,9 @@ func AnalyzeOpens(opens []types.OpenCalls, analyzer *PathAnalyzer) ([]types.Open } } - return slices.Collect(maps.Values(dynamicOpens)), nil + return slices.SortedFunc(maps.Values(dynamicOpens), func(a, b types.OpenCalls) int { + return strings.Compare(a.Path, b.Path) + }), nil } func AnalyzeOpen(path string, analyzer *PathAnalyzer) (string, error) {