-
Notifications
You must be signed in to change notification settings - Fork 391
Find, then filter, SARIF files for upload-sarif
Action
#3167
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
6b42eb8
to
2ba3c8b
Compare
Since `fixCategory` is now part of `AnalysisConfig`, we don't have to remember to do it at the call site for `uploadSpecifiedFiles` or `uploadFiles` anymore.
…ths` that don't belong to an analysis kind
2ba3c8b
to
93711d3
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.
Pull Request Overview
This PR refactors the upload-sarif
Action's approach by introducing a "find, then filter" strategy that simplifies the implementation while maintaining backward compatibility.
- Replaces the complex
findAndUpload
function with a newgetGroupedSarifFilePaths
function that finds all SARIF files first, then categorizes them by analysis type - Streamlines the upload logic by processing grouped SARIF files in a single loop
- Moves category fixing logic into the analysis configuration objects for better organization
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/util.ts |
Adds typed helper functions for Object.keys and Object.entries |
src/upload-sarif.ts |
Refactors main upload logic to use new grouping approach, removes findAndUpload function |
src/upload-sarif.test.ts |
Updates tests to reflect new API structure and removes findAndUpload tests |
src/upload-lib.ts |
Implements new getGroupedSarifFilePaths function and moves category fixing to uploadSpecifiedFiles |
src/upload-lib.test.ts |
Adds comprehensive tests for the new grouping functionality |
src/analyze.ts |
Updates to use analysis-specific category fixing method |
src/analyze-action.ts |
Simplifies quality upload by removing duplicate category fixing |
src/analyses.ts |
Adds fixCategory method to analysis configs and introduces helper functions |
Generated JS files | Compiled output reflecting TypeScript changes |
} else { | ||
for (const analysisConfig of analyses.SarifScanOrder) { | ||
if ( | ||
analysisConfig.kind === analyses.AnalysisKind.CodeScanning || |
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.
The hardcoded check for CodeScanning
analysis kind breaks the abstraction pattern. Consider adding a isDefaultAnalysis
property to the analysis configuration or restructuring the logic to avoid special-casing specific analysis types.
analysisConfig.kind === analyses.AnalysisKind.CodeScanning || | |
analysisConfig.isDefaultAnalysis || |
Copilot uses AI. Check for mistakes.
This PR changes the approach used by
upload-sarif
to simplify the complexity of the implementation:Instead of using
findAndUpload
, which finds files relevant to an analysis and uploads them, for Code Scanning and Code Quality in turn, the implementation in this PR is based around a newgetGroupedSarifFilePaths
function which:.sarif
files.We then loop through the results of
getGroupedSarifFilePaths
and upload the SARIF files to the respective endpoint.Risk assessment
For internal use only. Please select the risk level of this change:
Merge / deployment checklist