Repository navigation
Description
Context & Rationale
mask_secrets (security/sanitizer.py:269) masks password = <value> assignments. Code must not be rewritten before review (:136-141). So _is_code_value (:124-133) leaves an unquoted dotted name alone, but only when its first part is in CONST_CODE_EXEMPTION_RECEIVERS (config/constants.py:2347-2364). That list holds 14 names, such as request, settings and self.
At ef21785 it fails in both directions:
password = cfg.db_passwordbecomespassword=<masked-password>, becausecfgis not on the list. The code the reviewer needs to see is hidden.PASSWORD=settings.Hunter22in an env file is left as it is, becausesettingsis on the list.
The review masks whole files and pages before the model sees them (ai/review/verification.py:196, :287; ai/review/classification.py:329). Every other caller masks logs, errors and telemetry.
Scope & Deliverables
- Deliverable:
mask_secretstakes the syntax of the text it masks:code: a programming language, fromdetect_language(ai/analyze/scanner.py:127) on the reviewed path;data: everything else. This is the default.
- In
code, an unquoted right-hand side made of names, calls or indexing is an expression, and stays as written. Indata, every value is masked. - The review callers pass the syntax per file.
- Delete
CONST_CODE_EXEMPTION_RECEIVERS.
- Acceptance criteria:
- A table test runs both examples above in both syntaxes. In
code,cfg.db_passwordstays. Indata,settings.Hunter22is masked. Verified by the test. - The existing sanitizer tests pass. Verified by the gate.
- A review of one Python file and one env file masks each by its own syntax. Verified by a test with fake files, without a model.
grep -rn CONST_CODE_EXEMPTION_RECEIVERS src testsprints nothing. Verified by the command.
- A table test runs both examples above in both syntaxes. In
- Key questions:
- What about pages that hold several files (
classification.py:329)? Mask each file before the page is put together (proposed). Where that is not possible, the page usesdata, which masks more and so is safe. - Which languages count as code? The scanner's own language table decides, because it is a closed set this project defines (proposed). Config, markup and plain text count as
data.
- What about pages that hold several files (
- Constraint: Callers that pass no syntax keep masking as much as today or more, never less.
Strategic Alignment
- Depends on: none
- Related: fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 (split from it)
Split off #431 during the v0.2.25/v0.2.26 readiness review (2026-10-01): Part of #431's original scope (CONST_CODE_EXEMPTION_RECEIVERS is an arbitrary identifier-prefix list) that #431 no longer covers. It changes the sanitizer's interface and the review callers, so it is its own PR.
Update 2026-10-08: refinement
The defect stands (security/sanitizer.py:124-134). Single-file maskers: ai/review/verification.py:233, :324, ai/review/classification.py:329, ai/review/judged_claims.py:117, ai/analyze/outlines.py:96, :301; data maskers: ai/review/sanitization.py:27, ai/review/pipeline.py:3193. Each single-file caller passes its file's syntax.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Review
Activity
dan-petty commentedon Oct 3, 2026
Lines cited at dcafadf.
#1109 also edits
security/sanitizer.py, but different code: the URL-credential entry of_SECRET_PATTERNS(:235-239),mask_uri_credentials(:288-307) andsanitize_telemetry_endpoint(:343-366), which it moves ontourllib.parse.urlsplitandhttpx2.URL. This item changes_is_code_value(:124-134) and the signature ofmask_secrets(:269), so whichever lands second rebases. Keep #1109's URL-credential masking in force under both thecodeand thedatasyntax, since a password inside a URL is a literal in either.Two more notes (consolidation, 2026-10-03):
mask_secretstoday. This item's review-caller criterion is restated against what survives them. If the redesign's deletions land first, this item shrinks to the sanitizer API and the deletion ofCONST_CODE_EXEMPTION_RECEIVERS.ai/analyze/scanner.py'sdetect_language, which disagrees withai/ast/engine.py's (.ccis c in one and cpp in the other). File analysis labels C++ as C and Helm templates as plain text #540 merges the two classifiers; it is proposed that this item lands after File analysis labels C++ as C and Helm templates as plain text #540 (a person decides; it was split from fix(security): network references come from url and ip syntax, not identifier-prefix and property-suffix lists #431 on purpose, and that split stands).dan-petty commentedon Oct 8, 2026
Linked: #540 and #887. This item picks masking syntax with
scanner.detect_language, which #540 replaces with one classifier; #887 replaces other hand-written security tables under the same library-first rule. Found by the 2026-10-08 backlog review.dan-petty commentedon Oct 9, 2026
Folded in: a token right after
<is never masked (found by #1398's review, 2026-10-09)Since v0.2.18 (#116), the GitHub-token and
sk-patterns insecurity/sanitizer.pycarry<in their lookbehind ((?<![A-Za-z0-9_<])after #1398). So a token right after<, as in a Markdown autolink or a hook message that wraps the value in angle brackets (<ghs_...>), is printed whole, for every prefix. Neither #116's task file nor its commit says why<was added; the likely reason is to leave doc placeholders such as<ghp_token>alone, which the length minimums now do anyway.This belongs with this item's rework of how masking tells code from literals: drop
<from the lookbehinds (keeping the length minimums), with a test that<ghs_+ a real-length body is masked and a placeholder such as<ghp_token>is not.When this lands, also update
docs/agent/tasks/task-1398-mask-every-github-token-prefix.md, whose note says the<lookbehind gap "needs a follow-up issue": it should name this issue (#1398 merged before the fold).fix(security): secret masking tells code from literals by the file's …
chore(main): release 0.4.0 (#1960)