From 3ed39fe61272d6aeb4f450eb48a5e409448f3a4a Mon Sep 17 00:00:00 2001 From: Mark Wolfe Date: Fri, 22 Jan 2021 20:15:52 +1100 Subject: [PATCH] fix sarif add default configuration set to correct level --- output/sarif_format.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/output/sarif_format.go b/output/sarif_format.go index 6a5ca73..393a27e 100644 --- a/output/sarif_format.go +++ b/output/sarif_format.go @@ -21,12 +21,17 @@ type sarifProperties struct { } type sarifRule struct { - ID string `json:"id"` - Name string `json:"name"` - ShortDescription *sarifMessage `json:"shortDescription"` - FullDescription *sarifMessage `json:"fullDescription"` - Help *sarifMessage `json:"help"` - Properties *sarifProperties `json:"properties"` + ID string `json:"id"` + Name string `json:"name"` + ShortDescription *sarifMessage `json:"shortDescription"` + FullDescription *sarifMessage `json:"fullDescription"` + Help *sarifMessage `json:"help"` + Properties *sarifProperties `json:"properties"` + DefaultConfiguration *sarifConfiguration `json:"defaultConfiguration"` +} + +type sarifConfiguration struct { + Level sarifLevel `json:"level"` } type sarifArtifactLocation struct { @@ -108,6 +113,9 @@ func buildSarifRule(issue *gosec.Issue) *sarifRule { Properties: &sarifProperties{ Tags: []string{fmt.Sprintf("CWE-%s", issue.Cwe.ID), issue.Severity.String()}, }, + DefaultConfiguration: &sarifConfiguration{ + Level: getSarifLevel(issue.Severity.String()), + }, } }