-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(report): Fix invalid URI in SARIF report (#7645)
Co-authored-by: DmitriyLewen <[email protected]>
- Loading branch information
1 parent
ab3a3b2
commit 015bb88
Showing
2 changed files
with
41 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ func TestReportWriter_Sarif(t *testing.T) { | |
}, | ||
Results: types.Results{ | ||
{ | ||
Target: "library/test", | ||
Target: "library/test 1", | ||
Class: types.ClassOSPkg, | ||
Packages: []ftypes.Package{ | ||
{ | ||
|
@@ -137,10 +137,10 @@ func TestReportWriter_Sarif(t *testing.T) { | |
Message: sarif.Message{Text: lo.ToPtr("Package: foo\nInstalled Version: 1.2.3\nVulnerability CVE-2020-0001\nSeverity: HIGH\nFixed Version: 3.4.5\nLink: [CVE-2020-0001](https://avd.aquasec.com/nvd/cve-2020-0001)")}, | ||
Locations: []*sarif.Location{ | ||
{ | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test: [email protected]")}, | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test 1: [email protected]")}, | ||
PhysicalLocation: &sarif.PhysicalLocation{ | ||
ArtifactLocation: &sarif.ArtifactLocation{ | ||
URI: lo.ToPtr("library/test"), | ||
URI: lo.ToPtr("library/test%201"), | ||
URIBaseId: lo.ToPtr("ROOTPATH"), | ||
}, | ||
Region: &sarif.Region{ | ||
|
@@ -152,10 +152,10 @@ func TestReportWriter_Sarif(t *testing.T) { | |
}, | ||
}, | ||
{ | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test: [email protected]")}, | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test 1: [email protected]")}, | ||
PhysicalLocation: &sarif.PhysicalLocation{ | ||
ArtifactLocation: &sarif.ArtifactLocation{ | ||
URI: lo.ToPtr("library/test"), | ||
URI: lo.ToPtr("library/test%201"), | ||
URIBaseId: lo.ToPtr("ROOTPATH"), | ||
}, | ||
Region: &sarif.Region{ | ||
|
@@ -192,7 +192,7 @@ func TestReportWriter_Sarif(t *testing.T) { | |
input: types.Report{ | ||
Results: types.Results{ | ||
{ | ||
Target: "library/test", | ||
Target: "library/test 1", | ||
Class: types.ClassConfig, | ||
Misconfigurations: []types.DetectedMisconfiguration{ | ||
{ | ||
|
@@ -283,13 +283,13 @@ func TestReportWriter_Sarif(t *testing.T) { | |
RuleID: lo.ToPtr("KSV001"), | ||
RuleIndex: lo.ToPtr[uint](0), | ||
Level: lo.ToPtr("error"), | ||
Message: sarif.Message{Text: lo.ToPtr("Artifact: library/test\nType: \nVulnerability KSV001\nSeverity: HIGH\nMessage: Message\nLink: [KSV001](https://avd.aquasec.com/appshield/ksv001)")}, | ||
Message: sarif.Message{Text: lo.ToPtr("Artifact: library/test 1\nType: \nVulnerability KSV001\nSeverity: HIGH\nMessage: Message\nLink: [KSV001](https://avd.aquasec.com/appshield/ksv001)")}, | ||
Locations: []*sarif.Location{ | ||
{ | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test")}, | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test 1")}, | ||
PhysicalLocation: &sarif.PhysicalLocation{ | ||
ArtifactLocation: &sarif.ArtifactLocation{ | ||
URI: lo.ToPtr("library/test"), | ||
URI: lo.ToPtr("library/test%201"), | ||
URIBaseId: lo.ToPtr("ROOTPATH"), | ||
}, | ||
Region: &sarif.Region{ | ||
|
@@ -306,13 +306,13 @@ func TestReportWriter_Sarif(t *testing.T) { | |
RuleID: lo.ToPtr("KSV002"), | ||
RuleIndex: lo.ToPtr[uint](1), | ||
Level: lo.ToPtr("error"), | ||
Message: sarif.Message{Text: lo.ToPtr("Artifact: library/test\nType: \nVulnerability KSV002\nSeverity: CRITICAL\nMessage: Message\nLink: [KSV002](https://avd.aquasec.com/appshield/ksv002)")}, | ||
Message: sarif.Message{Text: lo.ToPtr("Artifact: library/test 1\nType: \nVulnerability KSV002\nSeverity: CRITICAL\nMessage: Message\nLink: [KSV002](https://avd.aquasec.com/appshield/ksv002)")}, | ||
Locations: []*sarif.Location{ | ||
{ | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test")}, | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test 1")}, | ||
PhysicalLocation: &sarif.PhysicalLocation{ | ||
ArtifactLocation: &sarif.ArtifactLocation{ | ||
URI: lo.ToPtr("library/test"), | ||
URI: lo.ToPtr("library/test%201"), | ||
URIBaseId: lo.ToPtr("ROOTPATH"), | ||
}, | ||
Region: &sarif.Region{ | ||
|
@@ -341,7 +341,7 @@ func TestReportWriter_Sarif(t *testing.T) { | |
input: types.Report{ | ||
Results: types.Results{ | ||
{ | ||
Target: "library/test", | ||
Target: "library/test 1", | ||
Class: types.ClassSecret, | ||
Secrets: []types.DetectedSecret{ | ||
{ | ||
|
@@ -400,13 +400,13 @@ func TestReportWriter_Sarif(t *testing.T) { | |
RuleID: lo.ToPtr("aws-secret-access-key"), | ||
RuleIndex: lo.ToPtr[uint](0), | ||
Level: lo.ToPtr("error"), | ||
Message: sarif.Message{Text: lo.ToPtr("Artifact: library/test\nType: \nSecret AWS Secret Access Key\nSeverity: CRITICAL\nMatch: 'AWS_secret_KEY'=\"****************************************\"")}, | ||
Message: sarif.Message{Text: lo.ToPtr("Artifact: library/test 1\nType: \nSecret AWS Secret Access Key\nSeverity: CRITICAL\nMatch: 'AWS_secret_KEY'=\"****************************************\"")}, | ||
Locations: []*sarif.Location{ | ||
{ | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test")}, | ||
Message: &sarif.Message{Text: lo.ToPtr("library/test 1")}, | ||
PhysicalLocation: &sarif.PhysicalLocation{ | ||
ArtifactLocation: &sarif.ArtifactLocation{ | ||
URI: lo.ToPtr("library/test"), | ||
URI: lo.ToPtr("library/test%201"), | ||
URIBaseId: lo.ToPtr("ROOTPATH"), | ||
}, | ||
Region: &sarif.Region{ | ||
|
@@ -495,7 +495,7 @@ func TestReportWriter_Sarif(t *testing.T) { | |
Message: sarif.NewTextMessage(""), | ||
PhysicalLocation: &sarif.PhysicalLocation{ | ||
ArtifactLocation: &sarif.ArtifactLocation{ | ||
URI: lo.ToPtr("OS Packages"), | ||
URI: lo.ToPtr("OS%20Packages"), | ||
URIBaseId: lo.ToPtr("ROOTPATH"), | ||
}, | ||
Region: &sarif.Region{ | ||
|