Skip to content

Commit 0bca8f7

Browse files
authored
Merge pull request #101 from Chrilleweb/cmn/dev
Removed low severity secrets from codebase scanner results, because i…
2 parents 9673cd4 + 8ccbe16 commit 0bca8f7

File tree

4 files changed

+9
-85
lines changed

4 files changed

+9
-85
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semant
1212
### Fixed
1313
-
1414

15+
## [2.3.11] - 2025-12-13
16+
### Changed
17+
- Removed low severity secrets from codebase scanner results, because it made too much noise.
18+
1519
## [2.3.10] - 2025-12-11
1620
### Added
1721
- More jsDocs for better code documentation.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dotenv-diff",
3-
"version": "2.3.10",
3+
"version": "2.3.11",
44
"type": "module",
55
"description": "Scan your codebase to find environment variables in use.",
66
"bin": {

src/services/codeBaseScanner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export async function scanCodebase(opts: ScanOptions): Promise<ScanResult> {
3434
if (opts.secrets) {
3535
try {
3636
const relativePath = path.relative(opts.cwd, filePath);
37-
const sec = detectSecretsInSource(relativePath, content, opts);
37+
const sec = detectSecretsInSource(relativePath, content, opts).filter(
38+
(s) => s.severity !== 'low',
39+
);
40+
3841
if (sec.length) allSecrets.push(...sec);
3942
} catch {
4043
// Ignore secret detection errors

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

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -231,48 +231,6 @@ describe('secrets detection (default scan mode)', () => {
231231
expect(res.status).toBe(0);
232232
expect(res.stdout).not.toContain('Potential secrets detected in codebase:');
233233
});
234-
it('should warn about using https URLs in codebase', () => {
235-
const cwd = tmpDir();
236-
237-
fs.writeFileSync(path.join(cwd, '.env'), 'DUMMY=\n');
238-
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
239-
fs.writeFileSync(
240-
path.join(cwd, 'src', 'index.ts'),
241-
`
242-
const service = 'https://hello.com';
243-
const service2 = "https://hello.com/api";
244-
const service3 = \`https://hello.com/path\`;
245-
246-
console.log(service, service2, service3);
247-
`.trimStart(),
248-
);
249-
250-
const res = runCli(cwd, []);
251-
expect(res.status).toBe(0);
252-
expect(res.stdout).toContain('Potential secrets detected in codebase:');
253-
expect(res.stdout).toContain('HTTPS URL detected');
254-
});
255-
it('should warn about using http URLs in codebase', () => {
256-
const cwd = tmpDir();
257-
258-
fs.writeFileSync(path.join(cwd, '.env'), 'DUMMY=\n');
259-
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
260-
fs.writeFileSync(
261-
path.join(cwd, 'src', 'index.ts'),
262-
`
263-
const service = 'http://hello.com';
264-
const service2 = "http://thisIsASecret.com/api";
265-
const service3 = \`http://yes.com/path\`;
266-
267-
console.log(service, service2, service3);
268-
`.trimStart(),
269-
);
270-
271-
const res = runCli(cwd, []);
272-
expect(res.status).toBe(0);
273-
expect(res.stdout).toContain('Potential secrets detected in codebase:');
274-
expect(res.stdout).toContain('HTTP URL detected');
275-
});
276234
it('should not give warning on SVG content', () => {
277235
const cwd = tmpDir();
278236

@@ -312,45 +270,4 @@ describe('secrets detection (default scan mode)', () => {
312270
expect(res.status).toBe(0);
313271
expect(res.stdout).not.toContain('Potential secrets detected in codebase:');
314272
});
315-
it('should ignore warnings with dotenv-diff-ignore comments', () => {
316-
const cwd = tmpDir();
317-
318-
fs.writeFileSync(path.join(cwd, '.env'), 'DUMMY=\n');
319-
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
320-
fs.writeFileSync(
321-
path.join(cwd, 'src', 'index.ts'),
322-
`
323-
// These should be flagged normally
324-
const service1 = 'https://shouldwarn.com';
325-
const secret1 = "sk_live_abcdefghijklmnopqrstuvwx";
326-
327-
// These should be ignored with comments
328-
const service2 = 'https://exdfdfdfdfdfe.com'; // dotenv-diff-ignore
329-
const service3 = "https://ignored.com/api" /* dotenv-diff-ignore */;
330-
const secret2 = "sk_live_ignoredtoken123"; // dotenv-diff-ignore
331-
const apiKey = 'AKIA1234567890IGNORE' /* dotenv-diff-ignore */;
332-
333-
// Also test high entropy strings
334-
const ignoredEntropy = "highEntropyButIgnored987654321fedcba"; // dotenv-diff-ignore
335-
336-
console.log(service1, service2, service3, secret1, secret2, apiKey, ignoredEntropy);
337-
`.trimStart(),
338-
);
339-
340-
const res = runCli(cwd, []);
341-
expect(res.status).toBe(1);
342-
expect(res.stdout).toContain('Potential secrets detected in codebase:');
343-
344-
// Should warn about the non-ignored ones
345-
expect(res.stdout).toContain('HIGH');
346-
expect(res.stdout).toContain('shouldwarn.com');
347-
expect(res.stdout).toContain('sk_live_abcdefghijklmnopqrstuvwx');
348-
349-
// Should NOT warn about the ignored ones
350-
expect(res.stdout).not.toContain('exdfdfdfdfdfe.com');
351-
expect(res.stdout).not.toContain('ignored.com');
352-
expect(res.stdout).not.toContain('sk_live_ignoredtoken123');
353-
expect(res.stdout).not.toContain('AKIA1234567890IGNORE');
354-
expect(res.stdout).not.toContain('highEntropyButIgnored987654321fedcba');
355-
});
356273
});

0 commit comments

Comments
 (0)