feat: persist redacted resolved config as audit artifact#4719
Conversation
|
@copilot fix this failing ci check https://github.com/github/gh-aw-firewall/actions/runs/27313022132/job/80687323683?pr=4719 |
There was a problem hiding this comment.
Pull request overview
Adds a persisted, redacted “resolved config” snapshot so AWF runs can be audited after completion without relying on debug logs, by writing a JSON artifact during startup and covering it with unit tests.
Changes:
- Write
awf-resolved-config.jsoncontaining the redacted resolved config early increateMainAction(). - Add unit tests to verify the artifact is written to
auditDirwhen set, and otherwise written to the fallback directory.
Show a summary per file
| File | Description |
|---|---|
src/commands/main-action.ts |
Writes a redacted resolved-config JSON file at startup. |
src/commands/main-action.test.ts |
Adds tests asserting the resolved-config artifact is written to the expected location. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 4
| // Persist redacted config to audit artifact for post-run diagnostics | ||
| try { | ||
| const configArtifactDir = config.auditDir || config.workDir; | ||
| fs.mkdirSync(configArtifactDir, { recursive: true }); | ||
| fs.writeFileSync( | ||
| path.join(configArtifactDir, 'awf-resolved-config.json'), | ||
| JSON.stringify(redactedConfig, null, 2) + '\n', | ||
| { mode: 0o600 }, | ||
| ); | ||
| } catch { /* best-effort — never block startup */ } |
| }); | ||
| }); | ||
|
|
||
| describe('resolved config artifact', () => { |
| const configWithAudit = { | ||
| ...STUB_CONFIG, | ||
| auditDir: '/tmp/awf-audit', | ||
| }; | ||
| mockedValidateOptions.validateOptions.mockReturnValue( | ||
| configWithAudit as unknown as import('../types').WrapperConfig | ||
| ); | ||
| const action = createMainAction(getOptionValueSource); | ||
| await action(['echo hi'], {}); | ||
|
|
||
| expect(mkdirSyncSpy).toHaveBeenCalledWith('/tmp/awf-audit', { recursive: true }); | ||
| expect(writeFileSyncSpy).toHaveBeenCalledWith( | ||
| '/tmp/awf-audit/awf-resolved-config.json', | ||
| expect.stringContaining('"allowedDomains"'), | ||
| { mode: 0o600 }, | ||
| ); | ||
| // Verify secrets are not in the artifact | ||
| const written = writeFileSyncSpy.mock.calls.find( | ||
| (c) => String(c[0]).includes('awf-resolved-config.json') | ||
| ); | ||
| expect(written).toBeDefined(); | ||
| expect(String(written![1])).not.toContain('ApiKey'); | ||
|
|
| expect(writeFileSyncSpy).toHaveBeenCalledWith( | ||
| '/tmp/awf-test/awf-resolved-config.json', | ||
| expect.any(String), | ||
| { mode: 0o600 }, | ||
| ); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Fixed in the latest commit. The CI failure was caused by two Also addressed the other review feedback in the same commit:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Fixed in the latest commit. The CI was running against the original commit — the previous fix didn't persist across sessions. Re-applied all changes: replaced |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Smoke Test: Copilot BYOK (Direct) Mode — PASS ✅
Mode: Direct BYOK (
|
🤖 Copilot Smoke Test — PASS
Overall: PASS PR by @lpcox — no assignees.
|
|
Merged PRs:
Checks:
Overall: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🔥 Smoke Test Results — PAT Auth
Overall: PASS 🎉 PR: feat: persist redacted resolved config as audit artifact by @lpcox
|
|
PR: feat: persist redacted resolved config as audit artifact ✅ GitHub MCP connectivity Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) Overall: PASS
|
|
feat: persist redacted resolved config as audit artifact: ✅ Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "api.openai.com"See Network Configuration for more information.
|
Chroot Version Comparison Results
Result: Not all tests passed. Python and Node.js versions differ between host and chroot environments. Go versions match.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
|
GitHub API: ✅ PASS Total: PASS
|
Problem
The full resolved AWF configuration (CLI flags, domain allowlists, network topology, feature flags) is only logged at
--log-level debugto stderr. After a run completes, there's no persistent artifact to recover what options AWF was invoked with — you have to parse GitHub Actions step logs and hope debug was enabled.Solution
Write
awf-resolved-config.jsonto the audit dir (or workDir) at startup, before containers launch. This file contains the complete resolved config with:Security: API keys are fully excluded (same redaction as debug log). The agent command has inline secrets redacted. File is written mode 0600.
Usage
Testing