Repository navigation
fix: bound design tweak startup log reads - #14949
Conversation
Co-authored-by: leonlaiyc <276034861+leonlaiyc@users.noreply.github.com>
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the copied PEM anchors ( Suggestions
[DESIGN-REVIEWED] 39ef139 Description read[DESCRIPTION-READ] 441afff03ca04f4aca51539e43da7eea7884f02974fa50a514fbb1c1ce471082 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 (Fable 5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS
Not justified as shipped
What this change shipsInventory (7 items) — 5 justifiedIntent: FIX — a failed dev-server launch's diagnostic tail must stay memory-bounded and never carry a printed credential to the dashboard (linked #8163/#14285; class pinned by
No unfixed siblings: grep [FIRST-PRINCIPLES-REVIEWED] 39ef139 Description read[DESCRIPTION-READ] 942cba8ce589378f253ddd8fcbf96f2fe3bd0a0f0a94df63ca398cd7b9f3e391 That sha256 names the PR description this verdict read. Recompute it with |
GPT 5.6 Review — ✅ human override acceptedHuman judgment by @iamwhatever overrides the GPT 5.6 finding for [GPT-OVERRIDE] 39ef139 This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
Opus 5 Review — ✅ no blocking findingsReviewed Review detailsNon-blocking: one prose/code contradiction — FINDING — src/kiro_crew/apps/builtins/design_tweak/backend/server.py:720 — the docstring states the END-mask fires only [OPUS-REVIEWED] 39ef139 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
907ae39 to
08c018d
Compare
Read the last 64 KiB of the failed-launch log into one buffer and redact it in a single pass, replacing the fixed-chunk StreamRedactor loop. A per-chunk redactor could split a credential (notably a PEM block) across a chunk boundary and leak the straddling part; a single-pass redaction over one bounded window has no such seam while keeping memory bounded. Co-authored-by: leonlaiyc <276034861+leonlaiyc@users.noreply.github.com>
08c018d to
39ef139
Compare
|
/ai-review override gpt 39ef139: The orphaned-PEM leak needs a dev-server log over 64 KiB whose PEM header sits above the window start and whose in-window head opens with encrypted-PEM metadata (Proc-Type/DEK-Info/blank), so the leading-body scan stops at run=0, no END is in the window, and a later secret's redaction shrinks the tail below 800 chars. The guard already drops multi-line base64 bodies and masks through the first END. Security-class, strictly safer than main; skipping the metadata is a follow-up. |
Human judgment recorded@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
chenmingwei23
left a comment
There was a problem hiding this comment.
Bulk approve: readiness passed, board green, no outstanding changes requested.
Supersedes #14285 and #8163 by @leonlaiyc (original head is a fork; this in-repo branch carries the identical commit so CI + the same-repo review lanes can run and the PR can be driven to green). No code change vs #14285 — same head
907ae39590972041c6eab7989eae4d40d8c2e97e.Problem / Motivation
Goal: A credential a failing dev server printed never reaches the dashboard, and the diagnostic read that carries the failure stays memory-bounded.
When an owned project's dev server fails to start, the design-tweak backend attaches the tail of the dev-server log to the error it returns. It did this with
log.read_text("utf-8", errors="replace")[-800:], which reads the entire log into memory before slicing off the last 800 characters. A child process that emits a very large amount of output to that log forces the parent to load the whole file just to keep the last 800 characters.Why it matters
The diagnostic read size is chosen by whatever the child writes, not by the parent, so a noisy dev server can make the failure path allocate memory proportional to the full log when only a bounded tail is used. The same failed-launch tail is returned to the dashboard, so a credential the dev script printed before dying must not survive into it — including a multi-line private key whose
-----BEGIN ... PRIVATE KEY-----header sits far above the retained tail.Not a goal
redact_via_context, which delegates to that floor on a standalone build and additionally applies a loaded companion's credential policy when one is composed.What changed (motivation → approach → change)
read_text(...)[-800:]reads everything, then discards all but the tail, and the tail is unredacted. Bounding before redaction would also sever a credential whose opening anchor precedes the window (a PEM body with no visible header is not recognised by the header-anchored redactor)._read_dev_log_tail(log)insrc/kiro_crew/apps/builtins/design_tweak/backend/server.pyreads at most_DEV_LOG_READ_WINDOW(64 KiB) bytes from the end of the log into one buffer, redacts that whole buffer in a singleredact_via_contextpass, and keeps the last_DEV_LOG_TAIL_CHARS(800) characters.redact_via_contextdelegates to the URL-then-credential floor on a standalone build and also applies a composed companion's credential policy when one is loaded. On a mid-file (truncated) read the window's start is untrusted, so_drop_truncated_window_head(window)first discards the partial first line and then masks through the first-----END ... PRIVATE KEY-----marker in the window, so a key body whoseBEGINheader sat above the window start cannot reach the tail even when a later full PEM follows. Memory stays bounded by the window, the single pass sees a PEMBEGINheader and its body together so the body is scrubbed even when the header sits above the retained tail, and there is no chunk boundary a credential could straddle to escape redaction.Backwards compatibility
Compatible: the returned value is still at most 800 characters of the log's end. What changes is that the read is memory-bounded (a 64 KiB window rather than the whole file) and the text is redacted in one pass before it is returned, so a credential in the tail — or one whose anchor sits above the tail but within the window — is scrubbed rather than surfaced.
Tests
Added in
test/test_design_tweak_devproc.py:test_process_exit_reads_only_a_bounded_log_tail: a large payload yields a tail bounded to_DEV_LOG_TAIL_CHARS.test_process_exit_redacts_credentials_from_the_log_tail: a dying dev server prints an AWS-shaped access key; the raw credential is absent from the returned tail.test_process_exit_redacts_a_key_whose_header_precedes_the_tail: a PEM key whoseBEGINheader sits far above the retained tail is still scrubbed from the body — the case a window-over-the-end read would miss.test_process_exit_redacts_a_key_straddling_the_read_window_edge: with the window shrunk below the log size, a PEM whose header lands just inside the window start is still scrubbed — the single pass has no seam where the old per-chunk redaction could split header from body.test_process_exit_masks_a_key_body_bisected_by_the_window_start: a key whoseBEGINheader fell before the window leaves an anchorless body at the window start; the truncated-head drop masks through the unmatchedENDso the body never reaches the tail.test_process_exit_masks_an_orphan_body_before_a_later_full_pem: an orphaned body (noENDof its own) followed by a complete PEM — so the window's firstBEGINprecedes its firstEND— is still masked, because the head drop masks through the firstENDregardless of any laterBEGIN.Manual verification
N/A — unit coverage sufficient. The change is a bounded-memory, single-pass redacted refactor of the diagnostic read with tests that lock in the bound and the redaction (including the header-above-tail and window-edge cases).
Related Issues
Replaces #8163 by @leonlaiyc.
Pattern harvest
Not generalizable: this is a one-off — a single diagnostic read that sliced a tail out of a full-file read and returned it unredacted, and whose fix must stay memory-bounded while still seeing a credential's opening anchor. The redaction primitive already exists; this call site now reads one bounded window and redacts it once through
redact_via_context(the floor on a standalone build, plus a composed companion's policy when loaded). The existingtest/test_core_path_redact_before_bound.pyalready pins the wider "bounded slice before redaction" class.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)