codex-security README

项目的 README,来自 github.com/openai/codex-security。合并为一个 markdown 文件:README.md。

Codex Security

Codex Security helps you find, investigate, and fix vulnerabilities in your code. Use its security workflows in Codex, or automate them with the @openai/codex-security CLI and TypeScript SDK.

Features

Use in Codex

Open your repository in a Codex session with the Codex Security plugin enabled, then ask:

Run a Codex Security scan on this repository, focusing on authentication and authorization. Return the saved report, source evidence, and coverage limits.

A completed scan saves a report and findings. Read the report for source evidence and exclusions, then request a patch or ask Codex to verify an existing fix. See the agent workflow guide for setup, task selection, and recovery.

Quick start

Requires Node.js 22.13.0+ within 22.x, or Node.js 24.x or 26.x, and Python 3.10+. Python 3.10 also requires tomli.

Install the CLI globally and sign in:

npm install --global @openai/codex-security
cs login

Run your first scan from the repository directory:

cs scan .

When the scan completes, open the Markdown file at the REPORT path in the terminal. Run cs scans show from the same repository to find its latest completed scan again. See scan scope and follow-up work for how to interpret exclusions in the report.

cs and codex-security run the same CLI. If the short name conflicts with another command, use codex-security. To skip the global install, or if npm reports an EEXIST conflict, use npx @openai/codex-security in place of cs for both login and scanning.

For CI, set OPENAI_API_KEY or CODEX_API_KEY in the scan process's environment. For a headless machine, see device or SSH login.

Scan options

Choose a scope and scan mode:

# Scan selected paths.
cs scan . --path src --path tests

# Exclude a directory from the scan.
cs scan . --exclude-path examples/

# Scan committed changes from a base revision to HEAD.
cs scan . --diff origin/main

# Run a deep scan of the repository.
cs scan . --mode deep

Use cs scan . --max-time 15 for an advisory 15-minute Standard investigation allowance. See investigation time for timing semantics and Deep Scan limits.

Use cs --help to browse commands, or cs scan --help for scan options, cost limits, and patching after a scan.

For an application spread across repositories, see review one system across repositories. Use bulk scans for independent repository reviews in one resumable campaign.

Scans use existing root and component SECURITY.md guidance. To write or revise it, see Generate SECURITY.md.

Some cybersecurity requests and protected findings require Trusted Access for Cyber. For accounts with Daybreak access, see Daybreak opt-in for the Codex toggle and Cyber access programs to select a program explicitly.

TypeScript SDK

Install the package locally in your TypeScript project:

npm install @openai/codex-security

Then import it:

import { CodexSecurity } from "@openai/codex-security";

const security = new CodexSecurity();

try {
  const result = await security.run("/path/to/repository");
  console.log(result.reportPath);
} finally {
  await security.close();
}

The SDK guide includes deep-scan configuration, validation, severity classification, owner suggestions, and result handling.

Linked Git worktrees share scan history and saved findings when they use the same Codex Security state directory. Keep CODEX_SECURITY_STATE_DIR stable to retain that shared history and sign-in scope. See the scan history guide.

Read existing Cloud findings

When Codex Security Cloud is available to your account, the Security plugin's $cloud-findings skill can read findings, reports, recorded assignment and verification, and scan status in Codex desktop or the Codex CLI. Cloud is an optional connection; local scans work without it.

See Cloud connection setup and CLI reads for authentication requirements and a read-only example.

Generate SECURITY.md

Use policy to draft a new SECURITY.md or update an existing one. Use --path to select a component:

cs policy .
cs policy . --path services/api --knowledge-base architecture.md

The command saves its draft outside the repository and leaves existing files unchanged. Review the diff and notes, edit the draft, then copy only SECURITY.md to the displayed Policy target. Keep the saved architecture and threat-model documents outside the repository.

Scans already use root and component SECURITY.md files. Keep your current policy if it needs no changes. When updating it, preserve its vulnerability-reporting instructions. If the command says the policy is already up to date, no copy is needed.

Files at .github/SECURITY.md or docs/SECURITY.md often contain reporting instructions. Preserve them when drafting a policy; those locations do not automatically provide repository-wide scan guidance. See the policy guide for policy locations, unanswered questions, saved artifacts, and SDK usage.

Save and export threat models

