feat(providers): add copilot_cli semantic-scan provider - #572
Yoseph-Zuskin wants to merge 12 commits into
Conversation
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Reviewed exact head 6bb8dc5a6af1f8e59d4967f2e8133fd00d02bfa6.
The provider wiring, exact-version gate, stdin transport, output bounds, environment filtering, and zero-tool allowlist are well covered. One trust-boundary gap remains: the invocation leaves Copilot CLI's normal custom-instruction discovery enabled while deliberately preserving the user's home/login context. Ambient global or user instructions can therefore alter semantic-security judgments even though COPILOT_CUSTOM_INSTRUCTIONS_DIRS is stripped. Disable custom instructions explicitly for this provider and add an end-to-end argv/isolation regression before enabling it.
- Add providers/copilot_cli/provider.py and __init__.py mirroring opencode_cli; register copilot in _agent_cli.py CliSpec with _prepare_copilot_env wired in - Transport is flags + piped stdin: copilot -s --no-ask-user, prompt via stdin (verified by nonce round-trip); --available-tools names a fixed implausible tool (verified live: model left tool-less, no side effect) plus --deny-tool shell,write belt-and-braces; never --allow-all* - Auth probe is copilot --version (must equal pinned 1.0.85), scrubbed env, fail-closed; login session or COPILOT_GITHUB_TOKEN/GH_TOKEN/ GITHUB_TOKEN auth, everything else COPILOT_* stripped - Update docs trio: README provider table (+1.0.85 pin note), .env.example, docs/DEVELOPMENT.md - Add tests/provider/test_copilot_cli.py (argv, auth, parser, wiring, adversarial fake-host with POSIX-skip) + registry coverage - Verified: live probe on Copilot Free (CLI-default model), llm_available=true, 3/3 calls, 0/LOW, 0 findings; 375 passed / 14 skipped; ruff + format + diff-check clean Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
6bb8dc5 to
9f8f9c6
Compare
…to-update - Add --no-custom-instructions to copilot argv so ambient AGENTS.md and related files cannot steer the semantic verdict (COPILOT_HOME stays for login, hence flag-level disabling) - Add --disable-builtin-mcps as defense in depth alongside the tool allowlist, and --no-auto-update so the version pin cannot invalidate mid-scan - Extend exact-shape, flag-presence, and fake-host adversarial tests; document the flags in the builder docstring - Verified: 134 passed / 2 skipped, ruff clean; live regression with a hostile AGENTS.md fixture returns the exact requested reply Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
- Bump copilot pin 1.0.85 → 1.0.86 plus all version references (code comments, test fixtures, README pin note, DEVELOPMENT); all six sandbox flags still present in --help, no policy changes - Re-ran live AGENTS.md-ignored regression on the new release: PASS - Verified: file suite 41 passed / 2 skipped; ruff clean Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
yashrajp22
left a comment
There was a problem hiding this comment.
Two issues remain in the Copilot safety boundary: inference bypasses the exact-version check, and ambient user/plugin lifecycle hooks remain enabled.
Validation: fresh base/head wheels with verified package identity; selected tests passed (324 base, 367 head; 10 skipped each); all 48 no-LLM corpus runs matched across source/wheel and base/head, with nine samples retaining partial reports. Synthetic unsupported-version checks reproduced prompt delivery through both public scans and direct completion. The real 1.0.86 binary reported missing authentication as expected, and the scan retained two PE3 findings while explicitly marking semantic analysis failed.
The hook finding is based on the pinned runtime source. The credential-free marker check was inconclusive; authenticated inference and native hook/tool/MCP behavior remain unverified. Corpus parity is not a global accuracy claim.
…e homes - Add _preflight_copilot_policy as the copilot CliSpec preflight: [binary, --version] under the isolated child env rejects anything but exactly 1.0.86 before run_agent_cli delivers stdin — covers normal scans and direct complete() calls, which never hit the once-per-scan availability probe - _prepare_copilot_env redirects HOME/USERPROFILE/COPILOT_HOME to per-invocation temp dirs (user/plugin lifecycle hooks have no argv off-switch); auth survives only via forwarded token vars, persistent login sessions are no longer carried over - Tests: 5 preflight mocks incl. synthetic 9.9.99, home-redirect unit test, fake-host OPERATOR_HOME bait test; stale COPILOT_HOME expectations rewritten - Verified: file suite 46 passed / 3 skipped; provider-wide 87 passed / 6 skipped; ruff check + format + diff-check clean Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
- Codifies the NVIDIA#536/NVIDIA#572 review bar as entry criteria: exact-version preflight before stdin on every completion path, no-hook-material enforcement (isolation where usable, presence-refusal otherwise), adversarial fake-host tests, synthetic-version gate tests, no silent fallbacks - Kept as a standalone commit so it can be reverted on its own if maintainers prefer this guidance elsewhere Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Re-reviewed exact head c9e001f29c7108fd3ecc23f7b6c4f15cac6fa53c, including the complete diff, provider/transport call path, tests, previous reviews and author replies, and CI.
Previous findings:
- Addressed: custom-instruction discovery is explicitly disabled with
--no-custom-instructions; built-in MCPs and auto-update are also disabled, with argv coverage. - Addressed in implementation: the exact-version check is now a registered per-completion preflight, invoked before
Popen/stdin delivery, including directcomplete()calls. The unsupported-version test currently calls the helper directly; please also exercise the public completion path so a future registry/wiring regression cannot bypass the gate unnoticed. - Still open: user/plugin hook isolation is only partially addressed. Rejecting nonempty
installed-plugins/does not reject user hook files or inline settings hooks. The inline finding supplies the concrete non-plugin paths requested in the author reply.
I inspected (did not execute) package/app.js and the version metadata from the official Copilot CLI 1.0.86 release, asset github-copilot-1.0.86-darwin-arm64.tgz. createNativeHookSession loads user settings and passes both settingsJson and userHooksDir to hookSessionCreate before adding plugin hooks separately. This is pinned-runtime evidence, not an assumption from newer documentation.
All six reported CI checks pass. Contributor code/tests and authenticated Copilot inference were not executed during this review; the remaining finding is based on source inspection. Approval remains blocked on closing and testing the non-plugin hook paths.
The copilot home audit only rejected installed-plugins/, but the pinned 1.0.86 runtime loads hooks from policy, user, project, then plugin sources with no argv off-switch (confirmed: no --disable*hook* flag in `copilot --help`). A plugin-free home carrying hooks/*.json or an inline hooks block in settings.json passed the audit while hooks stayed loadable outside the model tool allowlist. - _audit_copilot_home now also rejects hooks/*.json, a truthy top-level hooks block in settings.json (unreadable settings fail closed; messages name paths, never contents), and an explicitly set but missing COPILOT_HOME (unverifiable: the CLI may fall back to ~/.copilot). A missing default home still passes. Machine-wide policy hooks are documented as accepted residual risk (admin-owned, disableAllHooks-immune). - New _audit_tmp_cwd tripwire: repo-level hook material (.github/hooks, repo/Claude settings) in the fresh temp working dir raises; wired into the preflight (which now uses its tmp_cwd parameter). - Regressions: hook-file/inline/malformed/missing-home unit tests, parametrized tmp-cwd tests, a fake-binary end to end proving stdin never moves (invocation marker absent), and a preflight test asserting tmp-cwd rejection precedes the version probe. Fixed a latent Linux-CI failure where a preflight test assumed a nonexistent /tmp/iso/home. - Live validation on real 1.0.86: raw CLI executed both a hooks/*.json command hook and an inline settings hook headlessly (harmless marker files), then the real provider path rejected the same hook home with AgentCLIError and no markers. Temp hook home removed afterwards. Tests: tests/provider 105 passed, 6 skipped (win32 POSIX-shebang skips, incl. the new end to end, which follows the existing adversarial-transport pattern). Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
The CLI keeps several cached runtime generations on disk and disabling updates selects an older cached one: with COPILOT_AUTO_UPDATE=false or --no-auto-update (proven identical), the launcher reports and runs an older generation than the newest install, so any pin above the cached generation can never pass the gate. Drop both update-disabling controls and pin the executed 1.0.88 instead; a mid-scan update now fails loud at the per-completion preflight rather than drifting silently. - Pin 1.0.86 -> 1.0.88 across provider, tests, README, DEVELOPMENT - _prepare_copilot_env no longer forces COPILOT_AUTO_UPDATE (operator value stripped as before: updates stay enabled); --no-auto-update out of argv; docstrings explain why - Tests: exact-shape and fake-host posture assert the flag's absence; test_auto_update_not_forced replaces the forcing test - Live proof on this tree: hook home rejected with AgentCLIError and no markers; clean home returned the exact nonce Tests: file suite 64 passed / 3 skipped; ruff check + format clean. Revertable independently of the hook-audit commit. Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Re-reviewed current head 05f3e3236ea5eae91ffa611faf1df4b5ba239a52, both follow-up commits, the current provider/transport code and regression tests, prior discussions, and CI.
The previous direct-home cases are now addressed: the audit rejects user hooks/*.json, inline settings.json hooks, unreadable settings, and missing explicit homes; the temp-directory tripwire and transport-level rejection test are also present. The custom-instruction/MCP restrictions and per-completion exact-version preflight remain wired in. I also independently checked the official Copilot 1.0.88 launcher: I am not requesting changes solely because auto-update was re-enabled.
One remaining user-hook path prevents approval: the new audit observes the home before Copilot's inference startup migrates legacy XDG hook material into it. The --version subprocess exits before those migrations, so it cannot make the subsequent home audit sufficient. This is a deterministic startup-order issue, not a hypothetical concurrent modification. The inline comment gives the affected configuration, exact pinned-runtime source path, and required correction.
Evidence: read-only inspection of package/app.js from the official Copilot CLI 1.0.88 release, asset github-copilot-1.0.88-darwin-arm64.tgz. The version branch returns before tOn(); tOn() calls X0n for XDG config/state migrations; normal session creation subsequently loads the destination home's hooks.
All six reported CI checks pass. Contributor code, tests, and downloaded Copilot code were not executed locally; this finding is source-traced. No merges or thread-resolution changes were made.
Startup moves $XDG_CONFIG_HOME/.copilot/hooks into the copilot home after the audit, so a hook-free home with hook material in the XDG tree still ends up loadable outside the tool allowlist. _scrub_env retains XDG variables and only the resolved home was inspected. - _audit_copilot_home now also inspects the XDG source (default ~/.config/.copilot when unset; explicit-but-missing XDG raises; same-tree dedup) via an extracted _audit_hook_tree helper shared by both trees. Pure audit extension, no environment behavior change; messages name paths, never contents. - 6 new tests: explicit/default/missing/clean XDG sources plus a fake-binary transport end to end (clean home, dirty XDG source) proving stdin never moves. - Live validation: real-home copy plus XDG marker hook rejected with the migration-source message, marker absent. Tests: file suite 69 passed / 4 skipped (win32 POSIX-shebang skips); ruff check + format clean. Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
… ones Linux CI sets XDG_CONFIG_HOME with no .copilot subdir, tripping the explicit-missing refusal in the adversarial-transport tests. Replace both missing-raises rules with fallback coverage: the audit now walks the override and default trees for the copilot home and the XDG migration source (deduped; missing dirs hold nothing and pass), so a fallback in either direction lands on verified ground. - Deleted the callerless _xdg_copilot_home helper after inlining. - Tests encode the new semantics (missing override/default splits, dirty-default-despite-clean-override both ways). Tests: file suite 75 passed / 4 skipped; ruff clean. Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
|
Hi @yashrajp22 and @rng1995, all comments have been addressed. Please resolve them or let me know if you would prefer I do so myself. The PR description has also been updated to reflect that the pinned CLI version is now 1.0.88. I will propose a minor automation to check for OpenCode and GitHub Copilot CLI releases once a week after this and #613 will be merged. |
rng1995
left a comment
There was a problem hiding this comment.
[SkillSpector Review]
Re-reviewed exact head a053ab575bdf23e46d5971af3aedeffc2f11a75b, including the complete fourteen-file diff, transport/provider integration, tests, all prior reviews/replies/thread states, and CI. I also inspected the official Copilot CLI 1.0.88 release source as inert text.
Addressed: explicit custom-instruction/built-in MCP restrictions remain in place; the exact-version preflight is registered before inference Popen; current/fallback home hooks and inline settings are audited; the previously reported XDG_CONFIG_HOME user-hook migration source is now audited and has transport-level rejection coverage.
Still requires changes: startup migration is not fully covered. The pinned runtime also migrates installed-plugins from XDG_STATE_HOME/.copilot, but this environment variable survives the child environment and its source tree is never audited. The new inline finding describes how plugin hook material can appear after the audit and how to close this path. This is a separate migration source from the CONFIG-hook example fixed in the previous thread, not a repetition of that resolved example.
The earlier requested public-path unsupported-version regression is also still absent: the 9.9.99 rejection test invokes _preflight_copilot_policy directly, while transport tests run the supported version. Please add that public completion rejection case while extending migration coverage, so removal of the registered preflight cannot silently bypass the gate.
All six reported hosted checks pass. Contributor code/tests, downloaded runtime code, and authenticated Copilot inference were not executed locally. No merge or thread-resolution changes were made.
- _audit_copilot_home now inspects explicit $XDG_STATE_HOME/.copilot and default ~/.local/state/.copilot: 1.0.88+ migrates installed-plugins at startup, loading plugin hooks post-audit. Redirecting is not a lever (inference refuses under any redirected home); deleting falls back unaudited; both sources audited in place - New regressions: STATE transport rejection via the public path (clean home, populated STATE plugins, empty markers) and 9.9.99 via the public completion path (preflight removal cannot silently bypass the gate) - Bump pin 1.0.88 -> 1.0.89 plus all references; --help surface identical, still no --disable*hook* flag; 1.0.89 source re-inspected (migration path unchanged, juo still lists installed-plugins) - Verified: 79 passed / 6 skipped (POSIX-only transport skips); ruff + format clean; preflight PASSES live on real 1.0.89 against a genuine user home Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
…ovider Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com>
- Add --disallow-temp-dir alongside --disable-builtin-mcps: prevents automatic access to the system temporary directory (verified live on 1.0.89: inference from a temp working dir still answers exactly) - Pinned shape test updated (RED-witnessed the new flag first) - Verified: file suite 79 passed / 6 skipped (POSIX-only transport skips); ruff + format + diff-check clean Signed-off-by: Yoseph Zuskin <zuskinyoseph@gmail.com> Co-Authored-By: OpenCode Muse Spark 1.3 Free (1M context) <noreply@opencode.ai>
Add
copilot_clisemantic-scan providerProblem
SkillSpector ships CLI providers for Claude, Codex, Gemini, and OpenCode,
but none for GitHub Copilot, so Copilot users get static-only scans
(
llm_availablestays false and the semantic analyzers are skipped) unlessthey provide an OpenAI or Anthropic API key.
Fixes: #8
Approach
copilot_cliprovider mirroring the mergedopencode_clishape:providers/copilot_cli/{provider.py,__init__.py}, registry entry,SKILLSPECTOR_PROVIDER=copilot_cliselection,provider_name()label,CLI help text.
copilot -s --no-ask-userwith no-pflag — the prompt is piped to stdin by run_agent_cli (verified by nonce
round-trip;
-p ""is rejected, so stdin is the cleaner path).Untrusted content never reaches argv; list form throughout, shell never
invoked. Windows hostile-prompt roundtrips covered by test.
--available-toolsnames a fixed implausible tool so the model is offered nothing usable
(verified live: file-creation refused, no side effect), plus
--deny-tool shell,writebelt-and-braces in the documentedKind(argument)form (deny wins over allow). Never--allow-all*.--disallow-temp-dir(verified live on1.0.89: inference from a temp working dir still answers exactly),
alongside
--disable-builtin-mcps.--stream=off/--log-level=noneand=-form flags deliberately not adopted(cosmetic wire-format churn; validator already rejects
flag-like model labels).
--model <label>validated and forwarded only whenSKILLSPECTOR_MODELis set;
max_output_tokensaccepted for CliSpec uniformity and ignored.copilot --versionwith a 15s timeout, scrubbed env,fail-closed: non-zero exit, unparseable output, or anything but the
pinned
1.0.89fails. No status subcommand exists; authentication worksvia login session or one of
COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN(preserved deliberately by_prepare_copilot_env, whichdrops every other
COPILOT_*and forcesCOPILOT_AUTO_UPDATE=false).version re-check on EVERY completion (a swapped binary or direct
complete()call otherwise bypasses the probe), tmp-cwd tripwire forrepo-level hook material, and home audit for user/plugin hook sources
under the resolved home, the default home, and both XDG migration
sources (
$XDG_CONFIG_HOME/.copilot,$XDG_STATE_HOME/.copilotplustheir
~/.config/~/.local/statedefaults) — startup migrates bothinto the home, so clean-home/dirty-source trees refuse. Redirecting
either variable is not a lever (inference refuses under any redirected
home, probed 2026-09-19); both are audited in place. Machine-wide
policy hooks stay a documented residual (admin-owned, unauditable).
_prepare_copilot_envpreservesCOPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKENthrough the scrub(everything else
COPILOT_*is dropped). Rationale: these are the CLI'sdocumented headless auth path — without them, token-only CI setups (where
GITHUB_TOKENis often the only credential) cannot use the provider atall, and the issue being resolved is precisely keyless operation. The
model itself gets no tools, so it cannot read the environment; the CLI
redacts these variables from its own output by default. If reviewers
prefer login-only, the fallback is a one-line change (extend the scrub,
document fail-closed for token setups).
.env.example,docs/DEVELOPMENT.md); provider tests live intests/provider/per repo convention.
Verification
tests/provider/test_copilot_cli.py: 79 passed, 6 POSIX-skipped(TDD: argv, auth, parser, wiring, registry label, home/XDG audits,
adversarial transport; RED witnessed for the STATE regressions).
default, missing-explicit, clean), STATE transport rejection via the
public path with empty markers, and 9.9.99 rejection via the public
completion path (preflight removal cannot silently bypass the gate).
test_agent_cli,test_providers,test_new_providers,test_constants,test_llm_utils): 425 passed /15 skipped total.
ruff check+ruff format --check: clean on all touched files.app.js):migration path unchanged (
installed-pluginsstill migrated fromthe STATE source);
--helpsurface identical for policy purposes,still no
--disable*hook*flag.user home (version gate + all sensitive settings + agent deny; no
auth or inference required).
model):
skill-inspector0/100 LOW SAFE;safe_skill4/100 LOWSAFE;
malicious_skill100/100 CRITICAL with live semanticfindings (P5 narrative, TP4 mismatch);
mcp_poisoned_tool100/100CRITICAL. No errors. (Runs 1.0.88-era figures below retained for
the record:
llm_available: true, 3/3 calls, 0/LOW.)Risks
them — probes only, no bulk scanning on Free.
--available-toolsfixed-name posture depends on unknown names stayinginert (verified on 1.0.89 behavior: silent acceptance); the version
gate pins exactly 1.0.89 so any CLI behavior change fails closed first.
The exact pin is deliberate (matches the merged
opencode_clipolicy):the tool-deny behavior was verified against this release, and a silent
sandbox change must never pass unnoticed. Re-verification per Copilot
release is the known maintenance cost.
Signed-off-by(maintainer: verify on push).