Skip to content

Commit b63250e

Browse files
allow handling sarif files with schema from main branch (#594)
Every now then the sarif schema urls change in generated Sarif files by different tools. Most often, these changes are to paths or branch names and don't actually change anything about the schema itself. This change makes the CLI accept any schema from the main branch in the oasis-tcs repo.
1 parent cbac4a1 commit b63250e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

internal/snyk/sarif-code.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
2+
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
33
"version": "2.1.0",
44
"runs": [
55
{

internal/snyk/snyk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func ProcessSnykResultFile(file string) (*SnykData, error) {
4747
if err != nil {
4848
return nil, err
4949
}
50-
if !strings.HasPrefix(report.Schema, "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-") && !strings.HasPrefix(report.Schema, "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json") {
50+
if !strings.HasPrefix(report.Schema, "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/") && !strings.HasPrefix(report.Schema, "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-") && !strings.HasPrefix(report.Schema, "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json") {
5151
return nil, fmt.Errorf("invalid sarif file")
5252
}
5353
data := &SnykData{

0 commit comments

Comments
 (0)