Skip to content

Commit 592b8a2

Browse files
committed
removed csp because of backend frameworks
1 parent f5acae0 commit 592b8a2

File tree

7 files changed

+3
-110
lines changed

7 files changed

+3
-110
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ This project follows [Keep a Changelog](https://keepachangelog.com/) and [Semant
5959
### Fixed
6060
- Duration refactored for better code maintainability.
6161

62+
## Changed
63+
- Removed CSP detection from codebase scanner, as it was causing false positives in some cases for backend frameworks.
64+
6265
## [2.3.4] - 2025-11-05
6366
### Fixed
6467
- Fixed issue where CSP detection was not working as expected in some file types.

src/config/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export interface ScanResult {
157157
env?: Array<{ key: string; count: number }>;
158158
example?: Array<{ key: string; count: number }>;
159159
};
160-
hasCsp?: boolean;
161160
frameworkWarnings?: frameworkWarning[];
162161
exampleWarnings?: ExampleSecretWarning[];
163162
logged: EnvUsage[];
@@ -220,7 +219,6 @@ export interface ScanJsonEntry {
220219
env?: Array<{ key: string; count: number }>;
221220
example?: Array<{ key: string; count: number }>;
222221
};
223-
hasCsp?: boolean;
224222
logged?: Array<{
225223
variable: string;
226224
file: string;

src/core/cspDetector.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/services/codeBaseScanner.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
detectSecretsInSource,
66
type SecretFinding,
77
} from '../core/secretDetectors.js';
8-
import { hasCspInSource } from '../core/cspDetector.js';
98
import { DEFAULT_EXCLUDE_PATTERNS } from '../core/patterns.js';
109
import { scanFile } from '../core/scanFile.js';
1110
import { findFiles } from './fileWalker.js';
@@ -26,16 +25,10 @@ export async function scanCodebase(opts: ScanOptions): Promise<ScanResult> {
2625
let filesScanned = 0;
2726
const allSecrets: SecretFinding[] = [];
2827

29-
let hasCsp = false;
30-
3128
for (const filePath of files) {
3229
try {
3330
const content = await fs.readFile(filePath, 'utf-8');
3431

35-
if (!hasCsp && hasCspInSource(content)) {
36-
hasCsp = true;
37-
}
38-
3932
const fileUsages = await scanFile(filePath, content, opts);
4033
allUsages.push(...fileUsages);
4134
if (opts.secrets) {
@@ -80,7 +73,6 @@ export async function scanCodebase(opts: ScanOptions): Promise<ScanResult> {
8073
env: [],
8174
example: [],
8275
},
83-
hasCsp: hasCsp,
8476
logged: loggedVariables,
8577
};
8678
}

src/services/scanOutputToConsole.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { printSuccess } from '../ui/shared/printSuccess.js';
1414
import { printStrictModeError } from '../ui/shared/printStrictModeError.js';
1515
import { printFixTips } from '../ui/shared/printFixTips.js';
1616
import { printAutoFix } from '../ui/shared/printAutoFix.js';
17-
import { printCspWarning } from '../ui/scan/printCspWarning.js';
1817
import { printFrameworkWarnings } from '../ui/scan/printFrameworkWarnings.js';
1918
import { printExampleWarnings } from '../ui/scan/printExampleWarnings.js';
2019
import { printConsolelogWarning } from '../ui/scan/printConsolelogWarning.js';
@@ -123,9 +122,6 @@ export function outputToConsole(
123122
// Console log usage warning
124123
printConsolelogWarning(scanResult.logged ?? [], isJson);
125124

126-
// CSP warning
127-
printCspWarning(scanResult.hasCsp, isJson);
128-
129125
// Expiration warnings
130126
printExpireWarnings(scanResult.expireWarnings ?? [], isJson);
131127

src/ui/scan/printCspWarning.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/e2e/cli.autoscan.e2e.test.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -246,37 +246,6 @@ describe('no-flag autoscan', () => {
246246
expect(res.stdout).not.toContain('SECRET_KEY');
247247
});
248248

249-
it('warns about missing CSP when scanning codebase', () => {
250-
const cwd = tmpDir();
251-
252-
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
253-
fs.writeFileSync(
254-
path.join(cwd, 'src', 'index.ts'),
255-
`const url = "https://example.com";`,
256-
);
257-
258-
const res = runCli(cwd, []);
259-
expect(res.status).toBe(0);
260-
expect(res.stdout).toContain('CSP is missing');
261-
});
262-
263-
it('does not warn about CSP when CSP is present in codebase', () => {
264-
const cwd = tmpDir();
265-
266-
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
267-
fs.writeFileSync(
268-
path.join(cwd, 'src', 'index.ts'),
269-
`
270-
<head>
271-
<meta http-equiv="Content-Security-Policy" content="default-src 'self';">
272-
</head>
273-
`,
274-
);
275-
276-
const res = runCli(cwd, []);
277-
expect(res.status).toBe(0);
278-
expect(res.stdout).not.toContain('CSP is missing');
279-
});
280249
it('should warn about potential secret foound i .env.example', () => {
281250
const cwd = tmpDir();
282251

0 commit comments

Comments
 (0)