Repository navigation
feat(doctor): require a read-only environment directory with a deployment dump - #45
Merged
Merged
Conversation
…ment dump The generated configuration executes .env.dump.php and .env.cached.php from the environment directory. With cache-env auto the web process writes the cache there itself, which needs write access on the bootstrap path. The strict production profile now reports production.env-dir-readonly once a dump exists; another identity remains unknown because mode bits cannot prove ACL behavior.
Root can write every directory, so is_writable() says nothing about the PHP-FPM identity; mirror the readability checks' uid 0 handling.
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.
Finding
Review finding R-S1 (medium, operational): with the default
cache-env: autothe PHP-FPM process writes.env.cached.php, executable PHP containing file-owned secrets, intoenv-dirat shutdown. That only works when the web identity can write the directory the generated configurationrequires from, so any file-write primitive in the web process becomes a bootstrap code path.EnvCacheFormat::canReplace()only protects foreign files from being overwritten. Finding R-P4 (per-requeststat()of every environment source file in cache mode) has the same remedy and is documented in the same PR.Change
doctor --productionaddsproduction.env-dir-readonlyonce a deployment dump exists:passwhen the environment directory is not writable by the checked identity,failwhen it is,unknownfor a different--php-useror when doctor runs as root (mode bits cannot prove the PHP-FPM identity's access; same rule as the readability checks).docs/operations.mdanddocs/deployment.mdexplain why the directory must stay unwritable and that the request-time cache is a development convenience.Verification
ProductionDoctorTestruns the strict profile against a read-only project directory (chmod 0555 during the doctor run) and adds a case for writablefail, read-onlypassand foreign identityunknown.composer cs,composer static-analysisandtools/check-docs.pypass.testPhpIdentityChecksParentTraversalfails onmainin the same container (missing POSIX user).