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

add resource to the result block #18

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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