fix: close block-no-verify bypass holes

Backport Jamkris's fix for case-insensitive core.hooksPath overrides and the git commit -tn template-path false positive. Verified locally on current main with 25/25 block-no-verify tests and node tests/run-all.js passing 2369/2369.
This commit is contained in:
SeungHyun
2026-05-13 11:28:12 +09:00
committed by GitHub
parent 393d397efa
commit 6be241a463
2 changed files with 36 additions and 4 deletions

View File

@@ -179,6 +179,24 @@ if (test('blocks plain text input with --no-verify', () => {
assert.strictEqual(r.code, 2, `expected exit 2, got ${r.code}`);
})) passed++; else failed++;
// --- Case-insensitivity of git config keys + -t template short option ---
if (test('blocks case-variant core.hooksPath (lowercase)', () => {
const r = runHook({ tool_input: { command: 'git -c core.hookspath=/dev/null commit -m "msg"' } });
assert.strictEqual(r.code, 2, `expected exit 2, got ${r.code}`);
assert.ok(/core\.hookspath/i.test(r.stderr), `stderr should mention core.hooksPath: ${r.stderr}`);
})) passed++; else failed++;
if (test('blocks case-variant core.hooksPath (uppercase)', () => {
const r = runHook({ tool_input: { command: 'git -c core.HOOKSPATH=/dev/null commit -m "msg"' } });
assert.strictEqual(r.code, 2, `expected exit 2, got ${r.code}`);
})) passed++; else failed++;
if (test('still allows -tn (n is the -t template path, not a flag)', () => {
const r = runHook({ tool_input: { command: 'git commit -tn -m "msg"' } });
assert.strictEqual(r.code, 0, `expected exit 0, got ${r.code}: ${r.stderr}`);
})) passed++; else failed++;
console.log('─'.repeat(50));
console.log(`Passed: ${passed} Failed: ${failed}`);