Skip to content

Commit 7933b1f

Browse files
authored
Fix suggestion token redaction scope (#4403) (#4483)
1 parent 5a8e22b commit 7933b1f

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
category: fixed
3+
issues:
4+
- 4403
5+
affected:
6+
- src/CodeIndex/Diagnostics/DiagnosticRedactor.cs
7+
- tests/CodeIndex.Tests/DiagnosticRedactorTests.cs
8+
---
9+
10+
## English
11+
12+
- **Suggestion persistence preserves ordinary identifiers and recipe IDs (#4403)** — high-entropy detection now requires uppercase, lowercase, and numeric signals inside the same token, so later text no longer causes long PascalCase method names or slash/hyphen audit identifiers to be redacted while actual mixed-character secrets remain protected.
13+
14+
## 日本語
15+
16+
- **提案の永続化で通常の識別子と recipe ID を保持するようになりました (#4403)** — high-entropy 判定で大文字・小文字・数字が同じ token 内にあることを必須にしたため、後続テキストの影響で長い PascalCase メソッド名や slash/hyphen 形式の audit 識別子が伏字になることを防ぎつつ、実際の混合文字 secret は引き続き保護します。

src/CodeIndex/Diagnostics/DiagnosticRedactor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal static class DiagnosticRedactor
6363
RegexTimeout);
6464

6565
private static readonly Regex HighEntropyTokenPattern = new(
66-
@"\b(?=[A-Za-z0-9._~+/=-]{32,}\b)(?=.*[A-Z])(?=.*[a-z])(?=.*\d)[A-Za-z0-9._~+/=-]+\b",
66+
@"\b(?=[A-Za-z0-9._~+/=-]{32,}\b)(?=[A-Za-z0-9._~+/=-]*[A-Z])(?=[A-Za-z0-9._~+/=-]*[a-z])(?=[A-Za-z0-9._~+/=-]*\d)[A-Za-z0-9._~+/=-]+\b",
6767
RegexOptions.CultureInvariant | RegexOptions.Compiled,
6868
RegexTimeout);
6969

tests/CodeIndex.Tests/DiagnosticRedactorTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ public void RedactSuggestionText_UsesSharedTypedPolicy_Issue3933()
2929
redactedTypes.Order(StringComparer.Ordinal));
3030
}
3131

32+
[Theory]
33+
[InlineData("PersistSuggestionsAtomically writes 12 records")]
34+
[InlineData("Recipe risky-code/environment-secret-source; representative result count 3")]
35+
public void RedactSuggestionText_DoesNotBorrowEntropySignalsFromLaterText_Issue4403(string text)
36+
{
37+
var redacted = DiagnosticRedactor.RedactSuggestionText(text, out var redactedTypes);
38+
39+
Assert.Equal(text, redacted);
40+
Assert.Empty(redactedTypes);
41+
}
42+
3243
[Theory]
3344
[InlineData("--github-token")]
3445
[InlineData("github_token")]

0 commit comments

Comments
 (0)