Skip to content

fix(validation): judge target paths by POSIX rules, not the server's OS - #635

Open
owtaylor wants to merge 1 commit into
rhel-lightspeed:mainfrom
owtaylor:pure-posix-path
Open

owtaylor wants to merge 1 commit into
rhel-lightspeed:mainfrom
owtaylor:pure-posix-path

Conversation

@owtaylor

@owtaylor owtaylor commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Paths passed to the file and log tools name files on the target host, which is always Linux, but they were handled with pathlib.Path, whose behaviour follows the OS the server itself runs on. A Windows-hosted server rejected "/var/log/secure" as relative and would have accepted "C:/logs/app.log" as absolute.

Decide absoluteness from the string, and carry target paths as PurePosixPath so that splitting, joining and comparison stay POSIX wherever the server runs. pathlib.Path now appears only where a path names a file on the server's own filesystem: the LOCALHOST branches, which Linux-only local execution already restricts to Linux.

Fixes #633


Note: that this fixes up everything that I and Claude could find that was broken, but it leaves us open to reintroducing problems in the future. A more complete solution would be to have LocalPath and TargetPath aliases that we enforce everwhere (via ruff) in place of Path or PurePosixPath. I'll follow a follow-up issue for that.

Paths passed to the file and log tools name files on the target host,
which is always Linux, but they were handled with pathlib.Path, whose
behaviour follows the OS the server itself runs on. A Windows-hosted
server rejected "/var/log/secure" as relative and would have accepted
"C:/logs/app.log" as absolute.

Decide absoluteness from the string, and carry target paths as
PurePosixPath so that splitting, joining and comparison stay POSIX
wherever the server runs. pathlib.Path now appears only where a path
names a file on the server's own filesystem: the LOCALHOST branches,
which Linux-only local execution already restricts to Linux.

Fixes rhel-lightspeed#633

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@owtaylor
owtaylor requested a review from a team as a code owner October 2, 2026 04:03
@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 98.19% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/linux_mcp_server/commands.py 89.83% <100.00%> (+0.17%) ⬆️
src/linux_mcp_server/connection/ssh.py 93.96% <100.00%> (+0.03%) ⬆️
src/linux_mcp_server/models.py 100.00% <100.00%> (ø)
src/linux_mcp_server/parsers.py 85.82% <100.00%> (ø)
src/linux_mcp_server/tools/logs.py 100.00% <100.00%> (ø)
src/linux_mcp_server/tools/storage.py 97.75% <100.00%> (+0.02%) ⬆️
src/linux_mcp_server/utils/validation.py 100.00% <100.00%> (ø)
tests/utils/test_validation.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote Linux paths are rejected when the MCP linux-mcp-server runs on Windows

1 participant