Skip to content

Harden display sanitizing, retry cap, and host create --code-lifetime - #198

Merged
jasikpark merged 1 commit into
mainfrom
fix/sanitize-hidden-format-chars
Nov 21, 2026
Merged

jasikpark merged 1 commit into
mainfrom
fix/sanitize-hidden-format-chars

Conversation

@jasikpark

@jasikpark jasikpark commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Fixes from a review of src/, each checked against the code before changing it.

  • Hidden format characters in names. sanitize_for_display replaced only control characters (Cc). Bidi overrides, isolates and marks and zero-width spaces passed through, so a host named web\u{202E}dorp displayed as "webprod" in dn host delete's confirmation prompt. They now become spaces like control characters do; ZWJ and ZWNJ are kept. The proptest generator now draws these characters, and two unit tests pin the disguised name and a ZWJ emoji sequence.
  • Retry cap includes jitter. Retry-After was clamped to 60s and then up to 50% jitter was added on top (up to 90s per retry). MAX_RETRY_DELAY_SECS now clamps the total.
  • host create --code-lifetime range. Same 60..=604800 parser as host enroll-code; --code-lifetime 10 now exits 2 with ERR_USAGE before credentials are resolved.
  • Nits: parse_tag doc, #[expect(dead_code, reason = …)] on AuthLock, and a reviewer-facing paragraph dropped from render_host_create_human's doc (AGENTS.md comment rules).

Considered and not changed: a suspected failure of tag edit --description on tags without a description. A live dn tag list --json shows the API returns "description": "" rather than omitting the field.

Left for discussion: whether an unreadable/newer-version auth.json should block a DEFINED_API_KEY call (the current doc says skipping it is intended), and how write_private should treat a dangling symlink at auth.json.

Validation: cargo fmt --check, cargo clippy --locked --all-targets -D warnings, cargo test --locked (all pass locally). cargo mutants -D <this diff>: 16/16 caught. Two things cargo-mutants can't mutate are pinned by their own tests, each checked to fail when its code is removed: every character in is_hidden_format's list (plus ZWJ/ZWNJ kept), and the --code-lifetime range on both host create and host enroll-code with no request sent.

🤖 Generated with Claude Code

sanitize_for_display replaced only Cc control characters, so bidi
overrides/isolates/marks and zero-width spaces from API-supplied names
reached tables, detail views and the delete prompt; a host named
"web\u{202E}dorp" displayed as "webprod". They are now replaced with
spaces too; ZWJ/ZWNJ stay for emoji sequences and scripts that need them.

Retry-After was capped at 60s before jitter was added, so one retry could
wait up to 90s. MAX_RETRY_DELAY_SECS now caps the total.

host create --code-lifetime accepted any u64; it now has the same
60..=604800 range as host enroll-code, so an out-of-range value is a
local ERR_USAGE instead of an API error after resolving credentials.

Also: parse_tag's doc matches its first-colon split, AuthLock's
dead_code suppression is an #[expect] with a reason, and a
reviewer-directed paragraph left render_host_create_human's doc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jasikpark
jasikpark force-pushed the fix/sanitize-hidden-format-chars branch from a7947b6 to caa75b9 Compare November 21, 2026 20:16
@jasikpark
jasikpark merged commit d1866b9 into main Nov 21, 2026
10 checks passed
@jasikpark
jasikpark deleted the fix/sanitize-hidden-format-chars branch November 21, 2026 20:17
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.

1 participant