-
Notifications
You must be signed in to change notification settings - Fork 1k
Check open_basedir restrictions before is_readable() to prevent warnings #6192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
6
commits into
main
Choose a base branch
from
copilot/suppress-is-readable-warning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+61
−1
Conversation
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
… set Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Suppress is_readable warning in wp-cli with open_basedir
Suppress is_readable() warning when open_basedir restricts directory traversal
Jan 12, 2026
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Instead of suppressing errors with @, check if the path is within open_basedir restrictions before calling is_readable(). This approach avoids hiding other potential errors while still preventing warnings when traversing directories outside allowed paths. Add is_path_within_open_basedir() helper function that: - Returns true if no open_basedir restriction is set - Checks if path starts with any allowed path from open_basedir - Uses string comparison to avoid triggering warnings on restricted paths Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
- Normalize input directory with realpath() early in find_file_upward() to handle relative paths and symlinks properly - Add safety check for getcwd() returning false - Update documentation to clarify that is_path_within_open_basedir() expects absolute paths - This addresses security concerns about asymmetric path comparison Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot
AI
changed the title
Suppress is_readable() warning when open_basedir restricts directory traversal
Check open_basedir restrictions before is_readable() to prevent warnings
Jan 12, 2026
On Windows, filesystem paths are case-insensitive, so the path comparison in is_path_within_open_basedir() needs to handle this. Added case-insensitive comparison using strcasecmp() and stripos() when running on Windows systems (detected by checking if DIRECTORY_SEPARATOR is backslash). This ensures that open_basedir checks work correctly on Windows even when the case of paths doesn't match between open_basedir settings and actual paths. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
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.
Plan to address feedback on open_basedir warning fix
Summary
Successfully addressed all feedback on the PR to fix
open_basedirwarnings in WP-CLI.Latest change: Added case-insensitive path comparison for Windows systems to handle scenarios where the case of paths in
open_basedirsettings doesn't match the actual filesystem paths.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.