-
Notifications
You must be signed in to change notification settings - Fork 383
Implement dumping of processed sarif file #3089
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
base: main
Are you sure you want to change the base?
Conversation
2c3bb3f
to
a9b127f
Compare
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.
I have had an initial look over this. It looks like a more involved change than I had hoped -- I was hoping we could just check the environment variable once we have the post-processed SARIF, just before uploading it, and then dump it to a file/folder.
This part of the Action is evolving quite a bit at the moment due to the work on Code Quality and I was planning to make a bunch of changes here in the next few days. They probably wouldn't interact nicely with these changes, though.
I had hoped that as well, but:
|
but in light of the other comments here, it makes sense to make that point to a directory instead |
We could still have |
we already have the |
a9b127f
to
fea2428
Compare
Setting it will cause the SARIF files that would be uploaded to be dumped to the specified directory as `upload.sarif` or `upload.quality.sarif`. Crucially, this happens even if uploads are disabled, which is useful for testing.
fea2428
to
a7fb336
Compare
@mbg I tried a more surgical approach now (I recommend hiding whitespace in the diff view). I did like the fact that I had only one function in the lib processing the sarifs (as opposed to I still had to change the analyze action as well, because of the requirement to dump the SARIF file if requested even if |
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.
Pull Request Overview
This PR implements a new internal testing feature that allows dumping of processed SARIF files to a local directory via the CODEQL_ACTION_SARIF_DUMP_DIR
environment variable. The feature works regardless of whether upload is enabled or disabled, making it useful for testing what gets sent to Code Scanning or Code Quality after SARIF processing.
Key changes:
- Added
CODEQL_ACTION_SARIF_DUMP_DIR
environment variable support for dumping processed SARIF files - Refactored upload functions to conditionally process and upload based on upload kind and dump directory settings
- Modified analyze action to use the new conditional upload mechanism
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/upload-lib.ts | Refactored upload functions to support conditional processing and added SARIF dumping functionality |
src/environment.ts | Added new environment variable for SARIF dump directory |
src/analyze-action.ts | Updated to use conditional upload functions and handle optional upload results |
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.
Thanks for simplifying this, it's really appreciated!
I think there are fundamentally two things going on in this PR:
- Dumping the post-processed SARIF based on the value of the environment variable
- Refactoring
upload-lib
to support this when theupload
input is notalways
Perhaps it would be sensible to split these two aspects up into separate changes:
- One PR which implements the environment variable controlling where the post-processed SARIF is written to, but which will only do this just before uploading (i.e. the simple case we hoped for). Hopefully that is an easy change that we can extract from this PR and quickly review and merge.
- Then we can think about what the best way to refactor
upload-lib
to support this in the case where we wouldn't be uploading the SARIF is. I think that's a change that we want to think about more and, possibly, at the same time as changes I should make in the context of the Code Quality work.
Fair enough, here's the PR 🙂 : |
This introduces a
CODEQL_ACTION_SARIF_DUMP_DIR
environment variable for internal use that causes the processed SARIF file thatcodeql-action
would upload to Code Scanning or Code Quality to be dumped locally. Crucially, this will also happen onanalyze
withupload: never
.This will allow us to test what is actually sent for upload after the SARIF processing that
upload-lib.ts
does (validating, merging, filtering, adding fingerprints etc.).This SARIF file will be dumped in the directory specified by the environment variable, with
upload.sarif
orupload.quality.sarif
as name. There is a risk of naming conflict if an output SARIF file has that name (which depends on the category), but I'm deeming it low risk (and not happening for our testing usage, where the file names are language names).Risk assessment
For internal use only. Please select the risk level of this change:
Merge / deployment checklist