Skip to content

test: add a unit suite and CI, and fix what it caught - #13

Merged
abruption merged 2 commits into
mainfrom
chore/10-tests-and-cleanups
Sep 7, 2026
Merged

abruption merged 2 commits into
mainfrom
chore/10-tests-and-cleanups

Conversation

@abruption

Copy link
Copy Markdown
Owner

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 shellcheck on the installer.

What writing them caught

is_tailnet_address accepted 100.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.sh disables globbing around the --host loop, so --host '*' cannot expand
  • SKILL.md and CLAUDE.md show the reply line as it is now actually generated
  • CLAUDE.md no 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.sh is the supported path.

Type

  • feat
  • fix
  • docs
  • chore / refactor / test / perf

Checklist

  • python3 cc_peer.py list works locally
  • python3 cc_peer.py list --host <a real host> works over SSH
  • --dry-run resolves a target without posting anything
  • Commits follow Conventional Commits
  • Docs updated if behavior changed (README / SKILL.md / CLAUDE.md)
  • No secrets, tokens, or session keys in the diff

Verified 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.sh under curl | sh sets src_dir=$PWD because $0 is sh, so an unrelated cc_peer.py in 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 $0 is not a real file.

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.
@abruption
abruption merged commit 5ef9ef6 into main Sep 7, 2026
6 checks passed
@abruption
abruption deleted the chore/10-tests-and-cleanups branch September 7, 2026 09:25
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.

Correctness cleanups and the missing test/CI baseline

1 participant