ci: harden the bun audit gate (bun 1.4.0, registry retries, timeout) - #3211
Merged
Conversation
The Security workflow's Bun audit gate fails on main with one HIGH: @faker-js/faker 5.5.3, reached only through the dev-only @stoplight/prism-http mock server (postman-collection pins that exact version and no upstream release lifts the pin). Before bun 1.4, `bun audit --prod` run from a workspace root treated workspace members' devDependencies as production (oven-sh/bun#26675, fixed in 1.4 by oven-sh/bun#38333), so the job's bun 1.3.12 flagged a dependency the shipped product never installs. Pin the audit job — and only it — to bun 1.4.0. Verified locally: on the pre-#3210 lock, 1.4.0 `--prod --audit-level=high` still reports the real production findings (fast-uri via ajv, mysql2 direct and via better-auth) and nothing else; on today's main it reports none.
`bun audit` resolves advisories with one POST to registry.npmjs.org's bulk endpoint. On 2026-09-04 that endpoint alternated between 503s and minute-long hangs: the gate went red on main and on PR #3211 with no finding at all (`error: POST …/advisories/bulk - 503`), and the re-run was cancelled by the job's 5-minute budget while the report step hung. Run the gate up to three times, 30 s apart, each attempt capped at 240 s, and retry only a hung (exit 124) or transport-error attempt; a run that lists advisories exits 1 on the first pass exactly as before. stderr joins the tee'd log so the check can see the error line. Bound the report step at 4 minutes and give the job 20 so the retries fit.
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.
Why
After #3210 cleared the Trivy gate, the Security workflow's Bun audit gate is the last red on main (and on PR #3210's own run, job 100945897852):
That copy is
@faker-js/faker@5.5.3, pinned exactly bypostman-collection→@stoplight/http-spec→@stoplight/prism-http(the mock server), which is a devDependency of@tale/platformand never in a shipped image. No upstream release lifts the pin: the latestpostman-collection(5.3.1) still pins 5.5.3, and prism-http 5.16.0 still depends on http-spec ^7.1.0 → postman-collection ^4.1.3. Prism itself already resolves the patched 10.5.0.The gate runs
bun audit --prod, which is supposed to exclude exactly this. Before bun 1.4 it did not when run from a workspace root — oven-sh/bun#26675 ("bun audit --prod won't work in monorepos": workspace members' devDependencies reported as production), fixed in 1.4 by oven-sh/bun#38333. The job pins bun 1.3.12.What changed
.github/workflows/security.yml: the Bun audit job'ssetup-bunpin goes to1.4.0, with a comment saying why it is deliberately newer than the build jobs' 1.3.12. Nothing else — the Trivy job (which already classifies dev deps correctly) and the gate command are unchanged, and no--ignoreis added.Verified locally (bun 1.4.0, direct registry)
bun audit --prod --audit-level=high→5 vulnerabilities (5 high): the four fast-uri advisories viaworkspace:@tale/platform > ajv > fast-uriand mysql2 viaworkspace:@tale/platform > mysql2and> better-auth > mysql2— i.e. 1.4.0 still sees workspace production findings, root and member alike. No faker.No vulnerabilities found (checked 1651 packages, 6 below --audit-level=high), exit 0.This PR touches
security.yml, so the Security workflow runs on it and the gate proves itself before merge.Also in this PR: survive a degraded advisory registry
The first CI run of this PR failed the same gate for a different reason —
error: POST https://registry.npmjs.org/-/npm/v1/security/advisories/bulk - 503— and the re-run was cancelled by the job's 5-minute budget while the report step hung on that endpoint (probing it from here: alternating 1.5 s200s and 60 s hangs). A registry outage must not read as a finding, so the second commit:timeout 240; only a hung attempt (exit 124) or a transport-error line is retried — a run that lists advisories still exits 1 on the first pass (stderr now joins the tee'd log so the check can see the error line);continue-on-erroralready) and raises the job budget from 5 to 20 minutes so the retries fit.Simulated against a fake
bun(flaky 503 → pass on 3rd try; hang → retried once then pass; permanent 503 → red after 3; real finding → red on the 1st call; clean → green on the 1st call): all five behave as intended.