Repository navigation
fix(sanitize): redact secrets inside escaped JSON - #134
Conversation
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): fix(sanitize): redact secrets inside escaped JSON. Tiny Sweeper completed its review; deterministic results follow. Review snapshot
Completeness: Complete What changedThe credential scrubber now recognizes labelled secrets embedded in escaped/stringified JSON: the key suffix optionally accepts an escaped quote, a new value branch matches `\"…\"`-quoted values, and the regex captures are named. The callback reads `op`, `bare`, and the value through `dq`/`sq`/`edq`/`bare`, with `quoted` determined by whether the bare group matched; the rest of the redaction logic is described as unchanged. A test was added for the escaped-JSON case. Features
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
Summary
What was wrong.
scrub_credentialsdid not redact a labelled secret inside stringified JSON. In{"body":"{\"password\":\"hunter2secret\"}"}the key is followed by\", but the key/value regex only allowed an optional"or'right after the key. A JSON body embedded as a string (common in tool results and provider error payloads) therefore came back with the password in clear.Fix. One regex change, in the same key/value regex:
(?:\\?["'])?, so an escaped closing quote after the key is accepted.\"…\".op,dq,sq,edq,bare), and a value is "quoted" whenever it is not the bare alternative. The rest of the redaction logic is unchanged.Known limit: a value that itself contains an escaped quote (
\\\") inside stringified JSON is redacted only up to that quote.Related issue
None.
API or behavior changes
No public API change. Labelled secrets inside escaped/stringified JSON are now redacted (first four characters kept, as for other quoted values).
Validation
cargo fmt --all -- --check. I ran rustfmt (edition 2024) on the touched files only; CI runs the full check.cargo clippy --all-targets --all-features -- -D warnings. Not run locally; CI runs it.cargo build --all-targets --all-features. Not run locally; CI runs it.cargo test --all-features. I ran thesanitizemodule tests; CI runs the full suite.Tests
Added
secret_in_escaped_json_is_redactedtosanitize_tests.rs.leaked: {"body":"{\"password\":\"hunter2secret\"}"}cargo test -p tinyinference-core --lib sanitize: 35 passed, 0 failed.Documentation
No docs change. The regex doc comment lists the new groups and the known limit.
Checklist
#[allow(...)],#[ignore], or relaxed lints.envcontents in the diff or the description