Scans and policy generation save threat models with their results. Export a saved model without starting another analysis:

cs export --scan SCAN_ID --artifact threat-model --output threatmodel.md

Omit --scan to use the current repository's latest completed scan. The export guide also covers findings, SARIF output for CI, and the offline TypeScript API. For ServiceNow Application Vulnerability Response, see Export findings for ServiceNow.

GitHub Actions

To run a weekly repository scan on GitHub-hosted Ubuntu:

  1. Add an OpenAI API key as the repository secret CODEX_SECURITY_API_KEY.
  2. Copy the weekly workflow to .github/workflows/codex-security.yml. Replace REPLACE_WITH_REVIEWED_COMMIT with the reviewed distribution commit SHA from an Action release.
  3. To try the workflow before the next scheduled run, open Actions → Codex Security repository → Run workflow.

The example uses an estimated $5 limit per scan and reports findings without failing the job. Requests in progress can exceed the limit. For a severity threshold, pull request checks, or runner requirements, see the Action guide. For eligible accounts, see Daybreak access.

Containerized bulk scans

Scan a list of repositories with the included Docker Compose configuration, which keeps results and authentication between runs. See the container quick start. The workflow runner runs individual CLI stages in containers and can connect to a separately deployed findings service.

Findings storage and deduplication

The findings guide covers local storage, deduplication, and compatibility with independently operated endpoints through publish scan --to custom and explicit --findings-url. The local serve command and browser dashboard have been removed; existing databases and scan artifacts remain available.

Other providers

Scans support OpenAI, Amazon Bedrock, OpenRouter, and Fireworks AI. Bedrock uses AWS credentials and does not require a separate OpenAI login. See Bedrock setup for AWS profiles, regions, and model access.

For OpenRouter and Fireworks AI, set the provider's API key and choose a supported model. See provider configuration for examples.

Documentation

To report a vulnerability privately, follow the security policy.

Citation

Use Cite this repository on GitHub to copy an APA or BibTeX citation, or download CITATION.cff. Match the citation’s version to codex-security --version and use the publication date from that version’s npm-vX.Y.Z entry in GitHub Releases.

codex-security (openai/codex-security)

正在搜索数据库…

这是什么?Codex Security 是 OpenAI 推出的命令行工具和 TypeScript SDK,用于定义安全策略,并在代码中发现、验证和修复安全漏洞。
它是命令行工具、SDK,还是两者都是?两者都是:既可以在终端中运行的命令行工具,也可以作为 JavaScript 包安装的 TypeScript SDK;另外还提供基于 Docker 的扫描器和检测结果服务,适用于规模更大的部署。
我该怎么把它跑起来?安装 @openai/codex-security npm 包,然后运行快速开始命令,生成 SECURITY.md 并开始扫描;如需批量扫描多个代码仓库,请使用随附的 Docker Compose 配置。
我需要先安装什么?还需要登录吗?你需要先安装 Node.js 22.13.0 或更高版本,以及 Python 3.10 或更高版本;交互使用时需要登录,在持续集成(CI)中则需要设置 OpenAI API 密钥。
它能扫描或报告的内容有限制吗?部分网络安全相关请求和受保护的检测结果需要先通过 OpenAI 的 Trusted Access for Cyber 计划审批,才能使用。
我的扫描结果存在哪里?检测结果服务会将检测结果及其嵌入向量存储在本地 SQLite 中,并提供一个只读仪表板,每五秒刷新一次,显示已存储的检测结果和重复组。
我能一次扫描很多代码仓库吗?可以,随附的 Docker Compose 配置专门用于通过扫描器镜像对多个代码仓库进行容器化批量扫描。
我只能使用 OpenAI 的模型吗?不是,你可以设置其他推理服务商的 API 密钥并选择其模型,切换到该服务商。
classify-severity 命令有什么作用?codex-security classify-severity 可让你按照自己的策略评分标准,对选定的检测结果进行评估,然后再发布工单;结果会按每次扫描缓存,重新运行时会复用,除非你传入 --reprocess。
检测结果如何发布或分享?codex-security publish scan --to custom --findings-url 命令会将已完成的检测结果及其代码仓库 ID 上传到检测结果服务,该服务还支持通过嵌入向量相似度进行去重。
作者
openai
大小
92.1 MB
星标
14.4K
时长
4个月
提交 · 90 天