Security CLI 把结果写到仓库外,先 --dry-run
npx @openai/codex-security 是另一套扫描产品,不是编码 CLI。只扫你有权评估的仓。CI 把二进制装在 checkout 外面。
需要 Codex Security 权限。Node 22.13+ / 24 / 26,扫描还要 Python 3.10+。
npx @openai/codex-security --version
npx @openai/codex-security login # 无头用 --device-auth
REPOSITORY=/path/to/repository
SCAN_DIR=/path/outside/repository/codex-security-results
npx @openai/codex-security scan "$REPOSITORY" --output-dir "$SCAN_DIR" --dry-run
npx @openai/codex-security scan "$REPOSITORY" --output-dir "$SCAN_DIR"
npx @openai/codex-security scan "$REPOSITORY" --diff origin/main --head HEAD
npx @openai/codex-security install-hook
--dry-run 只校验输入,不加载凭据。省略 --output-dir 会写进产品自己的状态目录。报告含源码摘录,目录不要放进仓里。同时有 API key 又想用 ChatGPT 登录时加 --auth chatgpt。
CI 把包装到 $RUNNER_TEMP(或 /tmp),用绝对路径跑,密钥映射成扫描进程的 OPENAI_API_KEY,并 --auth api-key。--json 打出一份完整 JSON(不是 codex exec 那种 JSONL)。--fail-on-severity high 才会让检查失败。fork / Dependabot 不要带密钥。