mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-02-15 19:03:22 +08:00
fix: reject empty/invalid array commands in hooks validator, add 19 tests
validate-hooks.js: Empty arrays [] and arrays with non-string elements (e.g., [123, null]) passed command validation due to JS truthiness of empty arrays (![] === false). Added explicit length and element type checks. 19 new tests covering: non-array event type values, null/string matcher entries, string/number top-level data, empty string/array commands, non-string array elements, non-string type field, non-number timeout, timeout boundary (0), unwrapped hooks format, legacy format error paths, empty agent directory, whitespace-only command files, valid skill refs, mixed valid/invalid rules and skills.
This commit is contained in:
@@ -34,7 +34,7 @@ function validateHookEntry(hook, label) {
|
||||
hasErrors = true;
|
||||
}
|
||||
|
||||
if (!hook.command || (typeof hook.command !== 'string' && !Array.isArray(hook.command)) || (typeof hook.command === 'string' && !hook.command.trim())) {
|
||||
if (!hook.command || (typeof hook.command !== 'string' && !Array.isArray(hook.command)) || (typeof hook.command === 'string' && !hook.command.trim()) || (Array.isArray(hook.command) && (hook.command.length === 0 || !hook.command.every(s => typeof s === 'string' && s.length > 0)))) {
|
||||
console.error(`ERROR: ${label} missing or invalid 'command' field`);
|
||||
hasErrors = true;
|
||||
} else if (typeof hook.command === 'string') {
|
||||
|
||||
Reference in New Issue
Block a user