Repository navigation
Conversation
Entries can contain a `*` wildcard and start with `~` (home directory), so a whole workspace can be trusted with a single entry. Exact paths take precedence, otherwise the longest matching pattern wins.
ktherage
force-pushed
the
trust-glob-patterns
branch
from
October 20, 2026 08:58
4ebe36f to
5469e4c
Compare
Author
|
Closing this in favour of #3078. On reflection this is a much broader topic than a simple regex: trust is deliberately per-path and non-recursive (#2923, #2924), and a wildcard changes what a decision means for directories that do not exist yet. I would rather agree on the shape (subtree grant vs. wildcard vs. generating exact entries from tooling) before proposing code. |
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.
Motivation
Trust is stored as a map of exact project directories, so trusting a whole workspace means adding one entry per project:
{ "/home/me/projects/one": true, "/home/me/projects/two": true }This adds wildcard support, so a workspace can be trusted with a single entry:
{ "~/projects/*": true }Behaviour
*matches any sequence of characters, including/, so nested project directories are covered too.~(or~/,~\) is expanded to the home directory ($HOME, falling back to%USERPROFILE%).*is the only wildcard:?and[]are matched literally, with or without a*in the same pattern.falsevalue still counts as a decision:{"*": false}stops the language server from asking about every project, and an exacttrueentry (e.g. fromphpactor config:trust) overrides it.~.Security
Trusting a directory allows Phpactor to load a configuration file that can execute arbitrary code. The trust documentation now repeats this and recommends keeping patterns narrow (
/home/me/projects/*, not/home/me/*).Tests
TrustTest: exact match, wildcard match (including nested directories), negative patterns, exact vs. pattern precedence, most specific pattern, literal?with and without*,~expansion for both patterns and exact entries, matching untrusted pattern as a decision, unconditional trust.trust.jsoncontaining a wildcard makesconfig:dumpreportcore.trusted: trueand load the project's.phpactor.json.phpstanandphp-cs-fixerare clean on the changed files.