Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
Member
Author
|
This got a little wild, will be superseded by a smaller scoped PR. |
denolfe
added a commit
that referenced
this pull request
Nov 4, 2026
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
This branch had an error being deployed
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.
The daily
audit-dependenciesworkflow now opens a PR that fixes audit findings with a valid upgrade path. Codex (OpenAI's coding agent) makes the edits, and a person reviews and merges each PR.The audit reports findings every day, but a person still makes each fix by hand. For findings with a clear upgrade path, this workflow takes over that loop. Later jobs treat Codex's patch as untrusted and check it before a bot opens the PR.
Changes
audit-dependencies-branch.yml)precheckruns the audit and picks the next step:none,dry-run,create,update,skip,close, orblocked.fixruns Codex with the rewritten skill and uploads the patch and Codex's JSON result.verifyapplies the patch on a fresh runner. It runs the guards, the install, a re-audit, and the builds.open_prrepeats the guards and opens or updates the PR onci/audit-deps-fix-<ref>.housekeepingcloses a stale PR, or comments when a person has pushed to the bot branch.statusfails on any failed job or on findings without a fix PR. It only warns when an open PR covers the findings..agents/skills/audit-dependencies/SKILL.md)audit-dependenciesaction instead of the shell script. Local use still works.repositorymetadata, includingdirectoryfor monorepo packages./tmp. Network access is limited to the npm registry and GitHub hosts.drop-sudosafety strategy removes sudo before Codex starts. The checkout's.codex/config.tomlis ignored (untrusted project). Its MCP servers (tool servers Codex could call) never load.0.165.0. Thefixjob runs onubuntu-24.04becausedrop-sudofails on 26.04.package.json,pnpm-lock.yaml, andpnpm-workspace.yaml. Symlinks, renames, deletes, and mode changes fail.overrideschanges on the consumer-facing scope fail.mainwith default inputs (consumer-facing,high) change PRs. Every other run is a dry run.audit-depsenvironment. The App is not a ruleset bypass actor (an identity allowed to skip branch protection).main.ymlci/audit-deps-fix-*branches. The job assumes an AWS role. Bot PRs run dependency versions no person has reviewed.Design Decisions
Codex runs in a job with no write token. Its output leaves the runner only as an artifact.
verifyandopen_prrun on fresh runners and repeat every check before anything uses the patch. The job that holds the App token never executes dependency code.A dry run on this branch confirmed the sandbox boundary. Codex's shell can write to the checkout and
/tmp. Writes to$RUNNER_TEMP(the runner's temp folder, which holdsGITHUB_ENVand the trusted Codex config) fail with a read-only file system error.When a person closes the bot's PR, the next run skips that exact advisory set. A new advisory opens a fresh PR. When a person pushes to the bot branch, the workflow stops updating it and leaves a comment.
Rollout:
ci/audit-deps-auto-prfrom theaudit-depsenvironment's branch policy, so onlymainremains.mainand review the first PR.main.ymlchange also needs a 3.x backport for bot PRs that target 3.x.Overall Flow
References / Links
drop-sudofailure on ubuntu-26.04🤖 Written with AI