Repository navigation
test: add a unit suite and CI, and fix what it caught - #13
Merged
Merged
Conversation
461 lines had no tests, which is why a command injection, three unenforced caps, and an unrunnable reply address all shipped without anything noticing. 27 cases now cover the pure logic: argument quoting, the local and remote size limits, target resolution, and reply-line construction. No network, no SSH, no Claude Code — standard library only. Writing them immediately caught is_tailnet_address accepting 100.64.999.999, since it checked the first two octets and ignored the rest. Harmless while a regex guards the caller, but it was one careless caller away from mattering. CI runs the suite on Ubuntu and macOS against Python 3.9 (the floor the README promises) and 3.13, plus shellcheck on install.sh. Also from the same review: install.sh disables globbing around the --host loop so `--host '*'` cannot expand; SKILL.md and CLAUDE.md now show the reply line as it is actually generated; and CLAUDE.md no longer claims the skill directory is self-contained, which was backwards — the symlink exists to keep one source of truth, and dangles if that directory is copied alone.
SC2016 fires on the heredoc we pipe to ssh, where single quotes are exactly what keeps $HOME unexpanded until it reaches the remote shell. SC1007 misreads `CDPATH= cd -- ...`, the standard guard against cd printing a path. Both are load-bearing, so the check excludes them by name with the reason rather than dropping shellcheck or silencing it file-wide.
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
Closes #10.
461 lines had no tests. That is why a command injection, three unenforced caps, and an unrunnable reply address all shipped without anything noticing — every one of them was found by a person reading the code, not by the repo.
27 unit tests covering the pure logic: ssh-argument validation, local and remote size limits, target resolution, reply-line construction, and own-session detection. No network, no SSH, no Claude Code — standard library only, so they run anywhere in under a second.
CI on Ubuntu and macOS against Python 3.9 (the floor the README promises) and 3.13, plus
shellcheckon the installer.What writing them caught
is_tailnet_addressaccepted100.64.999.999— it checked the first two octets and ignored the rest. Harmless while the only caller feeds it regex-matched text, but one careless caller away from mattering. Fixed, and the real detection still returns the right address.That is the argument for the suite in one line: the bug was in a function I had already reviewed twice today.
Also in this change
install.shdisables globbing around the--hostloop, so--host '*'cannot expandSKILL.mdandCLAUDE.mdshow the reply line as it is now actually generatedCLAUDE.mdno longer claims the skill directory is self-contained — that was backwards. The symlink exists to keep one source of truth and dangles if that directory is copied alone;install.shis the supported path.Type
Checklist
python3 cc_peer.py listworks locallypython3 cc_peer.py list --host <a real host>works over SSH--dry-runresolves a target without posting anythingVerified against
v2.1.263 — 27/27 passing locally on macOS 26 (Python 3.13). CI covers the matrix.
Notes
Not addressed here, and worth deciding separately:
install.shundercurl | shsetssrc_dir=$PWDbecause$0issh, so an unrelatedcc_peer.pyin the current directory would be installed instead of the downloaded one. It needs a different fix than a quoting change — probably refusing the local-copy path when$0is not a real file.