From 483ba829bd8383f5187aa23ca249a9875bae8c7d Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Tue, 27 Aug 2024 12:12:47 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20lint=20error=20for=20duplicate?= =?UTF-8?q?=20uids=20in=20a=20query=20pack=20(#4612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ivan Milchev --- internal/bundle/lint.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/bundle/lint.go b/internal/bundle/lint.go index e847e4ff11..757e09c007 100644 --- a/internal/bundle/lint.go +++ b/internal/bundle/lint.go @@ -6,9 +6,10 @@ package bundle import ( "context" "fmt" + "strconv" + "go.mondoo.com/cnquery/v11/explorer" "go.mondoo.com/cnquery/v11/providers" - "strconv" ) func Lint(queryPackBundle *explorer.Bundle) []string { @@ -29,12 +30,17 @@ func Lint(queryPackBundle *explorer.Bundle) []string { errors = append(errors, fmt.Sprintf("pack %s does not define a name", packId)) } + queryUids := map[string]struct{}{} for j := range pack.Queries { query := pack.Queries[j] queryId := strconv.Itoa(j) if query.Uid == "" { errors = append(errors, fmt.Sprintf("query %s/%s does not define a uid", packId, queryId)) } else { + if _, ok := queryUids[query.Uid]; ok { + errors = append(errors, fmt.Sprintf("query %s/%s has a duplicate uid", packId, query.Uid)) + } + queryUids[query.Uid] = struct{}{} queryId = query.Uid }