Skip to content

Stop redacting optional-chained property accesses - #90

Merged
steflsd merged 1 commit into
mainfrom
fix/identifier-rejections
Jul 27, 2026
Merged

Stop redacting optional-chained property accesses#90
steflsd merged 1 commit into
mainfrom
fix/identifier-rejections

Conversation

@steflsd

@steflsd steflsd commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai ignore

isLikelySecretValue rejects code references so that ordinary expressions in source an agent is reading aren't mistaken for credentials. Both rules only matched plain dotted identifier chains, and ?. and ! fall outside [\w$] — so config.auth?.accessToken and process.env.SERVICE_API_KEY! failed the rejection, passed the entropy heuristics, and got replaced with surrogates.

Same failure mode as #85: a value the agent needed to see, silently removed from its view.

Fix

Tolerate optional chaining between segments and a trailing TypeScript non-null assertion.

Measurements

Across 4,098 tracked files in 10 repositories:

detections
baseline (main, 0.2.3) 103
with this change 89 (−14)
detections added 0

I listed all 14 removed detections individually rather than trusting the aggregate — every one is an optional-chained property access (foo?.bar, config.thing?.someValue). No credential-shaped value is affected. That mattered to check, because the same corpus does contain genuine credentials in test fixtures (bcrypt hashes, password literals) that a sloppier rule would have dropped.

pnpm check: 51 files, 563 tests, all pass. Four new cases added to the existing code-reference test.

Not addressed

Bare SCREAMING_SNAKE identifiers and kebab-case names at or above the 20-character threshold still pass the heuristics. Those need a different rule than identifier-chain matching, and I'd rather not widen this one speculatively — over-rejection here means a real secret slips through.

This was the measured prerequisite for the bare-key detection work (the token: / password: gap documented in #89); it removes roughly half the residual noise that made that change unattractive.

🤖 Generated with Claude Code

isLikelySecretValue rejects code references so that expressions in source an
agent is reading are not mistaken for credentials, but the two rules only
matched plain dotted identifier chains. `?.` and `!` fall outside `[\w$]`,
so `config.auth?.accessToken` and `process.env.SERVICE_API_KEY!` failed
those rules, then passed the entropy heuristics and were replaced with
surrogates.

Tolerate optional chaining between segments and a trailing TypeScript
non-null assertion.

Measured across 4,098 tracked files in 10 repositories: 103 detections drop
to 89, with none added. All 14 removed are optional-chained property
accesses; no credential-shaped value is affected.

Not addressed here: bare SCREAMING_SNAKE identifiers and kebab-case names at
or above the 20-character threshold still pass. Those need a different rule
than identifier-chain matching.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@steflsd
steflsd merged commit 7d4b093 into main Jul 27, 2026
4 checks passed
@steflsd
steflsd deleted the fix/identifier-rejections branch July 27, 2026 08:45
@github-actions github-actions Bot mentioned this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant