chore(16-03): triage eslint-plugin-security findings to green

- Disable detect-object-injection globally in eslint.config.js: all hits were
  numeric loop array indices (ranks[i]) — not user-controlled keys; zod guards
  real API input boundaries; justification comment added (T-16-09)
- Add inline eslint-disable for detect-non-literal-fs-filename at 2 sites:
  - apps/api/src/index.ts: realpathSync(process.argv[1]) — runtime entry path, not user input
  - apps/api/tests/broker/expand.test.ts: readFileSync of test fixture path — test-controlled
- pnpm lint exits 0 across both apps with --max-warnings 0
- 14 of 15 security rules remain active at error; no blanket file disables
This commit is contained in:
Lucas Berger
2026-06-13 05:24:02 -04:00
parent 826a23a16c
commit 59e49ec3da
3 changed files with 9 additions and 5 deletions
+1
View File
@@ -101,6 +101,7 @@ app.get('*', serveStatic({ path: './public/index.html' }));
function isMainModule(): boolean { function isMainModule(): boolean {
if (!process.argv[1]) return false; if (!process.argv[1]) return false;
try { try {
// eslint-disable-next-line security/detect-non-literal-fs-filename -- process.argv[1] is the Node runtime entry path, not user input
return fileURLToPath(import.meta.url) === realpathSync(process.argv[1]); return fileURLToPath(import.meta.url) === realpathSync(process.argv[1]);
} catch { } catch {
return false; return false;
+1
View File
@@ -25,6 +25,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
const FIXTURES = join(__dirname, '../fixtures'); const FIXTURES = join(__dirname, '../fixtures');
function loadFixture(name: string): string { function loadFixture(name: string): string {
// eslint-disable-next-line security/detect-non-literal-fs-filename -- name is a test-controlled fixture filename, not user input
return readFileSync(join(FIXTURES, name), 'utf8'); return readFileSync(join(FIXTURES, name), 'utf8');
} }
+7 -5
View File
@@ -106,16 +106,18 @@ export default tseslint.config(
}, },
// ── 5. eslint-plugin-security: blocking errors per D-03 ────────────────── // ── 5. eslint-plugin-security: blocking errors per D-03 ──────────────────
// Applied to all TS/TSX files in both apps. // Applied to all TS/TSX files in both apps. 14 of 15 rules active at error.
// 15 rules active at error level — heuristic, noisy on obj[key] patterns. // detect-object-injection is disabled globally: it fires on every obj[key]
// detect-object-injection disabled globally: very high false-positive rate on // pattern including numeric array index access (e.g. arr[i] in loops).
// Drizzle ORM bracket access and TypeScript generics; real user-controlled key // After triage: all hits are schema-derived or numeric loop counters — not
// risks are guarded by zod validation — see Task 2 triage notes. // user-controlled keys. Real user-controlled input is guarded by zod
// validation at API boundaries. Disabling one rule; the remaining 14 enforce.
{ {
files: ['apps/**/*.{ts,tsx}'], files: ['apps/**/*.{ts,tsx}'],
...pluginSecurity.configs.recommended, ...pluginSecurity.configs.recommended,
rules: { rules: {
...pluginSecurity.configs.recommended.rules, ...pluginSecurity.configs.recommended.rules,
'security/detect-object-injection': 'off', // High FP: all hits are numeric loop indices or schema-derived keys, not user input
}, },
}, },