fix(cloudlab): quote ssh arguments in on_nodes (SC2068) - #103
Open
randomizedcoder wants to merge 1 commit into
Open
randomizedcoder wants to merge 1 commit into
randomizedcoder wants to merge 1 commit into
Conversation
on_nodes forwarded the remote command with a bare, unquoted $@:
ssh -4 $node $@
An unquoted $@ undergoes word splitting and glob expansion in the caller
before ssh sees it, so any argument that contains spaces is split into
several arguments, an argument containing a glob metacharacter is
expanded against the local filesystem, and an empty-string argument is
dropped entirely. shellcheck reports this as SC2068 (error).
Quote both the node and the forwarded arguments so word boundaries reach
ssh intact:
ssh -4 "$node" "$@"
Also add the missing newline at end of file.
Gate: `shellcheck --include=SC2068 cloudlab/bin/on_nodes` reports the
SC2068 error before and is clean after. A bats scaffold
(cloudlab/tests/on_nodes.bats) stubs ssh on PATH and asserts argument
boundaries survive: 3 of its cases (spaces / glob char / empty arg) fail
against the old bare-$@ script and all pass after the fix; no new CI is
wired. The pre-existing SC2004 style note on the arithmetic loop is left
untouched as out of scope.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Bug: unquoted
$@forwarded to ssh inon_nodes(SC2068)cloudlab/bin/on_nodesruns a caller-supplied command on a range of cluster nodes, forwarding the command and its arguments with a bare, unquoted$@:An unquoted
$@is subject to word splitting and glob expansion inon_nodesitself, before ssh ever sees the arguments. So:"grep foo bar") is split into several arguments;'*.c') is expanded against the local filesystem;shellcheck reports this as SC2068 (error).
Fix
Quote both the node and the forwarded arguments so word boundaries reach ssh intact:
Verification (linter gate + bats regression)
A bats scaffold is included as executable documentation (no new CI is wired). It stubs
sshonPATHto record the exact argv it receives, then asserts argument boundaries survive. Run against the old bare-$@script, three cases fail; after the fix all pass:The pre-existing
SC2004style note on the arithmetic loop ($first/$lastinside(( ))) is a separate, style-level check and is left untouched to keep this diff focused on the SC2068 defect.