fix: sanitize level property for SARIF (#4831)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
parent
9211eeccf7
commit
304e22a024
@ -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"
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user