-
Notifications
You must be signed in to change notification settings - Fork 30
Fix SARIF validation errors for GitHub CodeQL upload #384
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
Conversation
- Set index property on ToolComponentReference to 0 (pointing to first taxonomy) - Set guid property to avoid null serialization - Initialize Rules field in ToolComponent as empty array instead of null - Add comprehensive test case to validate SARIF structure Co-authored-by: fproulx-boostsecurity <76956526+fproulx-boostsecurity@users.noreply.github.com>
|
@copilot explicitely add a test case to confirms that what was reported in issue #384 is fixed (create a test fixture with the exact YAML given by the reporter) i.e. |
- Replace require.Equal with require.InDelta for float comparison to fix testifylint error - Add test fixture with exact YAML from issue #384 - Add comprehensive test case TestSarifFormatIssue384 to validate the fix Co-authored-by: fproulx-boostsecurity <76956526+fproulx-boostsecurity@users.noreply.github.com>
Added test fixture with the exact YAML from issue #384 at |
|
@copilot you added |
- Modified TestSarifFormatIssue384 to use InventoryScanner to scan the testdata directory - Test now parses the actual workflow file and runs OPA analysis to generate findings - Added imports for scanner and opa packages - Test validates that issue-384.yml workflow is found and scanned - SARIF output is generated from real scan results instead of mock data Co-authored-by: fproulx-boostsecurity <76956526+fproulx-boostsecurity@users.noreply.github.com>
You were correct - the test was only referencing the file path in mock data. Updated TestSarifFormatIssue384 to actually scan the testdata directory using InventoryScanner and run OPA analysis on the real workflow file. The test now verifies that issue-384.yml is found, parsed, analyzed, and the SARIF output is generated from actual scan results. Commit: 8fe5538 |
indexproperty onToolComponentReferenceto point to the taxonomy array position (0)Rulesfield inToolComponentas an empty array instead of nullguidfield to avoid null serializationSummary
Fixed the SARIF validation errors by making minimal changes to
formatters/sarif/sarif.go:indexto 0 onToolComponentReference(points to first taxonomy)guidto a valid UUID to avoid null serializationRulesfield as empty array[]Added comprehensive tests including:
Original prompt
This section details on the original issue you should resolve
<issue_title>Error: Unable to upload "results.sarif" as it is not valid SARIF</issue_title>
<issue_description>Describe the bug
When the GitHub Action job reaches the SARIF upload step, the SARIF upload fails.
Error: Unable to upload "results.sarif" as it is not valid SARIF:
To Reproduce
Here is our job YAML. Notice we run on a https://runs-on.com/ GitHub runner, on Ubuntu 24.04.
Expected behavior
Uploading a SARIF normally works.
Screenshots