Check the suppressed issues when generating the exit code

Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
Cosmin Cojocar 2022-07-28 10:58:55 +02:00 committed by Cosmin Cojocar
parent a5982fb6a6
commit 45bf9a6095

View file

@ -293,6 +293,19 @@ func filterIssues(issues []*gosec.Issue, severity gosec.Score, confidence gosec.
return result, trueIssues
}
func exit(issues []*gosec.Issue, errors map[string][]gosec.Error, noFail bool) {
nsi := 0
for _, issue := range issues {
if len(issue.Suppressions) == 0 {
nsi++
}
}
if (nsi > 0 || len(errors) > 0) && !*flagNoFail {
os.Exit(1)
}
os.Exit(0)
}
func main() {
// Makes sure some version information is set
prepareVersionInfo()
@ -449,8 +462,5 @@ func main() {
// Finalize logging
logWriter.Close() //#nosec
// Do we have an issue? If so exit 1 unless NoFail is set
if (len(issues) > 0 || len(errors) > 0) && !*flagNoFail {
os.Exit(1)
}
exit(issues, errors, *flagNoFail)
}