test(#4519): migrate security-scanner batch to named timeout constants

Batch 8 of 17 in the ad hoc timeout literal migration (epic #4445).
Replaces every bare numeric timeout/timeoutMs object-literal property in
tests/secret-scan-lint.security.test.cjs, tests/security-scan.security.test.cjs,
tests/security-prompt-injection.security.test.cjs, tests/prompt-injection-scan.security.test.cjs,
tests/read-injection-scanner.security.test.cjs, tests/read-injection-scanner.property.test.cjs,
and tests/security.test.cjs with a named constant, per
eslint-rules/no-adhoc-timeout-literal.cjs. Removes the 7 files from the
rule's allowlist.

The issue guessed this batch "most likely needs its own named
SCAN_TIMEOUT_MS." Reading every one of the 19 call sites directly found a
more specific picture: 8 sites across 3 files scan exactly one small temp
fixture file and match the existing QUICK_SPAWN_TIMEOUT_MS class exactly
(reused, no new constant). Two new shared constants cover genuinely
distinct classes that happen to coincide in value:
SCAN_USAGE_ERROR_TIMEOUT_MS (a bash scan script given missing arguments)
and MALFORMED_INPUT_HOOK_TIMEOUT_MS (a Node hook fed malformed JSON) --
kept as separate names per this migration's standing rule that numeric
coincidence is never identity. Three file-local constants cover a real
multi-file directory scan, a property-fuzzing safety net, and a
path-traversal hook test, each with its own pre-existing rationale
preserved.

No bound is lowered or raised anywhere in this batch, honoring the
issue's explicit caution that security-scan timing margins deserve
extra scrutiny. No src/bin file touched.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sim
2026-09-10 17:09:23 -04:00
parent b25fe4dbaf
commit 150acd78c1
9 changed files with 93 additions and 27 deletions

View File

@@ -85,6 +85,7 @@ const {
} = require('./helpers.cjs');
const { runCli } = require('./helpers/cli-negative.cjs');
const { runHook: runHookSeam } = require('./helpers/process-seam.cjs');
const { MALFORMED_INPUT_HOOK_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
const REPO_ROOT = path.resolve(__dirname, '..');
const PROMPT_GUARD_HOOK = path.join(REPO_ROOT, 'hooks', 'gsd-prompt-guard.js');
@@ -402,7 +403,7 @@ describe('gsd-prompt-guard: hostile .planning/ writes are advised, not blocked',
const r = spawnSync(process.execPath, [PROMPT_GUARD_HOOK], {
input: 'this is not json at all',
encoding: 'utf-8',
timeout: 5000,
timeout: MALFORMED_INPUT_HOOK_TIMEOUT_MS,
});
assert.strictEqual(r.status, 0, 'hook must never propagate parser failure');
});
@@ -493,7 +494,7 @@ describe('gsd-read-injection-scanner: hostile reads are flagged with severity',
const r = spawnSync(process.execPath, [READ_SCANNER_HOOK], {
input: '{not json',
encoding: 'utf-8',
timeout: 5000,
timeout: MALFORMED_INPUT_HOOK_TIMEOUT_MS,
});
assert.strictEqual(r.status, 0,
'hook must silent-fail on parser error — never block downstream tool');