Skip to content

Commit 22b406c

Browse files
Ilanlidoclaude
andcommitted
CM-64462: redirect stdin explicitly in Copilot report-mode hooks
Copilot's bash hook field runs under bash, which reattaches a backgrounded command's stdin to /dev/null (POSIX behavior with job control off) - the scan read an empty payload and silently no-oped without reaching the backend. An explicit <&0 disables that default and keeps the payload flowing. Cursor/Codex keep the bare '&' - their runners were verified to deliver stdin to backgrounded scans (zsh keeps it; bash/sh do not). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 64f5132 commit 22b406c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

cycode/cli/apps/ai_guardrails/ides/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
def shell_background_suffix(async_mode: bool) -> str:
2929
"""`' &'` when backgrounding is requested and the platform's shell supports it.
3030
31+
Only valid for hooks whose runner is stdin-safe under backgrounding (zsh keeps
32+
a backgrounded command's stdin; verified for Cursor/Codex). bash/sh reattach it
33+
to /dev/null, silently emptying the payload — hooks that run under bash (e.g.
34+
Copilot's `bash` field) must add an explicit `<&0` redirect instead.
35+
3136
Windows gets no suffix: depending on the IDE, hooks may run under cmd (where a
3237
trailing `&` is a no-op separator) or Windows PowerShell (where it's a parse
3338
error that would fail the hook). Until the CLI can self-detach in report mode,

cycode/cli/apps/ai_guardrails/ides/copilot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,13 @@ def settings_path(self, scope: str, repo_path: Optional[Path] = None) -> Path:
317317
def render_hooks_config(self, async_mode: bool = False) -> dict:
318318
def entry(command: str) -> dict:
319319
if async_mode:
320-
# Copilot has no async hook flag; background via shell on unix.
320+
# Copilot has no async hook flag; background via shell on unix. The
321+
# explicit <&0 keeps the payload flowing: a bare `cmd &` gets its stdin
322+
# reattached to /dev/null by the shell (job control is off in hooks).
321323
# Windows PowerShell has no trailing-& operator, so it stays sync.
322324
return {
323325
'type': 'command',
324-
'bash': f'{command} &',
326+
'bash': f'{command} <&0 &',
325327
'powershell': command,
326328
'timeoutSec': _HOOK_TIMEOUT_SEC,
327329
}

0 commit comments

Comments
 (0)