The daily dependency audit now opens PRs that fix the advisories it
finds, on `main` and `3.x`. One PR holds all non-major bumps, and each
major bump gets its own draft PR.
Merge after #19300, which skips bot PRs in the `3.x` content API tests.
```diff
.github/
├── actions/
│ ├── audit-dependencies/src/lib/bumpAdvisor.ts # traces the whole graph when a module leaves its chain
│ └── setup/action.yml # pins setup-node to a commit SHA
├── scripts/
+│ └── audit-deps/ # plans bumps, prepares commits, renders PR bodies
+│ ├── cli.mjs # plan, prepare-prs
+│ ├── plan.mjs # builds and checks the bump and PR plan
+│ ├── step-handoff.mjs # checks the data each step gives the next
+│ └── commands/ # github-script steps: decide PR steps, publish
└── workflows/
├── audit-dependencies.yml # calls the branch workflow once per ref
+ ├── audit-dependencies-branch.yml # one job: audit, plan, prepare, publish
└── main.yml # runs audit-deps specs, skips bot PRs in content API tests
```
The audit action already reports which direct dependency bump clears
each advisory. Until now a person had to apply that bump by hand. This
PR applies the plan in CI, takes over from Dependabot security PRs, and
supersedes #19217, which had Codex write the fix.
Resolves PYLD-5012
**Example dry run:** [run
41712179405](https://github.com/payloadcms/payload/actions/runs/41712179405)
audits `main` and `3.x`. The run summary lists the PRs it would open.
**Example PR Body**
<img width="1040" height="900" alt="image"
src="https://github.com/user-attachments/assets/ec21a4de-9112-4187-a71f-b710adcc50c8"
/>
## Changes
- **Branch workflow** (`audit-dependencies-branch.yml`)
- One job per ref audits, plans, prepares and publishes.
- Only the publish step holds a write token. It is a GitHub App token,
minted after prepare.
- The scripts and the audit action come from the tooling checkout (a
sparse clone of the triggering commit). The audited ref gives only its
tree and its allowlist.
- A dry run from a branch therefore tests that branch's audit action
too.
- Publish runs only when prepare finishes. It still runs when the App
token mint fails, so the summary can report the missing token.
- **Pinned actions**
- Every action the job runs, including those in the shared setup action,
is pinned to a full commit SHA.
- The `setup-node` pin in the setup action applies to every workflow
that uses it. It pins the commit `@v6` resolves to today.
- **Plan and prepare** (`.github/scripts/audit-deps`)
- `plan` groups the fixable bumps: non-major bumps in one PR, each major
in its own draft PR.
- `prepare-prs` makes each PR one bot commit on the audited commit.
- Bumps use `pnpm install --lockfile-only --ignore-scripts`. No package
install scripts run.
- A range specifier such as `>=5.0.0` is left unchanged. The re-audit
shows whether the other edits fix the advisory.
- A path guard rejects any change outside the bumped manifests and the
lockfile.
- A re-audit runs on each prepared commit. A PR fails if an advisory it
claims is still reported.
- **Step handoffs**
- One plan module builds and reads the plan. Every step that reads it
checks that each PR names known bumps.
- The handoff module checks `pr_steps` and `prepared.json` (the data one
step gives the next) when it writes them and when it reads them.
- A bad handoff stops the run before any push. An update without a PR
number is one example.
- `prepare-prs` records every planned PR, including skipped and blocked
ones. Publish reads only that file.
- **Existing PRs**
- Each PR body ends with a fingerprint (a hidden comment with the PR id,
bumps and advisories).
- An unchanged PR is skipped. A PR with a person's commits is not
updated.
- A PR a person closed is not opened again for the same change.
- Bot PRs that are no longer planned are closed.
- When GitHub has not yet computed whether a PR has conflicts, publish
asks again, up to three times.
- **PR body**
- Lists each bump with its advisories, upstream release notes and
commits.
- An advisory counts as fixed only when none of its findings still
reaches a bumped dependency.
- Each bump lists as affected only the packages that declare its
dependency.
- Major PRs start with a review banner.
- Upstream details load one bump at a time. This keeps a large group PR
under GitHub's secondary rate limit.
- A repository owner or name from the registry must be a plain path
segment. Other values give no upstream links.
- Outside text is sanitized. Issue references, mentions and HTML
comments cannot break the body or notify anyone.
- Upstream GitHub links go through `redirect.github.com`. A link to an
issue cannot add a reference event to it.
- **Bump advisor** (`bumpAdvisor.ts`)
- The advisor first traces only the advisory's chain (the packages
between the direct dependency and the vulnerable module).
- When that trace finds no copy of the module, the advisor now traces
the whole graph before it reports `clear`.
- A renamed package no longer gives a false fix. `@sentry/nextjs`
10.76.2 renames `@sentry/bundler-plugin-core` to
`@sentry/bundler-plugins`. The new package still pulls `glob` 13.
- The `glob` and `minimatch` advisories through Sentry now show as "no
fix available". Sentry merged the `glob` 14 fix but has not released it.
- When a release clears them, the planner opens the Sentry PR. No
allowlist entry is needed.
- **`audit-dependencies.yml`**
- Real runs audit at `moderate` severity. At `high`, `main` had no
findings.
- **`main.yml`**
- audit-deps specs run in CI.
- Content API tests skip bot PRs. That job assumes an AWS role. Bot PRs
run dependency versions no person has reviewed.
- **Dry runs**
- Runs from other branches, or with non-default inputs, only report.
- A dispatch for one ref is a dry run. A real manual run needs `ref:
both` from `main`.
- Real runs share one concurrency group (a queue that keeps only its
newest pending run). Each dry run gets its own group.
- A dry run therefore cannot replace a pending real run.
## Design Decisions
- **No AI in the fix.** pnpm applies the bump the audit planned. The PR
body is built from registry and GitHub data. #19217 had Codex write the
change; this PR drops that.
- **Token per step.** Steps that run pnpm or read registry data hold the
read-only `github.token` at most. The App token exists only in the
publish step.
- **Lease on push.** Publish pushes with `--force-with-lease` (a push
that fails if the remote branch moved since the plan read it). A
person's push is never overwritten.
- **No cache.** The job later holds a write token. It restores no cache
another workflow could have written.
- **Re-audit stays strict.** The advisor's trace is a guess that bounds
registry requests. The re-audit is the check. A PR that still reports a
claimed advisory fails instead of opening.
- **Accepted costs**
- A PR fails when the re-audit disagrees with the plan.
- A failed group PR is not retried per bump.
- Major PRs are drafts. A person reads the release notes before merge.
- A closed group PR stays closed only for the exact same set of bumps.
- `main`'s audit action audits the `3.x` tree. A later action change on
`main` must also work on `3.x`.
- Each prepared PR runs a full re-audit. The job time grows with the
number of PRs.
- PRs that touch only `.github/scripts/audit-deps` run the full test
suite. The unit test job depends on the build job.
- The `audit-deps` environment allows the feature branch and has no
required reviewers. Using it from that branch needs write access. The
branch leaves the policy after merge.
- A consumer package whose dependencies fail to resolve gives no
findings. The re-audit then counts its advisories as fixed, and a
planned PR can close as stale. That audit behavior is already on `main`.
## Overall Flow
```diff
audit-dependencies.yml (daily schedule or dispatch; refs main and 3.x)
- audit action -> report
+ audit-dependencies-branch.yml, once per ref
+ checkout tooling -> scripts and audit action from the triggering commit
+ audit action -> report on the audited ref's tree
+ plan -> bumps grouped into PRs
+ decide PR steps -> create, update, skip, skip-rejected or blocked; stale PRs
+ prepare-prs -> per PR: bump, lockfile, path guard, re-audit, commit
+ mint App token (real runs only)
+ publish (only when prepare-prs finishes)
+ -> push with lease, create or update PR, close stale PRs, summary
```
## References / Links
-
[actions/create-github-app-token](https://github.com/actions/create-github-app-token):
App token for the publish step
- [git push](https://git-scm.com/docs/git-push): `--force-with-lease`
semantics
- [pnpm install](https://pnpm.io/cli/install): `--lockfile-only` and
`--ignore-scripts`
-
[getsentry/sentry-javascript#25969](getsentry/sentry-javascript#25969):
`glob` and `minimatch` advisories in `@sentry/bundler-plugins`
-
[getsentry/sentry-javascript#26014](getsentry/sentry-javascript#26014):
Sentry fix that moves `glob` to 14, not yet released
🤖 Written with AI
Content API tests no longer run on bot PRs to
3.x. This is the3.xhalf of the same gate in #19295, and it must merge before #19295.Root Cause
main.ymlof its base branch. Bot PRs to3.xtherefore use the3.xcopy, which skips only fork PRs.tests-content-apiassumes an AWS role and pulls a private ECR image.3.x, that code would run with the AWS credentials.Changes
tests-content-apicondition (.github/workflows/main.yml)ci/audit-deps-fix-, the prefix the audit workflow uses for its PRs.main.🤖 Written with AI