Repository navigation
fix: replace every spelling of the host name in a diagnostics bundle - #35569
Conversation
a8207cb to
d99560b
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: the new decoded view keeps each character's original span, which fixes the cause of the leaks, and nothing is taken away. Notes
[DESIGN-REVIEWED] 5015b8e Description read[DESCRIPTION-READ] 038987536ef592bd30146ddf5fcfc1a80d4b67b6944aac4f176eeadae65e3fae That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The shipped pieces stay inside the frozen Goal, and each spelling has a test this PR adds that fails on base. The Windows-path handling reads like a pile of guesses about spellings. Notes
What this change shipsInventory (8 items) — 7 justifiedIntent: stop a diagnostics bundle you attach to a public issue from leaking your machine's host name. This is a FIX (#32005).
[FIRST-PRINCIPLES-REVIEWED] 5015b8e Description read[DESCRIPTION-READ] 7786c250679c5a860ab38b6c3ec6b5f3c98d3a55a45cf31218eac3c60063d4f7 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
d99560b to
02ad0df
Compare
|
|
02ad0df to
950f0b1
Compare
|
|
|
|
The red Coverage Gate on 950f0b1 is not from this diff: it flags |
950f0b1 to
456596f
Compare
456596f to
53373a4
Compare
|
53373a4 to
710beac
Compare
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. The host-name pass moves into a new module that matches against both the raw text and a decoded copy that maps each character back to its original position. Hidden-character joins are recorded before the credential scrub, and the replacement still runs after it, so redaction order is kept. I traced the offset mapping, the segment and escape rules, and the join detection against strip_hidden_unicode. Every spelling main replaced is still replaced, except an encoded letter right before a short name ( Tier: 2, held for a person: changes requested. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for this fix. The decoded view with original spans is a clean way to stop chasing spellings one by one. The review found one regression to fix before merge.
src/kiro_crew/diagnostics_host_name.py:53: a short host name (under 6 characters, for examplejane) right after a doubly-escaped\\nor\\tis no longer replaced. This is the usual shape of a tool result nested in JSON inside an ACP or protocol log, for example"text":"{\"stdout\": \"Linux\\njane\\n\"}"or"msg": "line\\tjane"._ENCODEDreads\\first as one escaped backslash, so the view sees\followed bynjane._starts_segmentthen finds no segment start, and the Windows-path pass needs the name right after the backslash. Sojanestays in a bundle meant for a public issue. On main,_replace_host_namereplaces it through its\\(?:x..|u....|[A-Za-z])alternative. We ran both versions on these inputs: main returns<host>, this head returns the input unchanged. Smallest fix: for short names, also count it as a segment start when the original text has an escaped backslash plus an escape letter,x..oru....right before the name (\\n,\\t,\\x1b,\\u001b). That restores main's reading, and over-redacting a rare path folder such asC:\\nboxis the safe direction for a privacy scrub. Please add a test with a doubly-escaped newline and tab before the name. If you prefer to keep the current reading on purpose, could you name this case in troubleshooting.md among the spellings that can remain?
Optional:
src/kiro_crew/docs/troubleshooting.md:32: the new list of names that can remain reads as complete, but some spellings still survive (for example double percent-encoding%2562oxor an HTML entitybox). A short catch-all clause such as "or a less common spelling of it" keeps the warning accurate.src/kiro_crew/diagnostics_host_name.py:280: no test pins the raw-text pass for long names. With that line deleted,open D:\jane-laptop\logs nowpasses through unchanged and all tests stay green. A long-name Windows-path case would pin it.src/kiro_crew/diagnostics_host_name.py:131:_is_strippedcopies the hidden-character rule ofstrip_hidden_unicode. Callingstrip_hidden_unicodeon the matched run keeps one owner for that rule.
7a41ad0 to
485036f
Compare
|
Rebased onto main (7a41ad0 -> 9b2b67d) and fixed the review's regression in 485036f: a short host name right after a doubly serialized escape ( |
The bundle replaced this machine's host name only where it appeared literally. A short name joined onto a word by a hidden character the credential scrub strips (boot<FF>box), a name behind a percent-encoded byte (%2Fbox), a name with an escaped character (jane\u002dlaptop, jane%2Dlaptop), a short name in a Windows path (C:\Users\box) and the other IDNA spelling of the name all stayed readable in a bundle meant for a public issue. The host pass moves to diagnostics_host_name.py and matches on a decoded view of the text in which \uXXXX, \xXX and %XX read as the character they encode and every view character keeps its original span. Joins are read from the member before the scrub, and the replacement still runs after it, so a host name can never hide a credential from its rule. Names followed by -, _ or a digit, the domain after a short name, and names from earlier boots are unchanged. Fixes #32005
A tool result nested in a JSON log line writes a newline as two backslashes and an n, which the decoded view reads as a backslash and a name character, so a short host name right after it was kept. Count a doubly serialized escape before the name as a segment start, as the old literal matcher did, and pin the raw-text pass for long names.
The decoded view reads a nested JSON \\n as a backslash and a letter, so a short host name that starts with an escape letter (or a one-letter one) took the letter of the escape. Apply the same path test the raw backslash pass uses, and stop a serialized backslash from counting as the UNC marker of a path.
7a0a8c8 to
5015b8e
Compare
|
Correction to my earlier comment: it listed |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Re-review on 5015b8e. The earlier change request is resolved. The review read the full diff, ran the new tests and the host, scrub and bundle tests in test_diagnostics.py (all pass), checked that 47 of the new tests fail on the merge-base source, and ran a differential fuzz against main's _replace_host_name. The fuzz found no realistic spelling that main replaced and this head keeps.
Earlier items:
- Short name after a doubly serialized
\\nor\\t: fixed.test_a_short_name_after_a_doubly_serialized_escape_is_replacedpins it, along with the doubly serialized escape-letter and path tests.
- Optional, troubleshooting.md catch-all: fixed ("or a less common spelling of the name").
- Optional, long-name Windows path test: fixed (
test_a_long_name_in_a_raw_windows_path_is_replaced). - Optional, reuse
strip_hidden_unicode: rebutted. That rule depends on a character's neighbours, and a matched run has none. The rebuttal holds.
Security: this rewrites masking logic, and it only widens what becomes <host>. Joined names are found on the raw text but replaced after the credential scrub, so a host name cannot hide a credential. test_a_joined_host_name_keeps_a_credential_redacted pins that order.
Done well: the decoded view keeps each character's original span, so one matcher covers escaped, percent-encoded and UTF-8/UTF-16 spellings. Before, the regex needed another branch for each spelling.
Optional:
diagnostics_host_name.py:392: deleting the\before a non-escape letter hint reds no test, and the name then leaks inopen .\logs\nas. A case such as("open .\\logs\\nas", "open .\\logs\\<host>")would pin it.diagnostics_host_name.py:137: on a member near the 4 MiB cap the pass runs 10 to 18 times slower than main. Skipping the_Viewbuild when a member has no encoded token or hidden character would avoid most of that.- The PR has three commits and the body ticks "At most two". The Proof line also still names head 7a41ad0. A squash merge settles the commit count.
Problem / Motivation
Goal: A diagnostics bundle replaces this machine's host name with
<host>in its escaped, percent-encoded, joined, Windows-path and IDNA spellings, not only where the name is written literally.kirocrew doctor --bundlereplaces the host name in every text member, but only where it appears as written. On a machine namedbox, a log lineboot<form feed>boxreaches the zip asbootbox, because the credential scrub strips the form feed first.%2Fbox,C:\Users\box\,jane\u002dlaptop,jane%2Dlaptopand the punycode form of a Unicode name also survive.Why it matters
The bundle is meant to be attached to a public GitHub issue. A work machine's name often carries its user's name or an asset tag, so each surviving spelling publishes it.
Not a goal
-,_or a digit (jane-laptop-1234.log). The match stops there on purpose, becausejane-laptop2can be another machine.<host>.corp.example). Looking up the fully qualified name can block on DNS.localhostbeing replaced in ordinary text, and the macOS computer name (Jane's MacBook Pro), which comes from a different source.What changed (motivation → approach → change)
The old matcher compared literal spellings and kept a growing list of prefixes (
\n,\x1b,[32m) to recognise where a short name starts. Each review round of #31159 found another one.\u002d,\x2d,%2D,%2F,%62\n,\tand other serialized escapestof\tC:\Users\box\,\\box\share\inside a Windows path (its first letter makes no escape, a separator follows it, or the text before it on the same quoted run shows a path: a drive,\\, a collapsed~\, or a\before another letter), so\nAsin serialized text stays a newline escapeboot<FF>box,boot<ZWSP>boxbücher-pc/xn--bcher-pc-65a/XN--BCHER-PC-65Axn--labelb%C3%BCcher-pc,b\xc3\xbccher-pc,jane-\ud83d\ude00-pc%XXand\xXXas UTF-8,\uXXXXas UTF-16), so one encoded character is one characterThe host pass moves from
diagnostics.pyintosrc/kiro_crew/diagnostics_host_name.py, which keepsdiagnostics.pyunder the 1,600-line split point.src/kiro_crew/docs/troubleshooting.mdnow names the spellings that are replaced and the ones that can remain.Backwards compatibility
Compatible: the bundle replaces more spellings of the host name; every spelling replaced before is still replaced.
Removes nothing: the private
_replace_host_namehelper moves todiagnostics_host_name.replace_host_names; its only caller,diagnostics._scrub_bundle, moves with it.Tests
test/test_diagnostics_host_name.pydrivesdiagnostics._scrub_bundlefor each spelling: form feed, vertical tab and ZWSP joins (an encoded name and a name joined on both sides included), a 24-bit color code before the name,%2F,%62, Windows, UNC and JSON-escaped paths for a short name;\u002d,\u002D,\x2d,%2D, upper case and%6Afor a long name; both IDNA directions, an upper-casexn--name, a Unicode name as UTF-8%XXand\xXXbytes, and a name outside the Basic Plane as a JSON\uXXXXsurrogate pair. A stray byte or a lone surrogate still decodes, and a Unicode case variant (İ,ı,ſ) beside a joined short name does not abort the scrub. Many distinct joins in one member are each replaced, and a join keeps only the last 16 characters of the word in front, which keeps the pass linear in the member: 20,000 joined records take 0.07 s. It also pins what must survive (boxes,inbox,my-box,vm_box,1box,toolbox, a serialized\twith a one-letter name), that a credential next to a joined name is still redacted, and the issue's reproduction throughcollect_bundle. The existing host-name tests intest/test_diagnostics.pypass unchanged.Proof: PROVEN test/test_diagnostics_host_name.py::test_a_short_host_name_is_replaced_in_every_spelling[form-feed], test/test_diagnostics_host_name.py::test_a_short_host_name_is_replaced_in_every_spelling[vertical-tab], test/test_diagnostics_host_name.py::test_a_short_host_name_is_replaced_in_every_spelling[zwsp], test/test_diagnostics_host_name.py::test_a_short_host_name_is_replaced_in_every_spelling[joined-encoded], test/test_diagnostics_host_name.py::test_a_short_host_name_is_replaced_in_every_spelling[joined-twice] (head 7a41ad0)
The new tests are pure string checks on monkeypatched host names, with no clock, port or ordering dependence.
Manual verification
N/A — unit coverage sufficient: the bundle path is exercised end to end through
collect_bundlein the tests.Related Issues
Fixes #32005
Sibling sweep
Swept: git grep -n -e "gethostname()" -- src/kiro_crew
Sibling: src/kiro_crew/apps/builtins/issue_radar/backend/agent_tools.py:86 -- not affected -- it scrubs model-written crew prose, not serialized logs, so escaped spellings do not arise there
Pattern harvest
Not generalizable: matching on a decoded view with original spans is specific to scrubbing an identifier out of serialized log text.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)