-
Notifications
You must be signed in to change notification settings - Fork 10
Update sarif tests #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update sarif tests #124
Changes from 1 commit
43a3283
e229684
95a3c55
2910120
44dcfbc
3d468b3
df2ff76
5687163
99059bd
b746ef3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| runtimes: | ||
| - node@22.2.0 | ||
| - python@3.11.11 | ||
| - java@17.0.10 | ||
| tools: | ||
| - eslint@8.57.0 | ||
| - trivy@0.59.1 | ||
| - pylint@3.3.6 | ||
| - pmd@6.55.0 | ||
| - semgrep@1.78.0 | ||
| - lizard@1.17.19 | ||
| - lizard@1.17.19 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,14 +204,8 @@ func MergeSarifOutputs(inputFiles []string, outputFile string) error { | |
| return fmt.Errorf("failed to read SARIF file %s: %w", file, err) | ||
| } | ||
|
|
||
| // Filter out rule definitions from each input file | ||
| filteredData, err := FilterRuleDefinitions(data) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to filter rules from SARIF file %s: %w", file, err) | ||
| } | ||
|
|
||
| var sarif SimpleSarifReport | ||
| if err := json.Unmarshal(filteredData, &sarif); err != nil { | ||
| if err := json.Unmarshal(data, &sarif); err != nil { | ||
| return fmt.Errorf("failed to parse SARIF file %s: %w", file, err) | ||
| } | ||
|
|
||
|
|
@@ -234,16 +228,26 @@ func MergeSarifOutputs(inputFiles []string, outputFile string) error { | |
| return nil | ||
| } | ||
|
|
||
| // FilterRuleDefinitions removes rule definitions from SARIF output | ||
| func FilterRuleDefinitions(sarifData []byte) ([]byte, error) { | ||
| var report SarifReport | ||
| // FilterRulesFromSarif removes rule definitions from SARIF output if needed | ||
| // This should be called separately after MergeSarifOutputs if rule filtering is required | ||
| func FilterRulesFromSarif(sarifData []byte) ([]byte, error) { | ||
| // Use a map to preserve all fields during unmarshaling | ||
| var report map[string]interface{} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it was ok work on the parsed (structure) version
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these change are due to previously disappeared fields in serifs
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what I mean is that this version, it has this longer implementation, but doing exactly same thing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reverted to your versions, but there are now missing fields in the actual sarif that we used have, especially visible in eslint failure 🤔 |
||
| if err := json.Unmarshal(sarifData, &report); err != nil { | ||
| return nil, fmt.Errorf("failed to parse SARIF data: %w", err) | ||
| } | ||
|
|
||
| // Remove rules from each run | ||
| for i := range report.Runs { | ||
| report.Runs[i].Tool.Driver.Rules = nil | ||
| // Navigate to the runs array and remove rules from each run | ||
| if runs, ok := report["runs"].([]interface{}); ok { | ||
| for _, run := range runs { | ||
| if runMap, ok := run.(map[string]interface{}); ok { | ||
| if tool, ok := runMap["tool"].(map[string]interface{}); ok { | ||
| if driver, ok := tool["driver"].(map[string]interface{}); ok { | ||
| driver["rules"] = nil | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Marshal back to JSON with indentation | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.