Trust project configuration files in Behat runs - #348
Conversation
WP-CLI gates `require`, `exec`, `env` and `ssh-args` directives found in a project-level wp-cli.yml behind a trust confirmation. Test fixtures create such files routinely and a non-interactive test run cannot answer the prompt, so pass WP_CLI_TRUST_PROJECT_CONFIG=1 to every command the Behat context runs. An explicit WP_CLI_TRUST_PROJECT_CONFIG in the outer environment still wins, and scenarios exercising the trust mechanism itself can keep overriding it per command. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcafAC2UeQTVKoy8wVxJzB
|
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📝 WalkthroughWalkthroughChangesProject configuration trust
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 150-157: Update the “Project configuration trust” heading in
README.md to use the repository’s configured setext heading style, and add a
gherkin language identifier to the command example’s fenced code block.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 47ae8d2e-65d6-4ffa-a607-d2c37a5e68b8
📒 Files selected for processing (2)
README.mdsrc/Context/FeatureContext.php
schlessera
left a comment
There was a problem hiding this comment.
The change itself is right and minimal: get_process_env_variables() defaults WP_CLI_TRUST_PROJECT_CONFIG to 1 and an explicit outer value still wins, matching the existing pass-through pattern for WP_CLI_CONFIG_PATH and friends. '1' is accepted by normalise_trust_setting() in wp-cli/wp-cli#6365, and the per-command override in scenarios (WP_CLI_TRUST_PROJECT_CONFIG=false wp …) works because the process env is the base and the command prefix overrides it.
Two things before this can merge:
- README code fence is not closed. At head, the
gherkinblock under "Project configuration trust" has an opening fence and no closing one (37 fences in the file, an odd count), so everything from "Setting up the tests in Travis CI" onwards renders inside a code block. Your own suggestion from 2026-09-03 has the closing fence; it just needs to be applied. - This only makes sense together with #6365. Once released, every Behat run in the org trusts project config by default, which is exactly the behaviour #6365 gates. If #6365 is deferred to 4.0.0, this should wait with it; if it goes into 3.0.0, the order is: merge this, tag wp-cli-tests 5.4.0, then #6365's CI can pass.
Not blocking: the codecov/patch failure is the two new lines in get_process_env_variables(), which has no unit coverage for any of its pass-throughs; the CodeRabbit heading-style nit is wrong, the sibling headings in that section are #### as well.
Companion to wp-cli/wp-cli#6365.
That PR gates
require,exec,envandssh-argsdirectives found in a project-levelwp-cli.ymlbehind a trust confirmation, controlled by--trust-project-config/WP_CLI_TRUST_PROJECT_CONFIG.Test fixtures create such files all the time —
Given a wp-cli.yml file:with arequire:entry is one of the most common steps across the WP-CLI package suites, andgiven_a_request_to_a_url_respond_with_file()writes one itself. A Behat run is non-interactive, so without this change every one of those scenarios fails with:Changes
FeatureContext::get_process_env_variables()now passesWP_CLI_TRUST_PROJECT_CONFIG=1to every command it runs. An explicit value in the outer environment still wins, following the same pass-through pattern already used forWP_CLI_CONFIG_PATH,WP_CLI_ALLOW_ROOTand friends.When I try \WP_CLI_TRUST_PROJECT_CONFIG=false wp cli version``), which is how the trust mechanism's own acceptance tests in Add project configuration trust verification (trust-project-config) wp-cli#6365 exercise the denial paths.Testing
Ran the affected wp-cli/wp-cli feature scenarios against a checkout of wp-cli/wp-cli#6365 with this context patched in: the 28 scenarios that build a project
wp-cli.ymlcontainingrequire/exec/env/ssh-argsand do not need a WordPress install (acrosscommand,config,flags,prompt,runcommandandrunnerfeatures) fail without this change and pass with it. The nine new trust scenarios infeatures/config.featurestill pass, confirming that the per-command override keeps working.Note this needs to be released before wp-cli/wp-cli#6365's CI can go green, since that repo installs
wp-cli/wp-cli-testsfrom a version constraint.Generated by Claude Code
Summary by CodeRabbit
New Features
Documentation