Skip to content

Commit 9cf9cc0

Browse files
improve sarif
1 parent 14658d7 commit 9cf9cc0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

cmd/analyze.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ var analyzeCmd = &cobra.Command{
250250

251251
log.Println("Running all configured tools...")
252252

253-
if outputFormat == "sarif" {
253+
if outputFormat == "sarif" && outputFile != "" {
254254
// Create temporary directory for individual tool outputs
255255
tmpDir, err := os.MkdirTemp("", "codacy-analysis-*")
256256
if err != nil {

utils/sarif.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,18 @@ type Driver struct {
4343
}
4444

4545
type Rule struct {
46-
ID string `json:"id"`
47-
ShortDescription MessageText `json:"shortDescription"`
48-
Properties map[string]interface{} `json:"properties"`
46+
ID string `json:"id"`
47+
ShortDescription MessageText `json:"shortDescription"`
48+
Properties RuleProperties `json:"properties"`
49+
}
50+
51+
type RuleProperties struct {
52+
Priority int `json:"priority,omitempty"`
53+
Ruleset string `json:"ruleset,omitempty"`
54+
Tags []string `json:"tags,omitempty"`
55+
// Add other common properties that might be present
56+
Precision string `json:"precision,omitempty"`
57+
SecuritySeverity string `json:"security-severity,omitempty"`
4958
}
5059

5160
type Result struct {

0 commit comments

Comments
 (0)