Skip to content

Commit

Permalink
Update SarifReporter.py
Browse files Browse the repository at this point in the history
GitHub's SARIF validator doesn't like it when there is no `results` list associated with a run; therefore, it a `results` key doesn't exist, create one with an empty list.

resolves oxsecurity#1725
  • Loading branch information
wesley-dean-flexion authored Aug 9, 2022
1 parent 94543e5 commit 233dbe8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion megalinter/reporters/SarifReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ def fix_sarif(self, linter_sarif_obj, linter: Linter):
)
result["locations"][id_location] = location
run["results"][id_result] = result

else:
# make sure that there is a results entry so GitHub's SARIF validator doesn't cry
run["results"] = []

# Update run in full list
linter_sarif_obj["runs"][id_run] = run
return linter_sarif_obj
Expand Down

0 comments on commit 233dbe8

Please sign in to comment.