Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# robust route for a container image, since there's no cross-platform
# concern (the image itself is the platform).
#
# Note: none of the 4 agent CLIs (claude, agent/cursor, agy, gemini) are
# Note: none of the 5 agent CLIs (claude, agent/cursor, agy, gemini, codex) are
# installed in this image, and none of their auth lives here either --
# `secfoo run` needs one available on PATH inside the container (e.g. via
# a custom image built FROM this one, or a volume mount) to actually
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Context-based security architectural assessment orchestrator: pick skills, targe
Pick one or more security **activities** (see the catalog below), point them
at a **target** (a public GitHub URL, a local directory, plus optional
Confluence links for extra context), choose which coding-agent CLI runs them
(Claude Code, Cursor, Antigravity, or Gemini CLI), and browse every
(Claude Code, Cursor, Antigravity, Gemini CLI, or Codex CLI), and browse every
assessment ever run, across every project, in a local web dashboard.

> This repository is the open-source CLI and local dashboard. secfoo's
Expand All @@ -41,7 +41,7 @@ secfoo run --skill security-architecture-review --agent claude
```

You'll need an agent CLI already installed and authenticated — Claude
Code, Cursor, Antigravity, or Gemini CLI (`--agent claude|agent|agy|gemini`).
Code, Cursor, Antigravity, Gemini CLI, or Codex CLI (`--agent claude|agent|agy|gemini|codex`).
On a real terminal, that first run prompts for a project name and
application ID, then browse every result in the dashboard:

Expand Down Expand Up @@ -103,8 +103,8 @@ the [CLI reference](https://secfoo.com/docs/cli.html) for more.
record every rescan.
- **Concurrent by default**: multiple `--skill` flags run at the same
time, not one after another.
- **Bring your own agent**: Claude Code, Cursor, Antigravity, or Gemini
CLI — pick whichever you already use and trust.
- **Bring your own agent**: Claude Code, Cursor, Antigravity, Gemini
CLI, or Codex CLI — pick whichever you already use and trust.
- **Open source CLI**: MIT licensed.

## Activity catalog
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and, if possible, steps to reproduce. We aim to acknowledge reports within

secfoo is a developer tool that runs in your environment with your user
permissions. `secfoo run` shells out to a coding-agent CLI you already have
installed and trust (Claude Code, Cursor, Antigravity, or Gemini CLI) and
installed and trust (Claude Code, Cursor, Antigravity, Gemini CLI, or Codex CLI) and
points it at a target — a local directory or a shallow clone of a public
GitHub repo — with an instruction prompt telling it to *read and report
only*. secfoo does not itself execute code from the target; the agent CLI
Expand Down
3 changes: 2 additions & 1 deletion docs/REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ How MCP servers reach each agent varies by what its CLI actually supports:
|---|---|
| `claude` | Automatic on every `secfoo run` (`--mcp-config`, scoped to that invocation only — your global Claude config is never touched) |
| `gemini`, `agent` (Cursor) | Run `secfoo mcp sync --agent <agent>` once to register persistently in that tool's own config |
| `codex` | Not wired up yet — Codex reads MCP servers from its own `~/.codex/config.toml` |
| `agy` (Antigravity) | Not supported yet — its CLI has no MCP configuration mechanism as of this writing |

```bash
Expand Down Expand Up @@ -389,7 +390,7 @@ along with a `SHA256SUMS` file.
- **Docker**: `ghcr.io/rakfortltd/secfoo`, built from the PyPI package on
a slim Python base (simplest, most robust route for a container image —
no cross-platform concern since the image itself is the platform).
**Note**: none of the 4 agent CLIs (claude, cursor, antigravity, gemini)
**Note**: none of the 5 agent CLIs (claude, cursor, antigravity, gemini, codex)
are installed in this image, so `secfoo run` needs one made available on
`PATH` inside the container yourself (e.g. a custom image built `FROM`
this one, or a volume/bind mount) to actually execute a skill — without
Expand Down
54 changes: 54 additions & 0 deletions src/secfoo/agents/codex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""OpenAI Codex CLI adapter.

Flags verified against a real `codex exec --help` (codex-cli 0.155, Sep 2026):
`codex exec` runs a single prompt non-interactively. Progress/tool activity
goes to stderr and only the agent's final message is printed to stdout, so
the base class's default `extract_report` (stdout is the report) is correct
here and deliberately not overridden. `--json` would switch stdout to a JSONL
event stream, which we do not want for a plain-markdown report.

Deliberately NOT passed:
- `--dangerously-bypass-approvals-and-sandbox` / `--full-auto`: a read-only
review never needs write access, so we pin `--sandbox read-only` instead.
- `--json`: see above.

