Restrict packages directory permissions to 0700 - #243
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe default Composer packages directory now uses ChangesComposer directory permissions
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✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR tightens security around WP-CLI community packages by creating the packages composer directory with owner-only permissions, reducing exposure to local privilege/code-execution risks from a group/world-writable packages directory.
Changes:
- Change
Package_Command::create_default_composer_json()to create the composer directory with0700instead of0777. - Add a PHPUnit assertion to verify the created directory permissions on non-Windows systems.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Package_Command.php |
Creates the packages composer directory with owner-only permissions (0700). |
tests/phpunit/ComposerJsonTest.php |
Adds an automated check to validate the packages directory permissions after creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Restricts directory permissions for
~/.wp-cli/packages(orWP_CLI_PACKAGES_DIR) to0700upon creation inPackage_Command::create_default_composer_json().Previously,
0777was passed tomkdir(), which masked permissions using the active umask (e.g.002or000). This left the package directory group- or world-writable on environments with permissive umasks, exposing users to potential local code execution via the package autoloader.Summary by CodeRabbit