Skip to content
This repository was archived by the owner on May 24, 2025. It is now read-only.

Commit 6041689

Browse files
committed
Sanitize physical location URI in SARIF reports generated
1 parent a8a7c78 commit 6041689

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sarif/sarif.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,14 @@ func FromContainerScan(containerScanReport containerscan.ContainerScan) (SarifRe
221221
return sarifReport, nil
222222
}
223223

224+
const pathUriReplacement = "_"
225+
224226
func toPathUri(input string) string {
225-
return fmt.Sprintf("file://%s", input)
227+
var inputSanitized = strings.ReplaceAll(input, ":", pathUriReplacement)
228+
inputSanitized = strings.ReplaceAll(inputSanitized, " ", pathUriReplacement)
229+
inputSanitized = strings.ReplaceAll(inputSanitized, "(", pathUriReplacement)
230+
inputSanitized = strings.ReplaceAll(inputSanitized, ")", pathUriReplacement)
231+
return inputSanitized
226232
}
227233

228234
func (report SarifReport) WriteTo(outputPath string) error {

0 commit comments

Comments
 (0)