Repository navigation
Add read-only pipeline support and find, awk, wc to ssh allowlist - #274
Merged
Merged
Conversation
…st tests awk is only read-only with plain program text. gawk's -i inplace, -o, --profile, -f, -l, -E and --include can modify files or load code without any escape hatch in the program, so any option other than -F and -v now needs confirm. Adds a node:test suite (npm test) covering find primaries, awk restrictions, pipeline splitting, and quoted or glued pipes.
The tokenizer discarded any empty buffer, so grep '' file reached the remote host as grep file. A quoted empty string is now kept as an empty argument.
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.
This change extends the SSH passthrough tool in the MCP server so it accepts read-only pipelines instead of only single commands, and adds
find,awk, andwcto the command allowlist. Operators can chain inspection commands, such asfind /home/web/monitoring -mtime +90 | wc -l, in one call withoutconfirm: true.Previously every token was shell-quoted, so an unquoted pipe was rejected by the read-only check and, worse, sent to the remote host as a literal argument, meaning the pipeline never ran.
Pipeline behavior
|is treated as a pipe operator. A pipeline is auto-approved only when every segment passes the read-only check on its own.'a|b') and pipes glued to other text (ls|wc) stay literal arguments.New allowlist entries and their guards
findis refused when it carries mutating primaries:-delete,-exec,-execdir,-ok,-okdir,-fprint,-fprint0,-fprintf,-fls.awkis refused when its program text containssystem(),getline,close(),|, or output redirection, and when it carries any option other than-For-v(gawk's-i inplace,-o,--profile,-f,-l,-E,--includecan write files or load code).wchas no extra guard.Related fix
grep '' filereaches the remote host with its''intact.Tests
node:testsuite, run withnpm testinmcp-server/, covering thefindandawkrules, pipeline splitting, malformed pipelines, quoted and glued pipes, remote command building, empty arguments, and credential paths inside pipelines.Rollout
dist/, so it needsnpm run buildand a restart to pick this up. The Go CLI is unaffected.CHANGELOG.mdhas Added and Fixed entries under Unreleased, with no version bump.Files Changed
CHANGELOG.mdmcp-server/package.jsonmcp-server/src/tools/sshPassthrough.tsmcp-server/test/sshPassthrough.test.ts