Skip to content

Commit

Permalink
fix: sanitize level property for SARIF (#4831)
Browse files Browse the repository at this point in the history
Co-authored-by: Fernandez Ludovic <[email protected]>
  • Loading branch information
Zxilly and ldez committed Jun 19, 2024
1 parent 9211eec commit 304e22a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/printers/sarif.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ func (p Sarif) Print(issues []result.Issue) error {
issue := issues[i]

severity := issue.Severity
if severity == "" {

switch severity {
// https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/sarif-v2.1.0-errata01-os-complete.html#_Toc141790898
case "none", "note", "warning", "error":
// Valid levels.
default:
severity = "error"
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/printers/sarif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestSarif_Print(t *testing.T) {
},
{
FromLinter: "linter-a",
Severity: "error",
Severity: "low",
Text: "some issue 2",
Pos: token.Position{
Filename: "path/to/filec.go",
Expand Down

0 comments on commit 304e22a

Please sign in to comment.