Skip to content

Commit 096a98a

Browse files
SK-3156-gitleaks-detection-fix-added-script-to-fix-generated-files-fake-gitleaks
1 parent 6d417f8 commit 096a98a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎scripts/patch-generated-secrets.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ for (const [relativeFile, fileFindings] of byFile) {
196196
const base = placeholderFor(ruleID);
197197
const seen = byRule.get(base) || 0;
198198
byRule.set(base, seen + 1);
199-
const placeholder = seen === 0 ? base : base.replace(">", `_${seen + 1}>`);
199+
// base is always `<REDACTED_RULEID>` (placeholderFor always ends it with
200+
// exactly one ">"), so slice that off and re-append it with the suffix
201+
// rather than using String#replace, which CodeQL flags as an
202+
// incomplete-escaping-style bug (replaces only the first occurrence)
203+
// even though there's only ever one to begin with here.
204+
const placeholder = seen === 0 ? base : `${base.slice(0, -1)}_${seen + 1}>`;
200205

201206
if (content.includes(secret)) {
202207
content = content.split(secret).join(placeholder);

0 commit comments

Comments
 (0)