Skip to content

ci: fail the build on high-severity dependency advisories - #405

Open
IanoNjuguna wants to merge 2 commits into
IntersectMBO:mainfrom
IanoNjuguna:ci/audit-gate
Open

IanoNjuguna wants to merge 2 commits into
IntersectMBO:mainfrom
IanoNjuguna:ci/audit-gate

Conversation

@IanoNjuguna

Copy link
Copy Markdown
Contributor

Description

Adds the dependency advisory gate that #338 asked for, and documents it in TRIAGE.md.

website/package.json has defined audit:ci since before this change, and no workflow ran it: grepping .github/workflows/ for npm audit returned nothing. A dependency with a known high-severity advisory could therefore merge, and the first signal would be a Dependabot alert after the fact.

The step now runs in both gates, after npm ci and before the build:

  • pr-build-website.yml, so it fails the PR that introduces the finding
  • deploy.yml, so it also guards the path to production

Scope, as agreed on #338:

  • --audit-level=high, so high and critical fail and moderate or low are reported only. A gate that reddens on findings nobody can fix gets bypassed.
  • --omit=dev, so advisories that only affect build-time tooling do not block a release. npm run audit still reports the full tree locally.

Fixes #338. Also carries the third box from #339, which was closed when its alerts resolved themselves: TRIAGE.md now states the dismissal bar, and the existing code-scanning dismissal section is widened to cover Dependabot advisories, with the extra requirement that a dependency dismissal names the condition that reopens it.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • I have tested these changes locally
  • I have checked for broken links
  • Code examples have been tested

Checklist

  • My code follows the style guidelines
  • I have performed a self-review
  • I have made corresponding changes to documentation
  • My changes generate no new warnings

Verification

The gate passes on today's tree, so this does not redden main or any open PR on merge. Against main at 973801b:

npm audit --omit=dev --audit-level=high
found 0 vulnerabilities
exit 0

Both workflow files parse as YAML, and the step list for the build job is unchanged apart from the new step between install and build.

The new step runs on this PR itself, since pr-build-website.yml triggers on changes to pr-build-website.yml. The check on this PR is the evidence that the gate works on the way in. deploy.yml's copy only runs on a push to main.

Notes

  • Two commits: the gate, then the TRIAGE.md write-up. Splitting them keeps the CI change reviewable without the doc noise.
  • The unrelated open CodeQL alert, js/indirect-command-line-injection, is not touched here.

The repo defined npm run audit:ci and never ran it: no workflow mentioned
npm audit, so a dependency with a known high advisory could merge and the
first signal was a Dependabot alert afterwards.

Runs it in both gates, after npm ci and before the build, so the same check
runs on the way in (pr-build-website.yml) and on the way to production
(deploy.yml).

The script takes --omit=dev and --audit-level=high, which is the scope
agreed in IntersectMBO#338: high and critical findings fail, moderate and low are
reported, and findings that only affect build-time tooling do not gate a
release.

Verified the gate passes on main's lock at 973801b:
  npm audit --omit=dev --audit-level=high  ->  found 0 vulnerabilities, exit 0

Refs IntersectMBO#338
TRIAGE.md documents both scanning setups but nothing said what happens on
the way in, or when a finding may be dismissed. Adds the gate itself, and
extends the dismissal section so it covers Dependabot advisories as well as
CodeQL alerts, with the extra requirement for a dependency finding: name
the condition that reopens it.

Fixes IntersectMBO#338

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration and GitHub Actions Security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail the build on high-severity dependency advisories

1 participant