Skip to content

fix: replace the host name in diagnostics bundle members - #31159

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/28485-scrub-hostname
Nov 7, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/28485-scrub-hostname

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A diagnostics bundle no longer carries the machine's host name, so a user can attach it to a public issue without naming their machine.

kirocrew doctor --bundle and the in-app Report a Problem flow build a zip the user drags into a public GitHub issue. Two of its members, the loop-stall dump header (# PID: <pid> @ <pid-domain> ...) and the last-healthy-boot marker, carry the PID domain, which starts with socket.gethostname(). The bundle scrubs credentials and collapses home paths to ~, but leaves the host name in clear text.

Why it matters

The issue body the bundle pre-fills says "N path(s) collapsed", so a reader can fairly assume the zip is anonymised. On a work machine the host name often carries the user's name, an asset tag or the organisation, and it lands in a public attachment.

Not a goal

  • Changing what the crash-dump writer records locally, or how the PID-ownership check reads it.
  • Redacting other machine identifiers (IP addresses, other hosts' names).
  • Names this machine had in an earlier gateway process (a renamed host, or a laptop whose network name changed before an older dump was written); this covers the current name and the one this process recorded.

What changed (motivation → approach → change)

Symptom: a bundle's crash-dump members show the host name. Cause: the bundle scrub in diagnostics.py (_scrub_bundle) knows credentials and home paths, but not the host name the dump writer puts into every PID domain.

Change: the scrub replaces the host name with <host> in every text member, the user's note included. It replaces the live name, the name this gateway recorded at boot (the writer caches its PID domain, so the two differ after a network change), each in full and in its short form before the first .. A name of 6 characters or more is replaced wherever it appears, whatever precedes it (an escape, an ANSI control sequence, a percent-encoded byte), and only a name-character after it stops a match, so jane-laptop2 stays. A shorter name is replaced only as a whole word, so a generic short host name does not rewrite ordinary words, and a bare \ does not count as a word boundary, so a one-letter name never eats the t of a serialized \t. The pass runs only after the credential scrub and the home collapse, so a host name that is also a word a credential rule keys on cannot hide that credential. A long name is matched anywhere, so a control byte the scrub strips cannot hide it; a short name joined onto a word that way is a known gap, tracked with the other surviving spellings, and names from earlier gateway processes, in #32005. The replacements count with the path collapses, and the issue-body tally reads "path(s) collapsed to ~ or host name(s) replaced". The local dump files keep the real domain.

Docs: troubleshooting.md says the bundle shortens home paths and replaces the current host name, and that an older name or another spelling can remain, so the user should look through the zip before attaching it, and the FeedbackTrackerProvider.report_issue_url docstring in interfaces_runtime.py says path_collapses includes host-name replacements.

Backwards compatibility

Compatible: only the bundle copies change; no file format, API or config key does, and the local crash-dump files still hold the real PID domain.

Reader: src/kiro_crew/dashboard/crash_dump_store.py:_dump_owner -- release -- it reads the local dump header, which this change does not touch; only the bundle copy is rewritten (test/test_crash_dump_store.py)

Tests

  • test/test_diagnostics.py::test_bundle_replaces_the_host_name_crash_records_carry writes a loop-stall dump header and the last-healthy-boot marker with the writer's boot-time domain, plus a log line naming the live host in another case. It checks that no member of the zip carries either name, full or short, that jane-laptop2 survives, and that the replacements are counted.
  • test/test_diagnostics.py::test_bundle_replaces_the_host_name_after_an_escaped_newline_or_tab: the log line {"stdout":"boot\njane-laptop\n","err":"a\tjane-laptop"} comes out with <host> in both places. It is red without the escape boundary and passed 3 runs in a row.
  • test_bundle_replaces_the_host_name_after_a_form_feed_or_a_color_code and ..._after_any_escape_or_control_sequence: serialized \f, \x1b, \u001b, \u001b[?25h and raw ANSI codes before the name.
  • test_bundle_replaces_a_host_name_joined_on_by_a_stripped_control_character: a real form feed, vertical tab or ANSI code before the name.
  • test_a_long_host_name_goes_inside_a_word_and_a_short_one_only_whole: %2Fjane-laptop and xjane-laptop are replaced, jane-laptop2 stays; the short name box is replaced alone but not in boxes or inbox.
  • test_a_one_letter_host_name_leaves_serialized_escapes_intact: with host t, failure\t stays intact while \nt becomes \n<host> (red when a bare backslash counts as a boundary).
  • test_the_host_pass_before_redaction_keeps_a_credential_redacted: a token in a URL on the host is still redacted.
  • test_a_host_name_never_defeats_credential_redaction: a host named authorization, bearer or token leaves an Authorization header, a bare Bearer token and a token= query value redacted (red when the host pass runs before the credential scrub).
  • Each new case is red on the head before its fix and passed 3 runs in a row.
  • Determinism (first case): 20 runs at -n0; 10 at -n 4 --dist loadgroup --max-worker-restart=2 with test/test_diagnostics_kiro_log_layout.py and test/test_windows_logs_and_diagnostics.py as co-tenants; test/test_diagnostics.py in shuffled order (seed 16803). All green.
  • scripts/local-gate.py on the first head: the related backend tests (5970 passed) and the related frontend tests (492 files) pass. On this head: test_diagnostics.py and the seven test files that import the changed modules plus test_crash_dump_store.py (786 passed), flake8, isort and mypy on the changed files.

Proof: PROVEN test/test_diagnostics.py::test_bundle_replaces_the_host_name_crash_records_carry, test/test_diagnostics.py::test_bundle_replaces_the_host_name_after_an_escaped_newline_or_tab, test/test_diagnostics.py::test_bundle_replaces_the_host_name_after_a_form_feed_or_a_color_code, test/test_diagnostics.py::test_bundle_replaces_the_host_name_after_any_escape_or_control_sequence[x-escape], test/test_diagnostics.py::test_bundle_replaces_the_host_name_after_any_escape_or_control_sequence[u-escape] (head 2998d288b511)

Manual verification

N/A — unit coverage sufficient: the test drives collect_bundle end to end over real files written in the writers' formats.

Screenshots / video

N/A — the diff touches no frontend surface.

Related Issues

Closes #28485

Sibling sweep

Swept: git grep -nE "gethostname(|platform.node(" -- src/
Sibling: src/kiro_crew/snapshot_build.py:460 -- not affected -- a snapshot is a private backup the operator restores, never a public attachment
Sibling: src/kiro_crew/portability_stream.py:252 -- not affected -- an export archive goes to the operator's own other install, not a public issue
Sibling: src/kiro_crew/dashboard/handlers_system.py:324 -- not affected -- shown on the owner's own dashboard and never packed into the bundle

Pattern harvest

Not generalizable: the diagnostics bundle is the one artifact built for a public issue, and its single scrub path now covers the host name.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 06:55
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 06:55
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 07:13
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/28485-scrub-hostname branch from f1051ef to b8ec891 Compare November 6, 2026 11:20
@bolichen97

bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/diagnostics.py and files beside the ones this PR touches since this head went green (0c56b24 -> 083e552); the change itself is identical. CI re-running.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 849188d9be2afbaba25cad5d2a374e27f6c7505a touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 849188d9be2afbaba25cad5d2a374e27f6c7505a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the host pass runs inside the bundle scrub, after credential redaction, and it removes nothing.

Notes

  • Some machines use a generic host name of six or more characters, such as localhost or ubuntu. On those machines _HOST_ANYWHERE_MIN will replace every occurrence anywhere in the bundle, including inside words. Text like localhost:8765 loopback URLs and OS strings in versions.txt then reads as <host>, which makes the bundle less useful for diagnosis without protecting any identity. One simple fix is to skip a small set of known generic names. Reverting would also undo this cleanly.

[DESIGN-REVIEWED] 849188d

Description read

[DESCRIPTION-READ] 8f3b76284e97086dbfc89c8c851edbc1d4470dea8ffbb52e4e8dcda66c22f6e1

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 849188d9be2afbaba25cad5d2a374e27f6c7505a — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The bundle scrub is the one place that sanitizes a public attachment, and the fix goes in that scrub. #28485 supplies the provenance. Grepping gethostname|<host> in the redaction and diagnostics modules found no existing host-name scrub.

What this change ships

Inventory (5 items) — 4 justified

Intent: let a user attach a diagnostics bundle to a public issue without it naming their machine. This is a FIX.

  1. Every text member of the bundle (crash dumps, the healthy-boot marker, logs, the user's note) shows <host> instead of the live host name or the one recorded at boot — justified
  2. A name of 6 or more characters is replaced anywhere it appears; a shorter name only as a whole word, so ordinary words survive — justified
  3. The issue-body tally reads "path(s) collapsed to ~ or host name(s) replaced", and the count goes into the existing path_collapses field — justified
  4. troubleshooting.md tells the user an older name or another spelling can remain, so check the zip before attaching it — justified
  5. The a-ratchet-may-only-tighten rule in AUTOSDE.yaml now allows a capability skipif on a new test, with a pointer in testing-conventions.md — undeclared; same text as fix: allow a capability skipif on a new test under the ratchet rule #31845, already on base (diff-base drift)

[FIRST-PRINCIPLES-REVIEWED] 849188d

Description read

[DESCRIPTION-READ] 2753d985e54afca7bcbe9671a2d435a15d7355209fcecb46a91daa47a3b4786f

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 849188d9be2afbaba25cad5d2a374e27f6c7505a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 849188d

Verdict parsed from the review's SHA-scoped output markers for commit 849188d9be2afbaba25cad5d2a374e27f6c7505a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 849188d9be2afbaba25cad5d2a374e27f6c7505a false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on 849188d9be2afbaba25cad5d2a374e27f6c7505a; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- AUTOSDE.yaml:1190 -- New skip exemption weakens an existing blocking rule

skipif on a test this diff adds, and on that test alone (not one
Trigger: The review workflows load AUTOSDE.yaml from the base branch; this added Allowed branch exempts capability-gated skips on new tests from the base rule’s prohibition on newly added skips.
Outcome: Subsequent reviews explicitly permit skipped-test changes that the existing blocking rule requires flagging. Weakening a blocking rule is itself prohibited.
Anchor: a-ratchet-may-only-tighten
Fix: Remove the new exemption and its dependent documentation references, preserving the existing blocking policy.

[BLOCK-MERGE-DOWNGRADED] 849188d
[GPT-REVIEWED] 849188d

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — rung: LOW. Nothing would be prevented by blocking this PR.

  • The exemption at AUTOSDE.yaml:1189-1198 was added by fix: allow a capability skipif on a new test under the ratchet rule #31845 (7a80979), which is this PR's merge base and already on main. git diff 7a80979 HEAD touches only diagnostics.py, troubleshooting.md, interfaces_runtime.py and test_diagnostics.py. The .review-base-rules/AUTOSDE.yaml snapshot is older than fix: allow a capability skipif on a new test under the ratchet rule #31845, so the diff only looks like this PR added it.

  • The anchored rule's file-patterns (.review-base-rules/AUTOSDE.yaml:1142-1160) don't include AUTOSDE.yaml, so its blocking: true flag doesn't cover this file. There is no recovery path to name, because this PR has no defect here. The only fix would be for this unrelated diagnostics PR to revert a maintainer-merged main commit, and that costs far more than the zero harm the block prevents.

    [ADJUDICATION] 849188d total=1 uphold=0 downgrade=1
    DOWNGRADE F1 AUTOSDE.yaml:1190 reason=disproportionate-remedy
    [GPT-ADJUDICATED] 849188d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 849188d9be2afbaba25cad5d2a374e27f6c7505a false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/28485-scrub-hostname branch from b8ec891 to 3cd2d67 Compare November 6, 2026 13:01
@bolichen97

bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/lesson_validation.py and src/kiro_crew/member_essential_context.py (same package directory as src/kiro_crew/diagnostics.py) since this head went green (083e552 -> 07ab5da); the change itself is identical. CI re-running.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/28485-scrub-hostname branch from 3cd2d67 to 7de3c21 Compare November 6, 2026 14:11
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/cli_commands_cron.py (same package directory as src/kiro_crew/diagnostics.py) and test/test_config_patch.py (imports a module this PR touches) since this head went green (07ab5da -> 1ece983); the change itself is identical. CI re-running.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 6, 2026
@bolichen97 bolichen97 reopened this Nov 7, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 7, 2026
@bolichen97
bolichen97 force-pushed the fix/28485-scrub-hostname branch from 8fe6202 to 341034a Compare November 7, 2026 03:05
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 7, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485
@bolichen97
bolichen97 force-pushed the fix/28485-scrub-hostname branch from 341034a to 849188d Compare November 7, 2026 05:35
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026
@chenmingwei23
chenmingwei23 merged commit 70fcc4e into main Nov 7, 2026
101 of 109 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/28485-scrub-hostname branch November 7, 2026 06:26
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
buluoray added a commit that referenced this pull request Nov 8, 2026
A diagnostics bundle is meant to be dragged into a public issue, but
its loop-stall dump headers and last-healthy-boot marker carry the PID
domain, which starts with the machine's host name. The bundle scrub
removed credentials and collapsed home paths, never the host name.

The bundle scrub now replaces the live host name and the one the dump
writer recorded at boot with <host>, in full and in short form, as a
whole segment only, and counts the replacements with the path
collapses. Local crash-dump files keep the real domain.

Closes #28485

(cherry picked from commit 70fcc4e)

Original author: @bolichen97
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.

Diagnostics bundle: loop-stall crash dump header carries the machine hostname unredacted

2 participants