mirror of
https://github.com/securego/gosec.git
synced 2025-07-17 01:12:33 +02:00
Add support for suppressing the findings
This commit is contained in:
@ -53,6 +53,9 @@ const (
|
||||
// the specified format. The formats currently accepted are: json, yaml, csv, junit-xml, html, sonarqube, golint and text.
|
||||
func CreateReport(w io.Writer, format string, enableColor bool, rootPaths []string, data *gosec.ReportInfo) error {
|
||||
var err error
|
||||
if format != "json" && format != "sarif" {
|
||||
data.Issues = filterOutSuppressedIssues(data.Issues)
|
||||
}
|
||||
switch format {
|
||||
case "json":
|
||||
err = json.WriteReport(w, data)
|
||||
@ -77,3 +80,13 @@ func CreateReport(w io.Writer, format string, enableColor bool, rootPaths []stri
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func filterOutSuppressedIssues(issues []*gosec.Issue) []*gosec.Issue {
|
||||
nonSuppressedIssues := []*gosec.Issue{}
|
||||
for _, issue := range issues {
|
||||
if len(issue.Suppressions) == 0 {
|
||||
nonSuppressedIssues = append(nonSuppressedIssues, issue)
|
||||
}
|
||||
}
|
||||
return nonSuppressedIssues
|
||||
}
|
||||
|
Reference in New Issue
Block a user