fix: align deno.json audit task with CI invocation#1142
Conversation
The audit task was missing --allow-env=GITHUB_STEP_SUMMARY and --allow-write, causing it to crash in writeGitHubSummary() with NotCapable since PR #484. CI worked around the broken task by invoking scripts/audit_deps.ts inline with the right flags, which hid the bug from anyone not running the task locally. Add the missing flags to match CI's flag set, drop `&& deno outdated` from the task (CI runs deno outdated as a separate failure-tolerant step at ci.yml:98-106 which is unchanged), and route CI's vuln-scan step through `deno task audit` so the deno.json task is the single source of truth and the silent drift can't recur. Resolves swamp-club lab issue #27. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
CI Security Review
Critical / High
None.
Medium
None.
Low
None.
Verdict
PASS — Security-neutral change. The deps-audit job now routes through deno task audit instead of inlining the same command. The Deno permission flags (--allow-read --allow-net=api.osv.dev --allow-env=GITHUB_STEP_SUMMARY --allow-write) are byte-for-byte identical to what CI was already executing at line 96. No new actions, no trigger changes, no expression interpolation, no secret handling changes, no permission escalation. The deno.json task gains --allow-write (unbounded) and --allow-env=GITHUB_STEP_SUMMARY compared to its previous definition, but these match the existing CI flags and the write path is unreachable locally (the script early-returns when GITHUB_STEP_SUMMARY is unset).
There was a problem hiding this comment.
Code Review
Blocking Issues
None.
Suggestions
None — this is a clean, minimal fix. The changes are correct and well-scoped:
- The added
--allow-env=GITHUB_STEP_SUMMARYand--allow-writeflags match whataudit_deps.tsactually requires (line 245:Deno.env.get("GITHUB_STEP_SUMMARY"), line 241:writeGitHubSummarywrites that file) and align with the existingaudit-actionstask pattern. - Routing CI through
deno task auditeliminates the silent drift that hid this bug. - Removing
&& deno outdatedfrom the task is correct since CI already runs it as a separate failure-tolerant step with|| truesemantics.
Summary
The
deno run audittask indeno.jsonhas been silently broken since PR #484: it lacks--allow-env=GITHUB_STEP_SUMMARYand--allow-write, butscripts/audit_deps.ts:245callsDeno.env.get("GITHUB_STEP_SUMMARY")andwriteGitHubSummary()later writes that file. The task crashes withNotCapableafter every successful scan, returning a non-zero exit code locally.CI never noticed because
.github/workflows/ci.yml:96invokedscripts/audit_deps.tsdirectly with the correct flags, bypassing the task entirely.This PR:
--allow-env=GITHUB_STEP_SUMMARYand--allow-writeto theaudittask indeno.jsonso it matches CI's flag set byte-for-byte. The script'swriteGitHubSummaryearly-returns whenGITHUB_STEP_SUMMARYis unset, so the local dev experience is unchanged — the grant only matters in CI where the var is set.&& deno outdatedfrom the task. CI's vuln-scan invocation never included it, and CI runsdeno outdatedas its own failure-tolerant step (ci.yml:98-106) with|| truewarning semantics that would be lost if folded into the task's&&chain. That separate CI step is left intact. In practice no developer ever sawdeno outdatedrun viadeno run auditbecause the task always crashed first.deno task auditso thedeno.jsontask is the single source of truth. This eliminates the silent drift that hid this bug for ~30 PRs and matches the existingdeno task check/deno task test/deno task compilepattern used elsewhere inci.yml.Notes
scripts/audit_deps.ts,deno.json:15) shows the task body has been unchanged since017139c4(PR feat: add dependency auditing CI gate with OSV-Scanner #484), introduced together with the script that requires the env access. The task never worked locally; the bug was masked by CI bypassing it.--allow-writegrant on the local task is a deliberate trade-off for CI parity. Locally,GITHUB_STEP_SUMMARYis never set, sowriteGitHubSummary()returns ataudit_deps.ts:246before any write — the grant covers an unreachable code path.Test plan
deno run auditfrom the repo root — exits 0, "No known vulnerabilities found"deno fmt --check— cleandeno check— clean (1117 files)deno lint— clean (1011 files)deno task auditproduces the same output as the previous inline command, since they're byte-for-byte the same command line)🤖 Generated with Claude Code