From e213aa365234a30fffaaf548c7ec52ba896a721d Mon Sep 17 00:00:00 2001 From: Christian Zunker Date: Thu, 9 Mar 2023 11:09:01 +0100 Subject: [PATCH] Show 'Controls:' on when there are controls present Signed-off-by: Christian Zunker --- cli/reporter/print_compact.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cli/reporter/print_compact.go b/cli/reporter/print_compact.go index 31f8d033..0cce35a2 100644 --- a/cli/reporter/print_compact.go +++ b/cli/reporter/print_compact.go @@ -373,20 +373,22 @@ func (r *defaultReporter) printAssetQueries(resolved *policy.ResolvedPolicy, rep r.out.Write([]byte(NewLineCharacter)) } - r.out.Write([]byte("Controls:" + NewLineCharacter)) - for id, score := range report.Scores { - _, ok := resolved.CollectorJob.ReportingQueries[id] - if !ok { - continue - } + if len(report.Scores) >= 0 { + r.out.Write([]byte("Controls:" + NewLineCharacter)) + for id, score := range report.Scores { + _, ok := resolved.CollectorJob.ReportingQueries[id] + if !ok { + continue + } - query, ok := queries[id] - if !ok { - r.out.Write([]byte("Couldn't find any queries for incoming value for " + id)) - continue - } + query, ok := queries[id] + if !ok { + r.out.Write([]byte("Couldn't find any queries for incoming value for " + id)) + continue + } - r.printControl(score, query, asset, resolved, report, results) + r.printControl(score, query, asset, resolved, report, results) + } } }