From 0e0da2b048845f535f18a21132e3a1a0a22464b6 Mon Sep 17 00:00:00 2001 From: Owen Rumney Date: Wed, 10 Nov 2021 10:09:40 +0000 Subject: [PATCH] add resource to the result block (#18) --- internal/app/cfsec/scanner/scanner.go | 4 ++-- pkg/result/result.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/app/cfsec/scanner/scanner.go b/internal/app/cfsec/scanner/scanner.go index 01e0f82f..c2061c40 100644 --- a/internal/app/cfsec/scanner/scanner.go +++ b/internal/app/cfsec/scanner/scanner.go @@ -75,7 +75,6 @@ func (scanner *Scanner) Scan(contexts parser.FileContexts) []result.Result { for _, scanResult := range evalResult { location := scanResult.Reference().(*parser.CFReference) - if !isIgnored(scanResult) { description := getDescription(scanResult, location) addResult := result.Result{ @@ -87,6 +86,7 @@ func (scanner *Scanner) Scan(contexts parser.FileContexts) []result.Result { Links: scanResult.Rule().Links, Description: description, Severity: scanResult.Rule().Severity, + Resource: location.LogicalID(), Location: result.LocationBlock{ Filename: location.ResourceRange().GetFilename(), StartLine: location.ResourceRange().GetStartLine(), @@ -109,7 +109,7 @@ func (scanner *Scanner) Scan(contexts parser.FileContexts) []result.Result { func getDescription(scanResult rules.Result, location *parser.CFReference) string { if scanResult.Status() != rules.StatusPassed { - return fmt.Sprintf("Resource '%s' %s", location.LogicalID(), scanResult.Description()) + return scanResult.Description() } return fmt.Sprintf("Resource '%s' passed check: %s", location.LogicalID(), scanResult.Rule().Summary) } diff --git a/pkg/result/result.go b/pkg/result/result.go index 371320b3..e725e1b4 100644 --- a/pkg/result/result.go +++ b/pkg/result/result.go @@ -47,6 +47,7 @@ type Result struct { Severity severity.Severity `json:"severity"` Status rules.Status `json:"status"` Location LocationBlock `json:"location"` + Resource string `json:"resource"` resolvedProperty parser.Property }