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

@@ -188,6 +188,42 @@ const STAGED_HOOK_SCRIPT_TIMEOUT_MS = 20000;
*/
const LOOP_HOOK_POINT_CLI_TIMEOUT_MS = 60000;
/**
* A security-scan shell script (secret-scan.sh, secret-scan-lint.sh,
* prompt-injection-scan.sh, base64-scan.sh) invoked with missing or invalid
* CLI arguments -- exits almost instantly with a usage error, no scan work
* performed at all. A distinct, lighter-weight class than a real scan of
* even a single tiny fixture (`QUICK_SPAWN_TIMEOUT_MS`, 10000ms) -- this is
* the fast-fail path, not the scan path.
*
* Deliberately a separate name from `MALFORMED_INPUT_HOOK_TIMEOUT_MS`, even
* though the two currently coincide at the same value: that constant bounds
* a Node hook script fed malformed input (a different runtime, a different
* failure shape), not a bash scan script given no arguments. Collapsing them
* would let a future, independent tune of either value silently move the
* other -- the same reasoning `SEAM_DEFAULT_TIMEOUT_MS` documents for its own
* coincidence with `HOOK_FANOUT_TIMEOUT_MS`.
*
* Shared across 2 files in batch #4519 of the ad hoc timeout literal
* migration, epic #4445 -- every site independently arrived at this exact
* value -- that is why it lives here rather than as a file-local constant.
*/
const SCAN_USAGE_ERROR_TIMEOUT_MS = 5000;
/**
* A Node hook script (gsd-prompt-guard-hook.js, gsd-read-injection-scanner.js)
* spawned directly and fed malformed JSON on stdin -- expected to fail closed
* gracefully, no subprocess fan-out, no real scan work. A different operation
* family from `SCAN_USAGE_ERROR_TIMEOUT_MS` (a bash scan script given no
* arguments) despite the coincidentally-matching value -- see that constant's
* own doc comment for why the two are kept separate rather than merged.
*
* Shared across 2 files in batch #4519 of the ad hoc timeout literal
* migration, epic #4445 -- every site independently arrived at this exact
* value -- that is why it lives here rather than as a file-local constant.
*/
const MALFORMED_INPUT_HOOK_TIMEOUT_MS = 5000;
module.exports = {
PROBE_TIMEOUT_MS,
HOOK_FANOUT_TIMEOUT_MS,
@@ -200,4 +236,6 @@ module.exports = {
FIXTURE_HOOK_TIMEOUT_SECONDS,
STAGED_HOOK_SCRIPT_TIMEOUT_MS,
LOOP_HOOK_POINT_CLI_TIMEOUT_MS,
SCAN_USAGE_ERROR_TIMEOUT_MS,
MALFORMED_INPUT_HOOK_TIMEOUT_MS,
};