Fix zizmor output: suppress 0 warnings, show details with location, run per-file#2663
Conversation
- Skip displaying "🌈 zizmor 0 warnings" for files with 0 warnings - Display detailed findings (severity and type) for each warning - Run zizmor per-file as each workflow compiles instead of all at the end - Update tests to match new behavior Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot you need to show the file, line, column and error description for zizmor errors. |
Updated TestCompileWithZizmor to handle the new behavior where workflows with 0 warnings don't display any zizmor output. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated zizmorFinding struct to capture desc, url, annotation, and location info - Modified display logic to show line number, column number, and description - Used console.FormatErrorMessage for consistent error formatting - Updated all tests with enhanced JSON structure and expected output - Line/column numbers are displayed in 1-based indexing for user readability Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added detailed zizmor output showing file, line, column, and error description. The output now displays: Changes in commit f88d0d4:
|
|
Agentic Changeset Generator triggered by this pull request. |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the zizmor security scanner integration to improve output clarity and execution timing. The changes suppress zero-warning messages, add detailed diagnostic information including location and severity, and execute zizmor per-file during compilation rather than in batch afterward.
Key changes:
- Suppresses "0 warnings" output for clean workflows
- Displays detailed findings with severity, type, line/column location, and descriptions
- Executes zizmor per-file during compilation instead of batch execution at the end
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/zizmor.go | Enhanced zizmorFinding struct with location/description fields; refactored to runZizmorOnFile() for single-file scanning; updated output formatting to skip zero warnings and show detailed diagnostics |
| pkg/cli/compile_command.go | Integrated per-file zizmor execution into validation functions; removed batch execution code blocks |
| pkg/cli/zizmor_test.go | Updated test fixtures with complete zizmor JSON structure and verified new output format |
| pkg/cli/compile_integration_test.go | Updated test to accept silent output for workflows with no findings |
| pkg/cli/add_command.go | Updated function calls to match new signature with zizmor parameters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| row := loc.Concrete.Location.StartPoint.Row | ||
| col := loc.Concrete.Location.StartPoint.Column | ||
| // Zizmor uses 0-based indexing, convert to 1-based for user display | ||
| if row > 0 || col > 0 { |
There was a problem hiding this comment.
The condition row > 0 || col > 0 will incorrectly omit location info when both row and column are 0, which is a valid location (first line, first column). The condition should be row >= 0 && col >= 0 or simply always format the location since negative values should not occur in valid zizmor output.
| if row > 0 || col > 0 { | |
| if row >= 0 && col >= 0 { |
|
|
||
| compileLog.Printf("Starting compilation of %s", resolvedFile) | ||
| if err := CompileWorkflowDataWithValidation(compiler, workflowData, resolvedFile, verbose); err != nil { | ||
| if err := CompileWorkflowDataWithValidation(compiler, workflowData, resolvedFile, verbose, zizmor && !noEmit, strict); err != nil { |
There was a problem hiding this comment.
[nitpick] The expression zizmor && !noEmit is duplicated in multiple calls (lines 252, 393). Consider extracting this into a named boolean variable like runZizmor := zizmor && !noEmit at the function start to improve readability and reduce duplication.
Zizmor security scanner output was cluttered with "0 warnings" messages, lacked diagnostic details, and ran in batch at the end of compilation instead of per-file.
Changes
runZizmorOnFile()functionrunZizmor()and end-of-compilation scanning codeconsole.FormatErrorMessage()for consistent error display with ✗ symbolImplementation
pkg/cli/zizmor.go
zizmorFindingstruct to capturedesc,url,annotation, and location data (start_pointwith row/column)parseAndDisplayZizmorOutput()to skipcount == 0, extract location info, and display detailed findings with line/column numbers (1-based indexing) and descriptionsrunZizmorOnFile()for single-file scanning with Docker volume mount to git rootconsole.FormatErrorMessage()for consistent error formattingpkg/cli/compile_command.go
runZizmorPerFileandstrictparameters to validation functionsCompileWorkflowWithValidation()andCompileWorkflowDataWithValidation()pkg/cli/zizmor_test.go
desc,url, and location informationpkg/cli/compile_integration_test.go
TestCompileWithZizmorto accept silent output for clean workflowsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.