Skip to content

feat(cli): generate and review SECURITY.md - #489

Open
mldangelo-oai wants to merge 20 commits into
agent/threat-model-evidencefrom
mdangelo/codex/security-policy-command
Open

feat(cli): generate and review SECURITY.md#489
mldangelo-oai wants to merge 20 commits into
agent/threat-model-evidencefrom
mdangelo/codex/security-policy-command

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add codex-security policy to generate or update a repository's SECURITY.md from its source code. It maps how the system works, builds a detailed threat model, and drafts a short policy for owner review. In a terminal, it asks about important facts the code cannot establish, shows the exact proposed changes, and asks before writing. Codex has read-only file access while drafting. Future scans read the approved policy.

This PR builds on #485 and targets that branch until it merges. The command is called policy because SECURITY.md is the file developers maintain. The detailed threat model stays in a separate draft directory.

Changes

Once released, run it for a whole repository or one component:

npx @openai/codex-security policy .
npx @openai/codex-security policy . --path services/api

To save a draft for later review:

npx @openai/codex-security policy . --headless --output-dir /path/outside/repository/policy --json
# Review or edit the saved SECURITY.md.
npx @openai/codex-security policy . --apply /path/outside/repository/policy --write

Use the same repository and --path when applying a component draft. Applying does not call the model. It checks that the original and inherited policies have not changed, writes the reviewed text, and confirms that later scans can read it. It protects neighboring components and separate reporting policies from accidental changes. Linked worktrees and submodules keep their own policy roots, while draft output and policy-link checks still protect enclosing checkouts. Updates keep the previous file and report its location so late editor saves remain recoverable.

The SDK exposes the same generate, preview, and apply steps. The command offers the existing sign-in chooser when both ChatGPT and an API key are available. Use --knowledge-base for architecture documents, --max-cost for a generation budget, or --dry-run to check inputs without starting Codex. --format md prints the draft. Both READMEs explain the workflow.

To try this PR before release:

cd sdk/typescript
pnpm install --frozen-lockfile
pnpm run build
node bin/codex-security.mjs policy /path/to/repository

Testing

  • Focused policy and target suites: 149 passed, 0 failed. Covers policy links, repository boundaries, saved drafts, concurrent edits, Git worktrees and submodules, Python selection, and component names beginning with - or ~. The existing scan archive test also passes.
  • Full normal and randomized suites: each had 1,427 passed, 11 skipped, and 0 failed.
  • Types, formatting, build, and git diff --check: passed.
  • Package validation and installed-package smoke test: passed.
  • Local Linux ARM64 container build and offline smoke test: passed. The build now installs Python for the policy checks. Windows fixtures use portable newline and path assertions, and the parallel-scan test waits for both scans instead of using a timer.
  • Live generation on a synthetic repository: passed. Checked source citations and unchanged source before approval. Reused that saved draft to check exact written contents, stale-policy rejection, cancellation, recovery, and the built CLI on this commit. All passed.
  • Independent local review of 5c0acd8c: three clean passes, followed by a separate verification of all review outputs.

Risk and rollout

Merge #485 first, then change this PR's base to main. This adds no npm dependencies and does not change the saved scan format. It reuses the existing Codex runtime and security-policy resolver. The full scan tests cover the shared code changes; GitHub CI also runs the supported Windows configurations.

Generated policy decisions need owner review. Threat scenarios are not confirmed vulnerabilities. Keep the detailed threat model and other draft files private until someone reviews them for disclosure. This PR does not publish a package or deploy the external documentation.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, b1de4d9394c8c8ef7a155d0246735405186c9a11.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: b1de4d9394

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: b1de4d9394

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread sdk/typescript/src/security-policy.ts

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 5c0acd8.

@mldangelo-oai
mldangelo-oai marked this pull request as ready for review August 17, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant