mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
* feat(providers): Codex CLI provider — OpenAI via ModelProvider.OPENAI Mirrors the grok blueprint end to end: CodexCliProvider (RO ~/.codex mount, ANTHROPIC_* blanked), an orchestrator-side codex_auth.py refresher (JWT-exp staleness, atomic rewrite, lock-serialized single-use rotation, --check backstop; the CLI's own in-process refresh write no-ops on the RO mount by design — margins keep the orchestrator ahead of the CLI's 5-minute window), config.toml rendering with required=true gateway MCP servers, execpolicy deny rules (forbidden-only), per-role --sandbox (developer=workspace-write, review/doc roles read-only), codex exec --json with pinned ROBOCO_CODEX_CLI_MODEL (gpt-5.3-codex), usage summed from typed turn.completed events priced via the real 4-bucket split, dedicated image + entrypoint, registry/park/finalize/ compose/release wiring. V1 excludes interactive intake/secretary. Per adversarial review: migration 083 seeds the openai provider row enabled=True (without it every routing path 404'd — the whole feature was operationally dead code; grok needed the same seed in 039), the panel picker gained the OpenAI catalog group it silently lacked, and exit classification is structural — only stderr and error.message fields from error events are sniffed (word-boundaried patterns, exact auth phrases, bare 'login' dropped), so the model echoing on-topic words can never false-park the provider fleet-wide, proven by a benign-transcript test. Known open risk flagged, not claimed: whether codex's workspace-write OS sandbox excludes /app is unverified, and no hook mechanism exists to port the bash-guard defense-in-depth. * fix(providers): containment barrier on usage.json reads (code scanning) CodeQL flagged the codex usage read as path injection — correctly: os.path.basename does not neutralize '..', and the upstream segment validator isn't in CodeQL's taint model. The grok/codex reads collapse into one _read_usage_json_contained helper that resolves the built path and refuses anything outside the resolved usage root — a hostile id can never escape regardless of upstream drift. Traversal + containment regression tests added; a stray noqa in the test file replaced with a named constant per repo rule. * fix(providers): use realpath+startswith containment CodeQL recognizes The is_relative_to() guard was a real barrier but not in CodeQL's py/path-injection sanitizer model, so the alert persisted. Switch to the canonical os.path.realpath + startswith(root + os.sep) form, which CodeQL recognizes as a path-traversal barrier; behavior is identical (refuse any candidate resolving outside the usage root). * fix(providers): regexp-allowlist the usage-id segment (CodeQL barrier) Neither is_relative_to nor realpath+startswith was recognized by CodeQL's py/path-injection sanitizer model across the str->Path->open flow. Sanitize the tainted component at the source instead: the id must fullmatch a strict slug token ([A-Za-z0-9][A-Za-z0-9._-]*, no separators, no '..'), which CodeQL recognizes as a path-injection barrier; the realpath+startswith containment stays as defense-in-depth. * fix(providers): standalone regexp guard so CodeQL recognizes the barrier The sanitizer was one disjunct of a compound 'or' condition, which CodeQL's guard analysis does not trace as a barrier. Split the regexp fullmatch into its own single-condition guard (the redundant '..' check is dropped — the required alphanumeric first char already excludes it). --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
53 lines
2.7 KiB
Docker
53 lines
2.7 KiB
Docker
# Codex (OpenAI) Agent Image
|
|
# =============================================================================
|
|
# Runs OpenAI's Codex agent through the official `codex` CLI, authenticated by a
|
|
# ChatGPT subscription via a mounted ~/.codex/auth.json — the parity analogue of
|
|
# the Grok path's mounted ~/.grok (no metered API key). Reuses the base image's
|
|
# roboco venv + uv + the RoboCo MCP gateway servers. The entrypoint renders
|
|
# ~/.codex/config.toml (the gateway) + the execpolicy deny rules + the per-role
|
|
# sandbox flag from the mounted mcp-config.json (see
|
|
# roboco.llm.providers.codex_cli_config) and runs the CLI headless. One runtime
|
|
# image serves every one-shot delivery role — role behaviour comes from the
|
|
# mounted system prompt / manifest / mcp-config, exactly as on the grok path.
|
|
#
|
|
# V1 scope: no interactive intake/secretary variant of this image exists (unlike
|
|
# grok's agent-grok-prompter / agent-grok-secretary) — Codex is one-shot delivery
|
|
# roles only for now.
|
|
# =============================================================================
|
|
|
|
FROM roboco-agent-base
|
|
|
|
USER root
|
|
|
|
# Install the official codex CLI for the agent user. Pinned — untrusted model
|
|
# output runs under it, so bump the version deliberately, never float. Download
|
|
# the installer to a file first (a `curl | bash` pipe hides a curl failure as a
|
|
# silent no-op) and verify the binary installed AND runs, so a broken install
|
|
# fails the build here, not at spawn. (curl/bash from the base.)
|
|
ARG CODEX_CLI_VERSION=0.145.0
|
|
RUN su agent -s /bin/bash -c "set -euo pipefail; export HOME=/home/agent; \
|
|
curl -fsSL https://chatgpt.com/codex/install.sh -o /tmp/codex-install.sh; \
|
|
bash /tmp/codex-install.sh ${CODEX_CLI_VERSION}; \
|
|
test -x /home/agent/.codex/bin/codex || command -v codex; \
|
|
codex --version" \
|
|
&& rm -rf /tmp/*
|
|
|
|
# Entrypoint: render ~/.codex/config.toml + execpolicy rules + the per-role
|
|
# sandbox flag, then run codex headless (overrides the base image's `claude`
|
|
# entrypoint). ~/.codex is already agent:agent-owned (installed above via
|
|
# `su agent`), so no chown needed here.
|
|
COPY docker/scripts/codex-cli-agent-entrypoint.sh /app/scripts/codex-cli-agent-entrypoint.sh
|
|
RUN chmod 0755 /app/scripts/codex-cli-agent-entrypoint.sh
|
|
|
|
USER agent
|
|
|
|
# codex installs to ~/.codex/bin (or ~/.local/bin, depending on the installer);
|
|
# put both ahead of the venv on PATH so the entrypoint finds `codex` (and still
|
|
# resolves `python` to /app/.venv/bin).
|
|
ENV PATH="/home/agent/.codex/bin:/home/agent/.local/bin:/app/.venv/bin:$PATH"
|
|
|
|
LABEL role="codex-cli-runtime"
|
|
LABEL description="Codex (OpenAI) agent runtime — Codex Build via the official codex CLI"
|
|
|
|
ENTRYPOINT ["/app/scripts/codex-cli-agent-entrypoint.sh"]
|