feat(ssh): add collect-host-public-key method (#917) #88
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-917/collect-host-public-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
collect-host-public-keymethod to@swamp/sshthat reads a remote host's SSH public key file over SSH, validates it as a single OpenSSH public key line, computes its SHA256 fingerprint, and emits a structuredhostPublicKeyresource per host.exec/script/copy.hostKeyPathvia POSIX single-quoting for safe command construction.2026.07.02.1with upgrade entry. Updates manifest methods table and README with full documentation.Closes swamp-club#917
Test plan
CollectHostPublicKeyArgsSchema: defaults, custom path, empty rejection, hosts required)ssh_test.ts): successful collection with field verification, customhostKeyPath, empty output, multi-line output, private key rejection, invalid algorithm, non-zero exit with resource-before-throw, multiple hostsdeno check,deno lint,deno fmt --check,deno install --frozenall clean2026.06.27.1→2026.07.02.1viaswamp extension source add🤖 Generated with Claude Code
Code Review
Blocking Issues
None.
Suggestions
atobcan throw an opaqueDOMExceptionon malformed base64 (operations.ts,computeFingerprint). If a remote file contains a syntactically correct key line (passesparsePublicKeyLine) but its base64 field is not valid base64,atob(base64Data)throws aDOMExceptionwith no host name or context. A small try/catch that rethrows as a namedError(e.g.collect-host-public-key failed on ${host}: key base64 data is not valid) would make failures easier to diagnose.Dead guard after
throwOnHostFailures(operations.ts,runCollectHostPublicKey). Theif (r.exitCode !== 0 || r.error) continue;check in the second loop is unreachable whenthrowOnHostFailuresuses fail-fast semantics (which thenon-zero exit throws via throwOnHostFailurestest confirms). The guard is harmless and matches the defensive style elsewhere in the file, but removing it or moving it beforethrowOnHostFailureswould make the control flow more readable.The implementation is solid overall.
posixQuotecorrectly handles single-quote escaping, the private-key detection (-----BEGIN) guards against the most dangerous misconfiguration, the SHA-256 fingerprint computation matchesssh-keygen -lfoutput, and the temp-key cleanup is correctly in afinallyblock. Test coverage is thorough: schema defaults, rejection cases, multi-host success, and non-zero-exit behaviour are all exercised with mock executors rather than live SSH connections.