Repository navigation
fix: make Copilot and Codex agents work end-to-end on Windows - #23
Merged
Merged
Conversation
Found by an end-to-end test of both adapters on Windows 11 (SECFOO-10, copilot 1.0.89, codex-cli 0.159.2): - Launch the path shutil.which resolved. Popen ignores PATHEXT, so the bare name missed npm's .cmd/.bat shims and every npm-installed agent crashed with WinError 2 while `secfoo agents` showed it as available. A launch OSError now returns a failed result instead of a traceback. - Send the prompt on stdin for Copilot and Codex (`codex exec -`). As an argv it went through cmd.exe, which cut it off at the first newline. - Copilot: read --output-format json and keep only the main agent's final message. In text mode its built-in security-review subagent streamed concurrently and interleaved mid-line into the report. - Codex: mark a run failed when its sandbox rejected the commands. On Windows `--sandbox read-only` refuses even reads, yet `codex exec` exits 0 with an empty "could not inspect" report that was stored as a success. - Decode agent output as UTF-8 rather than the Windows locale codepage. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 2, 2026
Varunpoojari
added a commit
that referenced
this pull request
Oct 3, 2026
PR #23 moved Codex and Copilot to stdin because npm-installed CLIs are `.cmd` shims on Windows and cmd.exe cuts an argv prompt at its first newline. The Claude adapter still passed the prompt as an argument. `claude -p` with no prompt argument reads it from stdin; a two-line prompt was read in full on Linux with Claude Code 2.1.288. The Windows truncation itself was not reproduced for Claude (no Windows machine). - claude.py: `prompt_via_stdin = True`, prompt dropped from the argv. - test_base.py: the "stdin is DEVNULL" test used Claude as its example of an argv-prompt adapter; it now uses Cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JkVdBSUgu2rKg3G7Tg6DJD
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
End-to-end test of the Copilot (#15) and Codex (#12) adapters on Windows 11 (SECFOO-10) found that neither worked there. This fixes the secfoo side of each failure.
Popen(["copilot", ...])ignores PATHEXT, butshutil.whichdoesn'tsecfoo agentsshows the agent as available, then every run crashes withFileNotFoundError: [WinError 2]. This affects every npm-installed agent (Copilot, Codex, Gemini).base.pylaunches the pathshutil.whichresolved. A launchOSErrornow returnsfailedinstead of a traceback.cmd.exeAgentAdapter.prompt_via_stdin, used by Copilot (piped stdin, no-p) and Codex (codex exec -).security-reviewsubagent streams to stdout at the same time as the main answer**Severity:# Secret LOW Scanning Report, which is worse than the duplication the adapter docstring describes--output-format jsonand keep the last non-emptyassistant.messagewithout anagentId(subagent events always carry one).--stream offwas tried too: it stops the interleaving but renders Markdown to plain text, which drops the headings the parsers need.codex exec --sandbox read-onlyrejects every command, reads included ("blocked by policy")AgentAdapter.detect_failure()hook. Codex marks the runfailedwhen its commands were rejected, with an explanation in stderr.UnicodeDecodeErroron UTF-8 agent outputencoding="utf-8", errors="replace"E2E results (Windows 11, fixture repo with a fake AWS key, a SQL injection and a command injection)
sastfinds the command injection (Critical, CWE-78,app.py:24) and the SQL injection (High, CWE-89,app.py:19), andextract_findings_register_rowsparses both.secret-scanningfinds the AWS key pair and rates it Low (it recognises the AWS documentation example key). Each skill takes about 80s.failed, but it still can't read the target on Windows.windows.sandbox="unelevated"still blocks reads."elevated"starts a one-time admin-approved sandbox install, which I didn't approve on the test machine, so whether it fixes this is unverified. The failure message points users to that setup. I deliberately didn't switch todanger-full-access.Behaviour change outside Windows
Copilot and Codex now get the prompt on stdin on every OS. Both CLIs' help documents stdin input, but I only ran it on Windows, so a macOS/Linux smoke run before merging would be worthwhile.
Test plan
pytest: 703 passed, 5 failed. The 5 (test_cloudpermissions and 4 architecture dashboard tests) fail the same way on untouchedorigin/mainon Windows.secfoo run -s secret-scanning -s sast -a copiloton Windowssecfoo run -s sast -a codexon Windows (nowfailedwith a reason, previously a falsesuccess)Not in this PR
runninginsecfoo listforever. It's seen less often now that launch errors are handled, but it's still possible.session.usage_checkpoint), not dollars, so cost still shows-.