Skip to content

fix(sanitize): keep a short redacted value idempotent - #135

Merged
M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/scrub-short-value-idempotent
Oct 23, 2026
Merged

M3gA-Mind merged 1 commit into
tinyhumansai:mainfrom
M3gA-Mind:fix/scrub-short-value-idempotent

Conversation

@M3gA-Mind

Copy link
Copy Markdown
Collaborator

Summary

What was wrong. scrub_credentials was not idempotent for short quoted values. A quoted value of four characters or fewer is replaced whole, so {"token":"ab"} becomes {"token":"*[REDACTED]"}. A second pass then saw *[REDACTED] as a new quoted value, kept its first four characters and appended another marker: {"token":"*[RE*[REDACTED]"}. Text that is scrubbed more than once (for example a tool result that is scrubbed again when it is re-sent or logged) got progressively mangled. The existing "already redacted" guard only covered bare values, where the marker follows the kept prefix.

Fix. The existing guard now also skips a value that already starts with *[REDACTED].

Related issue

None.

API or behavior changes

No public API change. A second scrub_credentials pass leaves an already-redacted short quoted value unchanged.

Validation

  • N/A: cargo fmt --all -- --check. I ran rustfmt (edition 2024) on the touched files only; CI runs the full check.
  • N/A: cargo clippy --all-targets --all-features -- -D warnings. Not run locally; CI runs it.
  • N/A: cargo build --all-targets --all-features. Not run locally; CI runs it.
  • N/A: cargo test --all-features. I ran the sanitize module tests; CI runs the full suite.

Tests

Added short_quoted_value_scrubs_idempotently to sanitize_tests.rs.

  • Before the fix: FAILED, left: "{\"token\":\"*[RE*[REDACTED]\"}", right: "{\"token\":\"*[REDACTED]\"}"
  • After the fix: PASSED.

cargo test -p tinyinference-core --lib sanitize: 35 passed, 0 failed.

Documentation

No docs change. The guard's comment covers the new case.

Checklist

  • The change is focused on one logical change
  • No new #[allow(...)], #[ignore], or relaxed lints
  • No secrets, tokens, or .env contents in the diff or the description

@tinysweeper

tinysweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

Reviewed head: 47e3eb624cf0a6472af1644e65f443ee0956946f

Verdict: Ready for maintainer review · Priority: none
Coverage: Reviewed 2 of 2 files.
Pull request purpose (title): fix(sanitize): keep…

Diagnostics and supporting details

Full summary

Pull request purpose (title): fix(sanitize): keep a short redacted value idempotent. Tiny Sweeper completed its review; deterministic results follow.

Review snapshot

Change surface Files Review signal Count
Production 1 Active findings 0
Tests 1 Noted findings 0
Documentation 0 Resolved findings 0
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

Features

  • Modified — Idempotent short-quoted redaction in scrub_credentials: A short quoted credential value that is replaced whole with `*[REDACTED]` is now left unchanged on a second scrub pass, preventing progressive mangling of text scrubbed more than once (e.g., re-scrubbed tool results). Redaction of live secrets is unaffected because the guard only short-circuits values already carrying the marker. (crates/tinyinference-core/src/sanitize.rs pub fn scrub_credentials(input: &str) -> String {)

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Findings

No active actionable findings.

Before merge

None.

Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The critique lane answered with no findings, judging the change sound and safe to merge: the new condition only short-circuits into the unchanged passthrough path, so no previously-redacted input becomes un-redacted.
  • Lane summary: The change makes `scrub_credentials` idempotent for short quoted values by also treating a value that already begins with the redaction marker as done, and adds a test pinning that behaviour. The new condition only short-circuits into the unchanged passthrough path, so no previously-redacted input becomes un-redacted; the guarded inputs are limited to values starting with `*[REDACTED]`, which is itself the marker. The change looks sound and safe to merge. _The code index is behind this pull request (indexed at `50e6d1ce19bd`), so retrieved context may be out of date._

security

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The security lane answered with no findings; the guard only suppresses further redaction of a value that already carries the marker, so it neither weakens redaction of real secrets nor opens a new input path.
  • Lane summary: The change extends the idempotency guard in `scrub_credentials` so a short quoted value already replaced whole by `*[REDACTED]` is left alone on a second pass, and adds a test pinning that behaviour. The guard only suppresses further redaction of a value that already carries the marker, so it neither weakens redaction of real secrets nor opens an input path; I found no defect this PR introduces. _The code index is behind this pull request (indexed at `50e6d1ce19bd`), so retrieved context may be out of date._

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The one-line behaviour change (also treating a captured value that already begins with `*[REDACTED]` as already redacted) is covered by a new test that asserts the exact first-pass output and a fixed point on the second pass, so a regression that reintroduces stacked markers or over-redacts short quoted values fails `short_quoted_value_scrubs_idempotently`. The guard is narrowly scoped and does not stop redaction of a live value like `token=abc`; no findings. _The code index is behind this pull request (indexed at `50e6d1ce19bd`), so retrieved context may be out of date._

commits

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The commits lane answered reporting no sensitive content in committed files.
  • Lane summary: No sensitive content in committed files. _The code index is behind this pull request (indexed at `50e6d1ce19bd`), so retrieved context may be out of date._

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Positive: The description lane answered with no findings, confirming the change matches the stated one-clause guard extension and that the added test exercises exactly that input.
  • Lane summary: The diff adds one clause to the already-redacted guard in `scrub_credentials` so a short quoted value that was replaced whole (`"ab"` -> `"*[REDACTED]"`) is left alone on a second pass, plus a test that exercises exactly that input. The change matches the description, the added test covers the stated contract, and I found nothing that misbehaves or violates a repository rule. _The code index is behind this pull request (indexed at `50e6d1ce19bd`), so retrieved context may be out of date._
Evidence and run details
  • Models: ladder/vectors-oai3, deepseek-v4.1-flash
  • Spend: $0.000385
  • Tokens: 140351 input · 2955 output · 26112 cached · 98 embedding
  • Updated: 2026-10-22T22:56:53Z
Head State Pass summary
47e3eb624cf0 ready for maintainer review 0 active finding(s), 0 resolved finding(s) (at 2026-10-22T22:56:53Z)

tinysweeper 0.1.2

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3c6f4a6e-b625-4476-bcc7-fef77f9df4f8
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking. Approving.

Diagnostics

Total spend: $0.0004

@M3gA-Mind
M3gA-Mind merged commit ba203e5 into tinyhumansai:main Oct 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant