Skip to content

Add wp maintenance dependencies update - #95

Open
schlessera wants to merge 2 commits into
mainfrom
dependencies-update
Open

schlessera wants to merge 2 commits into
mainfrom
dependencies-update

Conversation

@schlessera

@schlessera schlessera commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Stacked on #94.

wp maintenance dependencies update fixes what dependencies audit reports, and proposes the new composer.lock as a pull request:

$ wp maintenance dependencies update --dry-run
| package            | from    | to      | dev |
| symfony/config     | v5.4.46 | v5.4.56 | yes |
| symfony/filesystem | v5.4.54 | v5.4.56 | yes |
| symfony/yaml       | v5.4.54 | v5.4.56 | yes |
Fixes 3 security advisories.
Dry run: not pushing the new composer.lock of wp-cli/wp-cli-bundle.

Without options, it updates the locked packages that have security advisories. --packages updates others instead, such as --packages=wp-cli/wp-cli to move the bundle to the framework's latest commit, or * to refresh the whole lock. Only composer.lock changes. The update runs composer update --no-install --with-dependencies --minimal-changes within the constraints of composer.json, so dependencies move only as far as they have to, and the new lock is audited again. Advisories that composer.json doesn't allow fixing are listed as still affected, and the command exits with an error code for them. For each one, it works out the first fixed version from the advisory's affected ranges and asks composer why-not what keeps that version out. The answer goes into the warning and into the "Still affected" section of the pull request, so it's clear which constraint, or which package, has to change:

Warning: symfony/yaml v5.4.54 is still affected by PKSA-nktx-f1n1-b4yd: Exponential and Quadratic Parse Times in the YAML Parser
It is fixed in 5.4.56, which is held back by:
  wp-cli/wp-cli-bundle 2.12.x-dev requires (for development) symfony/yaml (5.4.54)

Like the audit, it works from the files on GitHub, so no clone or git credentials are needed. The new lock is committed through the Git Data API on top of the commit it was built from, and a pull request is opened from a branch named after the update: update-dependencies-security by default, update-dependencies-wp-cli-wp-cli for the framework, and so on. A security fix and a framework refresh therefore never replace each other. A later run of the same update replaces its commit and refreshes the pull request. A rerun that would produce the same lock only refreshes the description, so it doesn't restart the checks. A branch that holds anything but the command's own composer.lock commit is never overwritten. Pushing asks first unless --yes is passed.

A few Composer details shaped it:

  • Composer 2.9 refuses to resolve at all when a named package keeps an advisory that composer.json doesn't let it fix, which would hold back every other fix with it. Security blocking is therefore off for the update, and the audit afterwards reports what's left.
  • With --minimal-changes, Composer updates the packages a wildcard matches only as far as needed. Wildcards are therefore resolved against the lock first, so symfony/* updates every locked Symfony package, and * makes the same 13 changes as a plain composer update.
  • An older local Composer rewrites the lock with its own plugin API version and drops fields. The command refuses instead of downgrading. The bundle's lock is currently written by Composer 2.11, so 2.9 fails with a hint to composer self-update.

This also moves the audit's temporary directory and environment handling into a Composer helper shared by both subcommands, and the y/n prompt of release generate into Prompt::confirm(), without changing either.

I checked this with --dry-run against the live bundle and nothing was pushed, so the first real run will open the pull request that fixes the failing audit. The write path, from the first run through reruns to refusing a branch someone else pushed to, is covered by tests against the fake GitHub API.

@schlessera
schlessera requested a review from a team as a code owner November 16, 2026 07:57
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9a01c55a-c2cd-4edd-ad59-7ff8fef55576
Commits

Reviewing files that changed from the base of the PR and between 3d214ed and 572825d.

Files selected for processing: 12

  • .maintenance/src/Composer.php
  • .maintenance/src/Dependencies_Command.php
  • .maintenance/src/Dependency_Audit.php
  • .maintenance/src/Dependency_Update.php
  • .maintenance/src/GitHub.php
  • .maintenance/src/Prompt.php
  • .maintenance/src/Release_Command.php
  • .readme-partials/DEVELOPMENT.md
  • tests/ComposerTest.php
  • tests/DependenciesUpdateCommandTest.php
  • tests/DependencyAuditTest.php
  • tests/DependencyUpdateTest.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@github-actions github-actions Bot added command:maintenance Related to 'maintenance' command dependencies Pull requests that update a dependency file enhancement New feature or request labels Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

@schlessera
schlessera changed the base branch from dependencies-audit to main November 16, 2026 13:12
schlessera and others added 2 commits November 16, 2026 13:13
Updates the locked packages that `dependencies audit` reports security
advisories for, or the ones given with --packages, within the constraints
of composer.json. Runs `composer update --no-install` against the files on
GitHub, audits the new lock again, and commits it through the Git Data API
on top of the commit it was built from. The pull request comes from a
branch named after the update, so a security fix and a refresh of the
framework never replace each other, and a rerun with the same result only
refreshes the pull request. A branch with commits or changes the command
did not make is never overwritten.

Wildcards are resolved against the lock, as Composer would only update
their matches as far as needed. Composer's security blocking is turned off
for the update, so that an advisory composer.json does not allow fixing
does not hold back the others; the audit afterwards reports it. A lock
written by a newer Composer than the local one is not downgraded.

Moves the temporary directory and environment handling of the audit into
a Composer helper shared by both subcommands, and the confirmation prompt
of `release generate` into a Prompt helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For each advisory that `wp maintenance dependencies update` cannot fix,
work out the first version that fixes it from the affected ranges, and
ask `composer why-not` what keeps that version out of the lock. Both go
into the warnings and into the "Still affected" section of the pull
request, so a maintainer knows which constraint in composer.json, or
which package, to change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:maintenance Related to 'maintenance' command dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant