Repository navigation
Python: fix(sessions): reject directory paths in upload path validation - #14797
Open
Hardik K (hardikkaurani) wants to merge 7 commits into
Open
Hardik K (hardikkaurani) wants to merge 7 commits into
Hardik K (hardikkaurani) wants to merge 7 commits into
Conversation
… upload validation
…ntinue to succeed
Hardik K (hardikkaurani)
deployed
to
github-app-auth
November 15, 2026 11:56 — with
GitHub Actions
Active
Contributor
Author
|
Could you please take a look when you have a moment? This PR hardens upload path validation in All unit tests and lint checks pass cleanly locally. Thank you for your review! |
This branch was successfully deployed
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 and Context
In
SessionsPythonTool._validate_local_path_for_upload, paths passed toupload_fileare validated againstallowed_upload_directories. However, the validation previously did not reject paths pointing directly to an allowed directory or one of its subdirectories.As a result, these paths passed validation and were returned as valid file paths.
upload_file()then attempted to open the directory as a file, causing an unhandled OS error instead of the expectedFunctionExecutionException("Access denied: ...").This aligns upload path validation with the directory validation behavior introduced for download paths in #14791.
Description
_validate_local_path_for_uploadto reject paths that resolve to an allowed directory or any subdirectory.test_sessions_python_plugin.pycovering:Contribution Checklist