Fix for Issue #1482 - SARIF artifactChanges null validation error#1483
Merged
ccojocar merged 1 commit intosecurego:masterfrom Jan 25, 2026
Merged
Conversation
Only create Fix object when autofix is non-empty to avoid null artifactChanges. Fixes securego#1482.
Contributor
Author
|
@ccojocar Please take a look at this PR when you get a chance. Folks have been waiting to get a release instead of doing some workarounds. It would be a nice for gosec adoption in the community. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1483 +/- ##
==========================================
+ Coverage 68.49% 69.23% +0.73%
==========================================
Files 75 83 +8
Lines 4384 6663 +2279
==========================================
+ Hits 3003 4613 +1610
- Misses 1233 1825 +592
- Partials 148 225 +77 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ccojocar
approved these changes
Jan 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Only create Fix object when autofix is non-empty to avoid null artifactChanges. Fixes #1482.
Problem
GitHub's CodeQL upload-sarif action was rejecting SARIF files generated by gosec with the error:
Root Cause: The
Fixobject was being created unconditionally, even whenautofixwas empty. This resulted inArtifactChangesbeingnullin the JSON output, which violates the SARIF 2.1.0 schema requirement thatartifactChangesmust be a non-empty array when present.Solution
Only create the
Fixobject whenautofixcontent is non-empty. This ensures:fixesfield when there's no fix suggestion (schema-compliant)artifactChangesarray when fix exists (schema-compliant)Tests