[Mate] Add symfony-dotenv-check tool for safe .env inspection - #2479
Merged
wachterjohannes merged 1 commit intoSep 23, 2026
Merged
Conversation
wachterjohannes
requested review from
Nyholm,
OskarStark and
chr-hertel
as code owners
September 1, 2026 20:35
wachterjohannes
force-pushed
the
symfony-dotenv-check
branch
from
September 23, 2026 19:40
d33de7e to
e427acd
Compare
wachterjohannes
force-pushed
the
symfony-dotenv-check
branch
from
September 23, 2026 20:03
4dea8c5 to
42390b8
Compare
Closed
3 tasks
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.
Problem
bin/console debug:dotenvprints every resolved env var fully unmasked. During local Mate testing this leaked a genuineHUGGINGFACE_API_KEYinto an agent transcript, sourced from the ambient shell rather than any project file. Mate had no tool of its own covering env/dotenv, despite a misconfigured.envbeing one of the most common causes of a broken setup.What this adds
A new
symfony-dotenv-checktool, active only whensymfony/dotenvis installed. It mirrors Symfony's ownDotenv::loadEnv()discovery order (.env/.env.dist→.env.local→.env.$APP_ENV→.env.$APP_ENV.local) and reports, per variable: which file(s) declare it, whether it resolves in Mate's own process, and astate(file,ambient_override,ambient_only,declared_empty_in_file,declared_not_resolved_in_this_process,not_set).ambient_overrideis exactly the shape of the original leak: declared as a placeholder in.env, but the real value comes from somewhere else entirely.Masking (never a raw value)
Every value reduces to
length(real count, shown openly) and a fixed-widthpreviewmask (first+last character, or**for very short values) plus a content-basedlooks_like_placeholderguess. Values are masked uniformly regardless of key name — no allowlist for "safe" keys likeAPP_ENV. That kind of per-key heuristic is exactly what let the original leak through unnoticed.Uses plain
ResponseEncoder::encode(), notencodeUntrusted()— same reasoning asserver-info: these are measured facts about the project/environment, not attacker-influenced application data.Docs & tests
New
symfony-dotenv-diagnosticsskill,INSTRUCTIONS.mdsection,CHANGELOG.mdentry in a new0.14section (0.13is frozen sincev0.13.0). Tests cover file precedence,.env.distfallback, empty/ambient/override states, uniform masking, placeholder detection, and an explicit "no raw secret in output" assertion.vendor/bin/phpunit,phpstan analyse --debug,php-cs-fixer fix: all green.