Skip to content

Commit 4a1840e

Browse files
committed
feat(core): add security posture scanner
1 parent 547e1e4 commit 4a1840e

76 files changed

Lines changed: 2121 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/core/src/check-security-posture.ts

Lines changed: 970 additions & 0 deletions
Large diffs are not rendered by default.

packages/core/src/constants.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ export const DEAD_CODE_WORKER_TIMEOUT_MS = 120_000;
210210
// the child's heap so those projects complete instead of crashing.
211211
export const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
212212

213+
export const SECURITY_SCAN_MAX_FILES = 2500;
214+
215+
export const SECURITY_SCAN_MAX_FILE_SIZE_BYTES = 2 * 1024 * 1024;
216+
217+
export const SECURITY_SCAN_MAX_BUNDLE_FILE_SIZE_BYTES = 8 * 1024 * 1024;
218+
219+
export const SECURITY_SCAN_MAX_DIRECTORY_DEPTH = 8;
220+
213221
// HACK: lookahead cap for JSX opener-span scanning; bounds worst-case
214222
// work on pathological files. Real openers stay well under this.
215223
export const JSX_OPENER_SCAN_MAX_LINES = 32;

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export * from "./check-expo-project.js";
3737
export * from "./check-pnpm-hardening.js";
3838
export * from "./check-react-native-project.js";
3939
export * from "./check-reduced-motion.js";
40+
export * from "./check-security-posture.js";
4041
export * from "./collect-ignore-patterns.js";
4142
export * from "./compute-diagnostic-delta.js";
4243
export * from "./constants.js";

packages/core/src/run-inspect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { checkExpoProject } from "./check-expo-project.js";
1717
import { checkPnpmHardening } from "./check-pnpm-hardening.js";
1818
import { checkReactNativeProject } from "./check-react-native-project.js";
1919
import { checkReducedMotion } from "./check-reduced-motion.js";
20+
import { checkSecurityPosture } from "./check-security-posture.js";
2021
import { DEFAULT_SHOW_WARNINGS } from "./constants.js";
2122
import { highlighter } from "./highlighter.js";
2223
import { computeJsxIncludePaths } from "./jsx-include-paths.js";
@@ -324,12 +325,12 @@ export const runInspect = <HooksR = never>(
324325
Stream.tap((diagnostic) => reporterService.emit(diagnostic)),
325326
);
326327

327-
// ── Phase: environment checks ──────────────────────────────────
328328
const environmentDiagnostics: ReadonlyArray<Diagnostic> = isDiffMode
329329
? []
330330
: [
331331
...checkReducedMotion(scanDirectory),
332332
...checkPnpmHardening(scanDirectory),
333+
...checkSecurityPosture(scanDirectory),
333334
...checkExpoProject(scanDirectory, project),
334335
...checkReactNativeProject(scanDirectory, project),
335336
];

0 commit comments

Comments
 (0)