-
Notifications
You must be signed in to change notification settings - Fork 8
Add action to export code scanning alert to a SARIF file #11
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
Add action to export code scanning alert to a SARIF file #11
Conversation
a93259b
to
00d75bc
Compare
Should the |
The |
SGTM |
Can you point to a run where you're testing this? I tried with winkerberos and it doesn't seem to be finding the ref I just uploaded. blink1073/winkerberos#26 |
I'm seeing similar behavior. It seems like, even though the repo has dismissed codeql alerts, the alerts are not returned by the github API. Example when I specify (I I'm going to test further tomorrow on a fork, I think it may work if I grab all codeql alerts for a given release tag instead of the current PR. Update: Grabbing alerts for a tag did not work. I'm going to instead grab alerts for the target release branch, since in Node's workflow we'll have already run CodeQL scans on each commit to the target branch. |
Co-authored-by: Bailey Pearson <[email protected]>
Working great for BSON: mongodb/js-bson#695 (also tested with the driver, and non-empty reports are generated for branches where we have dismissed codeql alerts) |
Great! I'll give it a try with Winkerberos tomorrow |
I'm still getting an empty sarif file on publish, will have to do some more debugging on a fork of this branch. |
It works with pymongo! I just pushed a commit that should fix CI, and made the logs print at info level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks for testing and fixing issues, @blink1073! Did you get it to work for a tag ref as well or only for a branch ref? |
I didn't try tag, I think using the branch ref makes more sense unless we explicitly wait on the scan result for the tag. |
Thanks for adding that last part - I may have just found out why it didn't work for y'all. The project I'm testing this with uploads a SARIF report to code scanning using the |
I think we can merge and iterate at this point, I'll attempt to run from a tag once mongodb/mongo-python-driver#1651 is merged. |
@baileympearson I've left the branch in my fork in place since you seem to be using it in js-bson. Let me know when you've changed that to |
The new code-scanning-export action allows exporting open and dismissed code scanning alert to a SARIF file, which we can then submit as a release artifact. The action makes a best effort to fill in tool information along with the rules, and adds
suppression
elements to all dismissed alerts.To test this action, you can use the following two steps in a GitHub Actions job:
In my case, I ran the steps directly after uploading the SARIF file from an external tool. Note that the tool can only produce results if analysis of the code scanning report has completed (which is the default when uploading a SARIF file to Code Scanning). In case of using CodeQL in GitHub Actions, add the two steps after running the
github/codeql-action/analyze
action.If the artifact is successfully uploaded, you can use a validator (e.g. Microsoft's SARIF Validator) to validate that the file is valid. If the action failed or if the generated SARIF report is invalid, please report back so we can add the responsible alert to our test suite.
Note that in my case the validator complained about the tool not having a
informationUri
property. This is not exposed in our alerts, but it may be in yours in which case we can add it to the report.TODOs:
npm run lint
currently reports errors (see CI pipeline)