@@ -20,6 +20,7 @@ import (
2020var (
2121 ruleID1 = "ruleID1"
2222 ruleID2 = "ruleID2"
23+ ruleID4 = "ruleID4"
2324 result1 = & secrets.Secret {
2425 ID : "ID1" ,
2526 Source : "file1" ,
6465 CvssScore : 0.0 ,
6566 RuleDescription : "Rule Description" ,
6667 }
68+ // result for confluence.pageId validation
69+ result4 = & secrets.Secret {
70+ ID : "ID4" ,
71+ Source : "file4" ,
72+ RuleID : "ruleID4" ,
73+ StartLine : 0 ,
74+ EndLine : 0 ,
75+ LineContent : "line content4" ,
76+ StartColumn : 11 ,
77+ EndColumn : 130 ,
78+ Value : "value 4" ,
79+ ValidationStatus : secrets .UnknownResult ,
80+ CvssScore : 0.0 ,
81+ RuleDescription : "Rule Description" ,
82+ ExtraDetails : map [string ]interface {}{
83+ "confluence.pageId" : "1234567890" ,
84+ },
85+ }
6786)
6887
6988// test expected outputs
@@ -81,6 +100,12 @@ var (
81100 Text : result2 .RuleDescription ,
82101 },
83102 }
103+ rule4Sarif = & SarifRule {
104+ ID : ruleID4 ,
105+ FullDescription : & Message {
106+ Text : result4 .RuleDescription ,
107+ },
108+ }
84109 // sarif results
85110 result1Sarif = Results {
86111 Message : Message {
@@ -175,6 +200,38 @@ var (
175200 "cvssScore" : result3 .CvssScore ,
176201 },
177202 }
203+ result4Sarif = Results {
204+ Message : Message {
205+ Text : createMessageText (result4 .RuleID , result4 .Source ),
206+ },
207+ RuleId : ruleID4 ,
208+ Locations : []Locations {
209+ {
210+ PhysicalLocation : PhysicalLocation {
211+ ArtifactLocation : ArtifactLocation {
212+ URI : result4 .Source ,
213+ },
214+ Region : Region {
215+ StartLine : result4 .StartLine ,
216+ StartColumn : result4 .StartColumn ,
217+ EndLine : result4 .EndLine ,
218+ EndColumn : result4 .EndColumn ,
219+ Snippet : Snippet {
220+ Text : result4 .Value ,
221+ Properties : Properties {
222+ "lineContent" : strings .TrimSpace (result4 .LineContent ),
223+ },
224+ },
225+ },
226+ },
227+ },
228+ },
229+ Properties : Properties {
230+ "validationStatus" : string (result4 .ValidationStatus ),
231+ "cvssScore" : result4 .CvssScore ,
232+ "confluence.pageId" : result4 .ExtraDetails ["confluence.pageId" ],
233+ },
234+ }
178235)
179236
180237func TestAddSecretToFile (t * testing.T ) {
@@ -293,6 +350,33 @@ func TestGetOutputSarif(t *testing.T) {
293350 },
294351 },
295352 },
353+ {
354+ name : "includes confluence.pageId in sarif result properties" ,
355+ arg : & Report {
356+ TotalItemsScanned : 1 ,
357+ TotalSecretsFound : 1 ,
358+ Results : map [string ][]* secrets.Secret {
359+ "secret1" : {result4 },
360+ },
361+ },
362+ wantErr : false ,
363+ want : []Runs {
364+ {
365+ Tool : Tool {
366+ Driver : Driver {
367+ Name : "report" ,
368+ SemanticVersion : "1" ,
369+ Rules : []* SarifRule {
370+ rule4Sarif ,
371+ },
372+ },
373+ },
374+ Results : []Results {
375+ result4Sarif ,
376+ },
377+ },
378+ },
379+ },
296380 }
297381
298382 for _ , tt := range tests {
0 commit comments