Skip to content

Commit

Permalink
fix: collapse logic when matching ignore to finding
Browse files Browse the repository at this point in the history
Co-authored-by: Callum Gardner <10970827+ctgardner@users.noreply.github.com>
  • Loading branch information
jamestelfer and ctgardner authored Nov 27, 2023
1 parent 8b8df74 commit 22f56a9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/finding/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,18 @@ func Summarize(findings *types.ImageScanFindings, ignoreConfig []findingconfig.I
summary.VulnerabilitySourceUpdatedAt = findings.VulnerabilitySourceUpdatedAt

for _, f := range findings.Findings {
var ignore *findingconfig.Ignore
detail := findingToDetail(f)

index := slices.IndexFunc(ignoreConfig, func(ignore findingconfig.Ignore) bool {
return ignore.ID == detail.Name
})

if index >= 0 {
ignore = &ignoreConfig[index]
}

detail.Ignore = ignore

if ignore == nil {
summary.addDetail(detail)
} else {
detail.Ignore = &ignoreConfig[index]
summary.addIgnored(detail)
}
} else {
summary.addDetail(detail)
}

Check failure on line 107 in src/finding/summary.go

View workflow job for this annotation

GitHub Actions / go-lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
}

return summary
Expand Down

0 comments on commit 22f56a9

Please sign in to comment.