Add directory boundary validation for stata_do execution paths#70
Merged
SepineTam merged 4 commits intodev/v1.16.2from Apr 30, 2026
Merged
Conversation
Deploying stata-mcp with
|
| Latest commit: |
4e1e053
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f545400b.stata-mcp.pages.dev |
| Branch Preview URL: | https://codex-add-directory-boundary.stata-mcp.pages.dev |
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
stata_doto the configured dofile folder and working directory to match the security model used byread_log.Description
_is_within_allowed_directories(target_path, allowed_dirs)that resolves paths and checks containment withrelative_to()to centralize boundary checks.stata_do(checked before guard validation) so only files underconfig.STATA_MCP_FOLDER.DOorconfig.WORKING_DIRmay be executed.[SECURITY VIOLATION]warning that includes the requested path, resolved path, and the allowed directories.tests/test_stata_do_boundary.py.Testing
PYTHONPATH=src pytest -q tests/test_stata_do_boundary.pyand all tests passed (5 passed).PYTHONPATHraisedModuleNotFoundError: No module named 'stata_mcp'in this environment, indicating the failure was due to import path setup rather than the code changes.pre-commit run --all-filescould not be executed in the environment becausepre-commitis not installed.Codex Task