Skip to content

ci: harden the bun audit gate (bun 1.4.0, registry retries, timeout) - #3211

Merged
larryro merged 2 commits into
mainfrom
ci/bun-audit-1-4
Sep 4, 2026
Merged

ci: harden the bun audit gate (bun 1.4.0, registry retries, timeout)#3211
larryro merged 2 commits into
mainfrom
ci/bun-audit-1-4

Conversation

@larryro

@larryro larryro commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

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):

bun audit v1.3.12
@faker-js/faker  <=10.4.0
  workspace:@tale/platform › @stoplight/prism-http
  high: Faker: helpers.fake exploitable into arbitrary code execution - GHSA-qxc2-j82w-r537
1 vulnerabilities (1 high)

That copy is @faker-js/faker@5.5.3, pinned exactly by postman-collection@stoplight/http-spec@stoplight/prism-http (the mock server), which is a devDependency of @tale/platform and never in a shipped image. No upstream release lifts the pin: the latest postman-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's setup-bun pin goes to 1.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 --ignore is added.

Verified locally (bun 1.4.0, direct registry)

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 s 200s and 60 s hangs). A registry outage must not read as a finding, so the second commit:

  • runs the gate up to 3 times, 30 s apart, each attempt capped at 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);
  • caps the informational report step at 4 minutes (continue-on-error already) 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.

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.
@larryro larryro changed the title ci: run bun audit on bun 1.4.0 so --prod skips workspace dev deps ci: harden the bun audit gate (bun 1.4.0, registry retries, timeout) Sep 4, 2026
@larryro
larryro merged commit ff48e53 into main Sep 4, 2026
14 checks passed
@larryro
larryro deleted the ci/bun-audit-1-4 branch September 4, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant