Repository navigation
Conversation
log() wrote `message` straight into the log line with no sanitization, unlike the shell-side report_error()/_dispatch_report_skip() equivalents, which already run `tr '[:cntrl:]' ' '` before writing (#599/#618). An embedded newline or other control byte in a logged message -- e.g. an untrusted error string from pipeline/haiku.py -- could corrupt the log line's own structure or forge what looks like a second entry. Mirrors the shell flattening exactly: same character class (ASCII C0 plus DEL, matching POSIX [:cntrl:] under LC_ALL=C), same replace-with-space semantics, applied only to `message` (not `component`), inside log() itself so every caller is covered without sanitizing independently. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…g Unicode-linebreak gap for curate Self-review finding (Explore reviewer): log()'s docstring still described `message` as untouched free-form text after the previous commit added control-character flattening -- update it to say so. Also logs a non-blocking oss:auditor finding to trap.d/: the new `_CONTROL_CHARS` regex (ASCII C0 + DEL, mirroring the shell's `tr '[:cntrl:]' ' '`) doesn't flatten U+0085/U+2028/U+2029, which Python's str.splitlines() also treats as line breaks. No in-repo consumer parses the log with splitlines() today, so this ships as a logged gap for /oss:curate to weigh rather than widening this diff's scope. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pipeline/log.py'slog()wrotemessagetomemory-*.logwith no control-character flattening, unlike the shell-side equivalents (report_error()/_dispatch_report_skip(), which already runtr '[:cntrl:]' ' 'before writing -- #599/#618). An embedded newline or other control byte in a logged message -- for example an untrusted error string -- could corrupt the log line's own structure or forge what looks like a second entry.Fixes this by adding a module-level
_CONTROL_CHARS = re.compile(r"[\x00-\x1f\x7f]")(the same ASCII C0 + DEL class the shell'strunderLC_ALL=Calready flattens) and applying it tomessageinsidelog()before building the line. Scoped tomessageonly, notcomponent, matching the shell precedent.Three new tests in
tests/test_log.py: a red-then-green assertion that a control character is flattened, a positive control proving printable text still passes through untouched, and a red-then-green assertion that an embedded newline cannot forge a second log line.Self-review
Two reviewers ran concurrently against the fix commit.
An Explore-model reviewer found log()'s docstring hadn't been updated to describe the new flattening -- fixed in a follow-up commit. It separately observed that the issue's own framing overstates the Python-side caller count (one external caller, not 'every caller... repo-wide') -- noted, not acted on, since fixing inside log() is still the correct design regardless of count.
An oss:auditor reviewer ran a 4-class sweep and found a residual gap: three Unicode line-break codepoints outside the flattened ASCII range still read as a second line to str.splitlines() -- not a regression from the Python port (the shell tr precedent has the identical byte-wise blind spot), logged to trap.d/881.unicode-linebreaks-outside-cntrl.md for curate rather than fixed here. Since no in-repo consumer is exposed to it today, this is non-blocking.
Closes #881
🤖 Generated with Claude Code
[AI-generated]