Skip to content

Commit b264158

Browse files
authored
Merge pull request #129 from Chrilleweb/cmn/removeShowUsed
Changelog + Fixed false positive secret detection
2 parents d853a12 + 01c8f58 commit b264158

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semant
77

88
### Added
99

10+
-
11+
12+
### Changed
13+
14+
-
15+
16+
### Fixed
17+
18+
-
19+
20+
## [2.3.12] - 2025-12-18
21+
22+
### Added
23+
1024
- Added warnings count to scan usage stats.
1125

1226
### Changed
@@ -19,7 +33,7 @@ This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semant
1933

2034
### Fixed
2135

22-
-
36+
- Fixed false positive secret detection for certain harmless attribute keys in codebase scanner.
2337

2438
## [2.3.11] - 2025-12-13
2539

src/core/secretDetectors.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ const HARMLESS_URLS = [
4444
/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/i, // SVG namespace
4545
];
4646

47+
// Known harmless attribute keys commonly used in UI / analytics
48+
const HARMLESS_ATTRIBUTE_KEYS =
49+
/\b(trackingId|trackingContext|data-testid|data-test|aria-label)\b/i;
50+
4751
/**
4852
* Determines the severity of a secret finding.
4953
* @param kind 'pattern' | 'entropy'
@@ -256,7 +260,10 @@ export function detectSecretsInSource(
256260

257261
// 1) Suspicious key literal assignments
258262
if (SUSPICIOUS_KEYS.test(line)) {
259-
const m = line!.match(/=\s*["'`](.+?)["'`]/);
263+
// Ignore known harmless UI / analytics attributes
264+
if (HARMLESS_ATTRIBUTE_KEYS.test(line)) continue;
265+
266+
const m = line.match(/=\s*["'`](.+?)["'`]/);
260267
if (
261268
m &&
262269
m[1] &&

src/ui/scan/printStats.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ export function printStats(
2727
console.log(
2828
chalk.magenta.dim(` Unique variables: ${stats.uniqueVariables}`),
2929
);
30-
console.log(
31-
chalk.magenta.dim(` Warnings: ${stats.warningsCount}`),
32-
);
30+
console.log(chalk.magenta.dim(` Warnings: ${stats.warningsCount}`));
3331
console.log(
3432
chalk.magenta.dim(` Scan duration: ${stats.duration.toFixed(2)}s`),
3533
);

test/e2e/cli.secrets.e2e.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,32 @@ describe('secrets detection (default scan mode)', () => {
270270
expect(res.status).toBe(0);
271271
expect(res.stdout).not.toContain('Potential secrets detected in codebase:');
272272
});
273+
it('does not warn on UI tracking attributes containing auth keywords', () => {
274+
const cwd = tmpDir();
275+
276+
fs.writeFileSync(path.join(cwd, '.env'), 'DUMMY=\n');
277+
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
278+
279+
fs.writeFileSync(
280+
path.join(cwd, 'src', 'page.svelte'),
281+
`
282+
<script>
283+
const trackingId = "users-reset-password-button";
284+
const trackingContext = "users-reset-password-confirmation-modal";
285+
</script>
286+
287+
<button
288+
trackingId="users-reset-password-button"
289+
trackingContext="users-reset-password-confirmation-modal"
290+
>
291+
Reset password
292+
</button>
293+
`.trimStart(),
294+
);
295+
296+
const res = runCli(cwd, []);
297+
298+
expect(res.status).toBe(0);
299+
expect(res.stdout).not.toContain('Potential secrets detected in codebase:');
300+
});
273301
});

0 commit comments

Comments
 (0)