gosec/output/sonarqube_format.go

44 lines
1.1 KiB
Go
Raw Normal View History

2019-03-11 20:13:48 +00:00
package output
import "github.com/securego/gosec/v2"
2019-03-11 20:13:48 +00:00
type textRange struct {
StartLine int `json:"startLine"`
EndLine int `json:"endLine"`
StartColumn int `json:"startColumn,omitempty"`
EtartColumn int `json:"endColumn,omitempty"`
}
type location struct {
Message string `json:"message"`
FilePath string `json:"filePath"`
TextRange textRange `json:"textRange,omitempty"`
}
type sonarIssue struct {
2019-03-11 20:16:30 +00:00
EngineID string `json:"engineId"`
RuleID string `json:"ruleId"`
Cwe gosec.Cwe `json:"cwe"`
2019-03-11 20:13:48 +00:00
PrimaryLocation location `json:"primaryLocation"`
Type string `json:"type"`
Severity string `json:"severity"`
EffortMinutes int `json:"effortMinutes"`
SecondaryLocations []location `json:"secondaryLocations,omitempty"`
}
2019-03-11 21:32:32 +00:00
type sonarIssues struct {
SonarIssues []sonarIssue `json:"issues"`
}
2019-03-11 20:13:48 +00:00
func getSonarSeverity(s string) string {
switch s {
case "LOW":
return "MINOR"
case "MEDIUM":
return "MAJOR"
case "HIGH":
return "BLOCKER"
default:
return "INFO"
}
}