@@ -21,17 +21,18 @@ ${buildHookBlock(cliPath)}
2121 */
2222function buildHookBlock ( cliPath ) {
2323 if ( cliPath ) {
24+ const quotedCliPath = `'${ cliPath . replace ( / ' / g, "'\\''" ) } '` ;
2425 return `${ HOOK_MARKER }
2526# Auto-installed by CodeAnt AI — blocks commits containing secrets.
2627# To disable: delete this hook or run "codeant push-protection disable"
2728# Uses the CLI bundled with the VS Code extension.
2829# Reopen stdin from terminal so the CLI can show an interactive bypass prompt.
2930# In non-interactive environments (CI), this silently fails and the commit is blocked.
3031exec < /dev/tty 2>/dev/null || true
31- if [ -f " ${ cliPath } " ] && command -v node >/dev/null 2>&1; then
32- node " ${ cliPath } " secrets --staged --hook
32+ if [ -f ${ quotedCliPath } ] && command -v node >/dev/null 2>&1; then
33+ node ${ quotedCliPath } secrets --staged --hook
3334else
34- command -v codeant >/dev/null 2>&1 || exit 0
35+ command -v codeant >/dev/null 2>&1 || exit 1
3536 codeant secrets --staged --hook
3637fi
3738${ HOOK_MARKER_END } `;
@@ -40,7 +41,7 @@ ${HOOK_MARKER_END}`;
4041# Auto-installed by CodeAnt AI — blocks commits containing secrets.
4142# To disable: delete this hook or run "codeant push-protection disable"
4243exec < /dev/tty 2>/dev/null || true
43- command -v codeant >/dev/null 2>&1 || exit 0
44+ command -v codeant >/dev/null 2>&1 || exit 1
4445codeant secrets --staged --hook
4546${ HOOK_MARKER_END } `;
4647}
@@ -127,7 +128,7 @@ export function installPushProtectionHook(workspacePath, cliPath) {
127128 }
128129 // There's a user-managed hook — append only for shell hooks to avoid breaking non-shell scripts
129130 const firstLine = existing . split ( '\n' , 1 ) [ 0 ] || '' ;
130- const isShellHook = firstLine . startsWith ( '#!' ) ? / \/ ( b a | z | k ) ? s h ( \s | $ ) / . test ( firstLine ) : true ;
131+ const isShellHook = firstLine . startsWith ( '#!' ) ? / ^ # ! \s * (?: \/ \S * \/ | \/ u s r \/ b i n \/ e n v \s + (?: - S \s + ) ? ) ( b a | z | k ) ? s h ( \s | $ ) / . test ( firstLine ) : true ;
131132 if ( ! isShellHook ) {
132133 return { installed : false , hookPath, message : 'Existing pre-commit hook is non-shell; cannot append CodeAnt block safely' } ;
133134 }
0 commit comments