mirror of
https://github.com/securego/gosec.git
synced 2024-11-06 03:55:50 +00:00
Check the suppressed issues when generating the exit code
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
parent
a5982fb6a6
commit
45bf9a6095
1 changed files with 14 additions and 4 deletions
|
@ -293,6 +293,19 @@ func filterIssues(issues []*gosec.Issue, severity gosec.Score, confidence gosec.
|
||||||
return result, trueIssues
|
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() {
|
func main() {
|
||||||
// Makes sure some version information is set
|
// Makes sure some version information is set
|
||||||
prepareVersionInfo()
|
prepareVersionInfo()
|
||||||
|
@ -449,8 +462,5 @@ func main() {
|
||||||
// Finalize logging
|
// Finalize logging
|
||||||
logWriter.Close() //#nosec
|
logWriter.Close() //#nosec
|
||||||
|
|
||||||
// Do we have an issue? If so exit 1 unless NoFail is set
|
exit(issues, errors, *flagNoFail)
|
||||||
if (len(issues) > 0 || len(errors) > 0) && !*flagNoFail {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue