diff --git a/report/csv.go b/report/csv.go index 71278289..86d041d1 100644 --- a/report/csv.go +++ b/report/csv.go @@ -4,6 +4,7 @@ import ( "encoding/csv" "io" "strconv" + "strings" ) // writeCsv writes the list of findings to a writeCloser. @@ -28,6 +29,7 @@ func writeCsv(f []Finding, w io.WriteCloser) error { "Date", "Email", "Fingerprint", + "Tags", }) if err != nil { return err @@ -48,6 +50,7 @@ func writeCsv(f []Finding, w io.WriteCloser) error { f.Date, f.Email, f.Fingerprint, + strings.Join(f.Tags, " "), }) if err != nil { return err diff --git a/report/csv_test.go b/report/csv_test.go index 441b1557..0a1a7f52 100644 --- a/report/csv_test.go +++ b/report/csv_test.go @@ -35,6 +35,7 @@ func TestWriteCSV(t *testing.T) { Email: "johndoe@gmail.com", Date: "10-19-2003", Fingerprint: "fingerprint", + Tags: []string{"tag1", "tag2", "tag3"}, }, }}, { diff --git a/report/sarif.go b/report/sarif.go index 09719e49..732e0463 100644 --- a/report/sarif.go +++ b/report/sarif.go @@ -104,6 +104,9 @@ func getResults(findings []Finding) []Results { Date: f.Date, Author: f.Author, }, + Properties: Properties{ + Tags: f.Tags, + }, } results = append(results, r) } @@ -203,11 +206,16 @@ type Locations struct { PhysicalLocation PhysicalLocation `json:"physicalLocation"` } +type Properties struct { + Tags []string `json:"tags"` +} + type Results struct { Message Message `json:"message"` RuleId string `json:"ruleId"` Locations []Locations `json:"locations"` PartialFingerPrints `json:"partialFingerprints"` + Properties Properties `json:"properties"` } type Runs struct { diff --git a/report/sarif_test.go b/report/sarif_test.go index 1e8e99c8..7fb88452 100644 --- a/report/sarif_test.go +++ b/report/sarif_test.go @@ -43,7 +43,7 @@ func TestWriteSarif(t *testing.T) { Author: "John Doe", Email: "johndoe@gmail.com", Date: "10-19-2003", - Tags: []string{}, + Tags: []string{"tag1", "tag2", "tag3"}, }, }}, } diff --git a/testdata/expected/report/csv_simple.csv b/testdata/expected/report/csv_simple.csv index a02ab010..71b68c9e 100644 --- a/testdata/expected/report/csv_simple.csv +++ b/testdata/expected/report/csv_simple.csv @@ -1,2 +1,2 @@ -RuleID,Commit,File,SymlinkFile,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint -test-rule,0000000000000000,auth.py,,a secret,line containing secret,1,2,1,2,John Doe,opps,10-19-2003,johndoe@gmail.com,fingerprint +RuleID,Commit,File,SymlinkFile,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint,Tags +test-rule,0000000000000000,auth.py,,a secret,line containing secret,1,2,1,2,John Doe,opps,10-19-2003,johndoe@gmail.com,fingerprint,tag1 tag2 tag3 diff --git a/testdata/expected/report/sarif_simple.sarif b/testdata/expected/report/sarif_simple.sarif index 0b1b15f7..a43c7896 100644 --- a/testdata/expected/report/sarif_simple.sarif +++ b/testdata/expected/report/sarif_simple.sarif @@ -294,6 +294,13 @@ "author": "John Doe", "date": "10-19-2003", "commitMessage": "opps" + }, + "properties": { + "tags": [ + "tag1", + "tag2", + "tag3" + ] } } ]