feat: add audit-report input for SARIF report generation#14
Merged
Conversation
- Add audit-report input (true for default path, or custom path) - Add audit-report-path output for downstream SARIF upload - Run apm audit -f sarif after install and bundle restore - Emit core.warning() for critical findings and apm-unavailable fallback - Update README with usage example Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an audit-report input to the APM GitHub Action that generates SARIF audit reports via apm audit, with output path exposed for upload to GitHub Code Scanning.
Changes:
- New
audit-reportinput (acceptstrueor custom path) andaudit-report-pathoutput inaction.yml - New
runAuditReport()helper insrc/runner.tsthat runsapm audit -f sarif -o <path>after install/unpack, with graceful handling of exit codes and missing APM - Documentation and tests for the new feature
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| action.yml | Adds audit-report input and audit-report-path output |
| src/runner.ts | Adds audit report path resolution and runAuditReport() helper |
| src/tests/runner.test.ts | 4 new tests covering default path, custom path, critical findings, and no-op |
| dist/index.js | Compiled bundle reflecting source changes |
| README.md | Documents new input/output with Code Scanning usage example |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Write a collapsible markdown summary to $GITHUB_STEP_SUMMARY when audit-report is enabled. The summary is best-effort and wrapped in a <details> section so it stays collapsed in the Actions UI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add core.debug, core.summary, and exec.getExecOutput mocks to runner.test.ts — runAuditReport() uses these and their absence caused 3 test failures (core.debug is not a function). Also add tsconfig.test.json to include test files in TypeScript compilation and suppress ESM-related TS diagnostics in jest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Type jest.fn() for summary.write mock to avoid strict-mode 'never' inference — mockResolvedValue needs explicit return type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to microsoft/apm#329
Adds
audit-reportinput andaudit-report-pathoutput to the APM action, enabling SARIF audit report generation for GitHub Code Scanning integration.Changes
action.ymlaudit-reportinput: set totruefor default path (apm-audit.sarif), or provide a custom file pathaudit-report-pathoutput: path to the generated SARIF reportsrc/runner.tsrunAuditReport()helper that runsapm audit -f sarif -o <path>after install/unpackignoreReturnCode: true— audit exit codes (1=critical, 2=warning) are informational, not action failurescore.warning()for critical findings and when APM is unavailable in restore modeREADME.mdUsage
Depends on
Requires
apm audit --format sarif --outputsupport in apm-cli (microsoft/apm#330).Tests
42 tests passing (4 new: default path resolution, custom path, critical findings warning, no-op when empty).