Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
add resource to the result block (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Rumney authored Nov 10, 2021
1 parent 3a5b90e commit 0e0da2b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/app/cfsec/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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(),
Expand All @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/result/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 0e0da2b

Please sign in to comment.