MCP servers from ~/.secfoo/config.toml are not wired up for Codex yet
(`secfoo mcp sync --agent codex` is a follow-up); Codex runs use whatever is
already in the user's own ~/.codex/config.toml.
"""

from __future__ import annotations

from pathlib import Path

from secfoo.agents.base import AgentAdapter


class CodexAdapter(AgentAdapter):
name = "codex"
binary = "codex"
default_timeout_seconds = 1800

def build_command(self, prompt: str, *, workdir: Path) -> list[str]:
return [
self.binary,
"exec",
# Read-only filesystem: the assessment only reads the target.
"--sandbox",
"read-only",
# secfoo runs against arbitrary targets (cloned repos, user
# paths, non-git dirs); without this Codex refuses to start
# outside a trusted git repository.
"--skip-git-repo-check",
# Don't litter ~/.codex/sessions with one file per assessment.
"--ephemeral",
# No ANSI escapes in captured stdout/stderr.
"--color",
"never",
"--cd",
str(workdir),
# `--` so a prompt that happens to start with "-" is never
# parsed as a flag.
"--",
prompt,
]
2 changes: 2 additions & 0 deletions src/secfoo/agents/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from secfoo.agents.antigravity import AntigravityAdapter
from secfoo.agents.base import AgentAdapter
from secfoo.agents.claude import ClaudeAdapter
from secfoo.agents.codex import CodexAdapter
from secfoo.agents.cursor import CursorAdapter
from secfoo.agents.gemini import GeminiAdapter
from secfoo.agents.secfoo import SecFooAdapter
Expand All @@ -13,6 +14,7 @@
AntigravityAdapter.name: AntigravityAdapter,
GeminiAdapter.name: GeminiAdapter,
SecFooAdapter.name: SecFooAdapter,
CodexAdapter.name: CodexAdapter,
}


Expand Down
1 change: 1 addition & 0 deletions src/secfoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class AgentId(str, Enum):
ANTIGRAVITY = "agy"
GEMINI = "gemini"
SECFOO = "secfoo"
CODEX = "codex"


class DepthId(str, Enum):
Expand Down
2 changes: 1 addition & 1 deletion src/secfoo/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[defaults]
# Used whenever --agent / --depth / --timeout aren't passed on the command
# line. CLI flags always win over these.
agent = "claude" # claude | agent (Cursor) | agy (Antigravity) | gemini | secfoo
agent = "claude" # claude | agent (Cursor) | agy (Antigravity) | gemini | secfoo | codex
depth = "quick" # quick | standard
# timeout = 1800 # seconds; omit to use each agent's own default

Expand Down
3 changes: 2 additions & 1 deletion src/secfoo/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@ def sync(agent_id: str, servers: list[MCPServerConfig]) -> list[SyncResult]:
raise ValueError(
f"secfoo mcp sync isn't supported for {agent_id!r}. "
f"claude uses --mcp-config automatically on every run (no sync needed); "
f"agy doesn't expose any MCP configuration mechanism via its CLI yet."
f"agy doesn't expose any MCP configuration mechanism via its CLI yet; "
f"codex isn't wired up for it yet (it reads ~/.codex/config.toml directly)."
)
43 changes: 43 additions & 0 deletions tests/test_agents/test_codex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from __future__ import annotations

from secfoo.agents import ADAPTERS, get_adapter
from secfoo.agents.codex import CodexAdapter


def test_registered_under_codex_id():
assert ADAPTERS["codex"] is CodexAdapter
assert isinstance(get_adapter("codex"), CodexAdapter)


def test_build_command_is_non_interactive_exec(tmp_path):
cmd = CodexAdapter().build_command("hello", workdir=tmp_path)
assert cmd[:2] == ["codex", "exec"]


def test_build_command_is_read_only(tmp_path):
cmd = CodexAdapter().build_command("hello", workdir=tmp_path)
assert cmd[cmd.index("--sandbox") + 1] == "read-only"
assert "--dangerously-bypass-approvals-and-sandbox" not in cmd
assert "--full-auto" not in cmd


def test_build_command_headless_flags(tmp_path):
cmd = CodexAdapter().build_command("hello", workdir=tmp_path)
assert "--skip-git-repo-check" in cmd
assert "--ephemeral" in cmd
assert cmd[cmd.index("--color") + 1] == "never"
assert "--json" not in cmd # report must stay plain text on stdout


def test_build_command_sets_working_root(tmp_path):
cmd = CodexAdapter().build_command("hello", workdir=tmp_path)
assert cmd[cmd.index("--cd") + 1] == str(tmp_path)


def test_prompt_is_last_arg_after_double_dash(tmp_path):
cmd = CodexAdapter().build_command("--looks-like-a-flag", workdir=tmp_path)
assert cmd[-2:] == ["--", "--looks-like-a-flag"]


def test_extract_report_is_stdout_passthrough():
assert CodexAdapter().extract_report("final message") == "final message"
14 changes: 12 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ def fake_execute_runs(**kwargs):
assert "Security Architecture Review" in result.stdout


def test_agents_command_lists_all_five_adapters():
def test_agents_command_lists_all_adapters():
result = runner.invoke(app, ["agents"])
assert result.exit_code == 0
for agent_id in ["claude", "agent", "agy", "gemini", "secfoo"]:
for agent_id in ["claude", "agent", "agy", "gemini", "secfoo", "codex"]:
assert agent_id in result.stdout


Expand Down Expand Up @@ -417,3 +417,13 @@ def test_mcp_sync_unsupported_agent_exits_nonzero(monkeypatch):
)
result = runner.invoke(app, ["mcp", "sync", "--agent", "agy"])
assert result.exit_code == 1


def test_mcp_sync_codex_is_reported_unsupported(monkeypatch):
servers = [MCPServerConfig(name="s", command="npx")]
monkeypatch.setattr(
"secfoo.cli.load_config", lambda: SecfooConfig(defaults=Defaults(), mcp_servers=servers)
)
result = runner.invoke(app, ["mcp", "sync", "--agent", "codex"])
assert result.exit_code == 1
assert "codex" in result.output
Loading