Skip to content

Commit ec93e99

Browse files
committed
fix(security): removed http warnings
1 parent 2abfab8 commit ec93e99

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

.changeset/huge-kings-make.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'dotenv-diff': patch
3+
---
4+
5+
removed warning on detecting http URLs

packages/cli/src/core/security/secretDetectors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const PROVIDER_PATTERNS: RegExp[] = [
4141
const LONG_LITERAL = /["'`]{1}([A-Za-z0-9+/_\-]{24,})["'`]{1}/g;
4242

4343
// Regex for detecting HTTPS URLs
44-
const HTTPS_PATTERN = /["'`](https?:\/\/(?!localhost)[^"'`]*)["'`]/g;
44+
const HTTPS_PATTERN = /["'`](https:\/\/(?!localhost)[^"'`]*)["'`]/g;
4545

4646
// List of harmless URL patterns to ignore
4747
const HARMLESS_URLS = [
@@ -296,15 +296,15 @@ export function detectSecretsInSource(
296296
const url = httpsMatch[1];
297297
if (url && !looksHarmlessLiteral(url)) {
298298
if (ignoreUrlsMatch(url, opts?.ignoreUrls)) continue;
299-
const protocol = url.startsWith('https') ? 'HTTPS' : 'HTTP';
300299

301300
findings.push({
302301
file,
303302
line: lineNo,
304303
kind: 'pattern',
305-
message: `${protocol} URL detected – consider moving to an environment variable`,
304+
message:
305+
'HTTPS URL detected – consider moving to an environment variable',
306306
snippet: line.trim().slice(0, 180),
307-
severity: protocol === 'HTTP' ? 'medium' : 'low',
307+
severity: 'low',
308308
});
309309
}
310310
}

packages/cli/test/unit/core/security/secretDetectors.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,11 @@ const token = "AKIAIOSFODNN7EXAMPLE";
351351
expect(findings[0].message).toContain('HTTPS URL detected');
352352
});
353353

354-
it('should detect HTTP URLs as medium severity', () => {
354+
it('should not detect HTTP URLs as medium severity', () => {
355355
const source = 'const apiUrl = "http://api.realservice.com/endpoint";';
356356
const findings = detectSecretsInSource('test.ts', source);
357357

358-
expect(findings).toHaveLength(1);
359-
expect(findings[0].severity).toBe('medium');
360-
expect(findings[0].message).toContain('HTTP URL detected');
358+
expect(findings).toHaveLength(0);
361359
});
362360

363361
it('should ignore URLs from ignoreUrls config', () => {

0 commit comments

Comments
 (0)