Skip to content

Commit 9866be4

Browse files
committed
update sarif to be lowercase
Signed-off-by: pxp928 <[email protected]>
1 parent 707725f commit 9866be4

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

kusari/cmd/repo_scan.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
func init() {
2121
scancmd.Flags().StringVarP(&platformUrl, "platform-url", "", "https://platform.api.us.kusari.cloud/", "platform url")
2222
scancmd.Flags().BoolVarP(&wait, "wait", "w", true, "wait for results")
23-
scancmd.Flags().StringVarP(&outputFormat, "output-format", "", "markdown", "output format (markdown or SARIF)")
23+
scancmd.Flags().StringVarP(&outputFormat, "output-format", "", "markdown", "output format (markdown or sarif)")
2424

2525
// Bind flags to viper
2626
mustBindPFlag("platform-url", scancmd.Flags().Lookup("platform-url"))
@@ -33,8 +33,8 @@ func scan() *cobra.Command {
3333
cmd.SilenceUsage = true
3434

3535
// Validate output format
36-
if outputFormat != "markdown" && outputFormat != "SARIF" {
37-
return fmt.Errorf("invalid output format: %s (must be 'markdown' or 'SARIF')", outputFormat)
36+
if outputFormat != "markdown" && outputFormat != "sarif" {
37+
return fmt.Errorf("invalid output format: %s (must be 'markdown' or 'sarif')", outputFormat)
3838
}
3939

4040
dir := args[0]

pkg/repo/scanner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ func queryForResult(platformUrl string, epoch *string, accessToken string, conso
267267
s.Stop()
268268

269269
// Check output format
270-
if outputFormat == "SARIF" {
271-
// Output SARIF format
270+
if outputFormat == "sarif" {
271+
// Output sarif format
272272
sarifOutput, err := sarif.ConvertToSARIF(results[0].Analysis.RawLLMAnalysis)
273273
if err != nil {
274274
return fmt.Errorf("failed to convert to SARIF: %w", err)

pkg/sarif/sarif.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ type SarifRule struct {
3535
ShortDescription SarifMultiformatMessageString `json:"shortDescription,omitempty"`
3636
FullDescription SarifMultiformatMessageString `json:"fullDescription,omitempty"`
3737
Help SarifMultiformatMessageString `json:"help,omitempty"`
38-
Properties map[string]interface{} `json:"properties,omitempty"`
38+
Properties map[string]any `json:"properties,omitempty"`
3939
}
4040

4141
type SarifResult struct {
42-
RuleID string `json:"ruleId"`
43-
Level string `json:"level,omitempty"` // "error", "warning", "note", "none"
44-
Message SarifMessage `json:"message"`
45-
Locations []SarifLocation `json:"locations,omitempty"`
46-
Properties map[string]interface{} `json:"properties,omitempty"`
42+
RuleID string `json:"ruleId"`
43+
Level string `json:"level,omitempty"` // "error", "warning", "note", "none"
44+
Message SarifMessage `json:"message"`
45+
Locations []SarifLocation `json:"locations,omitempty"`
46+
Properties map[string]any `json:"properties,omitempty"`
4747
}
4848

4949
type SarifMessage struct {
@@ -178,7 +178,8 @@ func ConvertToSARIF(analysis *api.SecurityAnalysis) (string, error) {
178178
},
179179
},
180180
},
181-
Properties: map[string]interface{}{
181+
Properties: map[string]any{
182+
"type": "code",
182183
"line_number": mitigation.LineNumber,
183184
},
184185
}
@@ -193,7 +194,7 @@ func ConvertToSARIF(analysis *api.SecurityAnalysis) (string, error) {
193194
Message: SarifMessage{
194195
Text: mitigation.Content,
195196
},
196-
Properties: map[string]interface{}{
197+
Properties: map[string]any{
197198
"type": "dependency",
198199
},
199200
}
@@ -203,7 +204,7 @@ func ConvertToSARIF(analysis *api.SecurityAnalysis) (string, error) {
203204
// Convert to JSON
204205
jsonBytes, err := json.MarshalIndent(sarifLog, "", " ")
205206
if err != nil {
206-
return "", fmt.Errorf("failed to marshal SARIF: %w", err)
207+
return "", fmt.Errorf("failed to marshal sarif: %w", err)
207208
}
208209

209210
return string(jsonBytes), nil

0 commit comments

Comments
 (0)