Skip to content

Commit 9951ba3

Browse files
feat: propagate resultId to SARIF (#359)
<!-- Thanks for contributing to 2ms by offering a pull request. --> Closes # **Proposed Changes** Have the resultId in SARIF report. I put the resultId in the field result.properties.resultId. I was thinking of putting in the result.Guid field but the format does not match the pattern of "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$" in the SARIF schema. https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json <!-- Please describe the big picture of your changes here. If it fixes a bug or resolves a feature request, be sure to link to that issue. --> **Checklist** - [x] I covered my changes with tests. - [ ] I Updated the documentation that is affected by my changes: - [ ] Change in the CLI arguments - [ ] Change in the configuration file I submit this contribution under the Apache-2.0 license.
1 parent f606f03 commit 9951ba3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

lib/reporting/report_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ var (
136136
Properties: Properties{
137137
"validationStatus": string(result1.ValidationStatus),
138138
"cvssScore": result1.CvssScore,
139+
"resultId": result1.ID,
139140
},
140141
}
141142
result2Sarif = Results{
@@ -167,6 +168,7 @@ var (
167168
Properties: Properties{
168169
"validationStatus": string(result2.ValidationStatus),
169170
"cvssScore": result2.CvssScore,
171+
"resultId": result2.ID,
170172
},
171173
}
172174
result3Sarif = Results{
@@ -198,6 +200,7 @@ var (
198200
Properties: Properties{
199201
"validationStatus": string(result3.ValidationStatus),
200202
"cvssScore": result3.CvssScore,
203+
"resultId": result3.ID,
201204
},
202205
}
203206
result4Sarif = Results{
@@ -230,6 +233,7 @@ var (
230233
"validationStatus": string(result4.ValidationStatus),
231234
"cvssScore": result4.CvssScore,
232235
"confluence.pageId": result4.ExtraDetails["confluence.pageId"],
236+
"resultId": result4.ID,
233237
},
234238
}
235239
)

lib/reporting/sarif.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func getResults(report *Report) []Results {
9494
props := Properties{
9595
"validationStatus": secret.ValidationStatus,
9696
"cvssScore": secret.CvssScore,
97+
"resultId": secret.ID,
9798
}
9899

99100
if secret.ExtraDetails != nil {

0 commit comments

Comments
 (0)