Harden remote artifact path reads#1709
Open
fallintoplace wants to merge 1 commit into
Open
Conversation
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
Contributor
📝 WalkthroughWalkthroughThis PR hardens remote artifact path reading by introducing validation before tunnel execution. A new ChangesRemote Artifact Path Validation
Sequence Diagram(s)sequenceDiagram
participant Client as read_cluster_artifact_impl
participant Validator as _validate_remote_artifact_path
participant Regex as _SAFE_REMOTE_ARTIFACT_PATH
participant Tunnel as tunnel.run_command
Client->>Validator: validate(path)
Validator->>Regex: match segments and characters
alt Path is invalid
Validator-->>Client: error reason string
Client-->>Client: return invalid_artifact_path
else Path is valid
Validator-->>Client: None
Client->>Client: build remote_path (sanitized join)
Client->>Tunnel: cat -- (shlex.quoted path)
Tunnel-->>Client: artifact content
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Summary
read_cluster_artifact(path=...)to safe relative POSIX paths before loading the experiment.cat --when invoking the tunnel.Why
The previous implementation interpolated the artifact path into a remote shell command. A path containing shell syntax could run extra commands on the remote host.
Tests
uv run --with pytest python -m pytest tests/uv run --with ruff ruff check modelopt_mcp testsuv run --with ruff ruff format --check modelopt_mcp testsSummary by CodeRabbit
Bug Fixes
Tests