Skip to content

feat(cli): add interactive finding review, patching, and optional PRs - #461

Merged
ianw-oai merged 5 commits into
mainfrom
dev/ianw/interactive-scan-patching
Aug 18, 2026
Merged

feat(cli): add interactive finding review, patching, and optional PRs#461
ianw-oai merged 5 commits into
mainfrom
dev/ianw/interactive-scan-patching

Conversation

@ianw-oai

@ianw-oai ianw-oai commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

After a security scan finishes, choose which findings to fix, generate and check the fixes, and optionally open a GitHub pull request. The same flow also works without prompts and with findings from earlier scans.

Each selected finding runs in its own saved Codex task, which appears in the Codex desktop app.

Changes

Review findings after a scan

npx @openai/codex-security scan .

The scan prints its usual findings, then asks whether to review and patch them. Scans with no findings do not ask.

 CODEX SECURITY  example-app                         3/3 selected · low and above

 ╭─ FINDINGS ─────────────────────────────╮ ╭─ DETAILS ─────────────────────────╮
 │ › [✓] CRITICAL SQL injection in search │ │ SQL injection in account search   │
 │   [✓] HIGH Missing admin authentication│ │                                   │
 │   [✓] MEDIUM Stack trace in response   │ │ SUMMARY                           │
 │                                        │ │ Search input enters a SQL query.  │
 │                                        │ │                                   │
 │                                        │ │ SEVERITY        ● Critical        │
 │                                        │ │ CONFIDENCE      ● High            │
 ╰────────────────────────────────────────╯ ╰───────────────────────────────────╯

 ╭─ PATCH INSTRUCTIONS ──────────────────────────────────────────────── i edit ─╮
 │ Add instructions for this finding.                                          │
 ╰──────────────────────────────────────────────────────────────────────────────╯

 [ ] Create GitHub pull request after patching                  (r toggle)
 ↑↓ browse · Tab details · Space select · 1–4 severity · Enter patch

Choose a severity, select individual findings, inspect the surrounding code, and give the patch instructions for each finding:

 CODEX SECURITY  example-app                        2/3 selected · high and above

 ╭─ FINDINGS ─────────────────────────────╮ ╭─ DETAILS ─────────────────────────╮
 │ › [✓] CRITICAL SQL injection in search │ │ src/accounts.ts:7–8               │
 │   [✓] HIGH Missing admin authentication│ │   5 │ const user = requireUser(); │
 │   [ ] MEDIUM Stack trace in response   │ │   6 │ const term = query.search;  │
 │                                        │ │ › 7 │ const sql = `...${term}`;   │
 │                                        │ │ › 8 │ return database.query(sql); │
 ╰────────────────────────────────────────╯ ╰───────────────────────────────────╯

 ╭─ PATCH INSTRUCTIONS ────────────────────────────────────────────────────────╮
 │ Use the shared parameterized query helper.                                   │
 ╰──────────────────────────────────────────────────────────────────────────────╯

 [✓] Create GitHub pull request after patching

After you press Enter, each selected finding gets its own saved Codex task in the desktop app. Each task runs the bundled codex-security:fix-finding skill with that finding and its instructions. Tasks run one at a time in the same checkout, and a failed finding does not stop the remaining tasks. The scan has already validated its findings, so patching does not run a separate validation command. A fix is accepted only when the task reports how it verified the change.

Patch automatically

# Fix all confirmed findings without opening the review screen.
npx @openai/codex-security scan . --headless --patch

# Fix only high and critical findings, without opening the review screen.
npx @openai/codex-security scan . --headless --patch --patch-severity high

Patch findings from an earlier scan

npx @openai/codex-security patch occ_EXAMPLE
npx @openai/codex-security patch --scan latest --severity high
npx @openai/codex-security patch --scan SCAN_ID --severity high --json

Open a pull request after verified fixes

npx @openai/codex-security scan . --patch --patch-severity high --create-pr
npx @openai/codex-security patch --scan latest --severity high --create-pr

Only verified fixes are committed. Existing staged changes are left alone. The existing Linear issue and project patch commands still work; automatic pull request creation applies to saved scan findings.

Retry a failed push or pull request

If publication fails, run the command printed by the CLI from the same repository:

npx @openai/codex-security patch --resume-pr codex-security/patch-SCAN_ID

This reuses the saved commit without running Codex again. It refuses to publish a changed branch and returns the existing PR if one was already created.

Testing

  • Node CI passed, including Windows on Node 22 and 24.
  • Full local suite: 1,376 passed, 15 skipped, zero failures. Includes publication retries, interactive review, separate saved tasks, Linear patching, and project-trust checks.
  • pnpm run types
  • pnpm run format
  • pnpm run build
  • pnpm run check:package ../../dist/openai-codex-security-0.1.14.tgz

Risk and rollout

Patching and pull request creation are optional. Incomplete scans are not patched. Saved Codex tasks can contain finding details. Code shown in the review stays inside the scanned repository. Existing Linear patching, authentication, project trust, and failure behavior are preserved. Saved findings and Linear issues cannot be mixed in the same patch command.

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.

@ianw-oai ianw-oai changed the title [codex] Add interactive and automated security finding patches feat(cli): add interactive and automated finding patching Aug 15, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Aug 15, 2026
@ianw-oai
ianw-oai force-pushed the dev/ianw/interactive-scan-patching branch from 6ab52c3 to 93e9967 Compare August 16, 2026 03:41
@ianw-oai ianw-oai changed the title feat(cli): add interactive and automated finding patching feat(cli): scan, review, patch, and create pull requests Aug 16, 2026
@ianw-oai ianw-oai changed the title feat(cli): scan, review, patch, and create pull requests feat(cli): add interactive finding review, patching, and optional PRs Aug 16, 2026

@mldangelo-oai mldangelo-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking QA notes on draft 93e99673. The saved-finding patch flow, selection and cancellation UI, and successful local Git publication path worked with synthetic fixtures. The full local suite passed 1,316 tests with 11 skipped. Git used a local remote, and PR creation used a test double, so this was not a live GitHub PR test.

I'd split the work at the patch result: return one structured result for saved findings, literal issues, and Linear input, then let a separate publication step consume it. The saved-finding-only --create-pr path does not yet join up with #475 and #477.

Two concrete Windows follow-ups: use platform-resolved paths in the new tests, and add *.tsx text eol=lf to .gitattributes. The new TUI file passes formatting with LF and fails with CRLF. The current Windows checks still fail. I left the recovery and simplification suggestions inline.

Comment thread sdk/typescript/src/cli.ts Outdated
Comment thread sdk/typescript/src/cli.ts
Comment thread sdk/typescript/tests-ts/cli-patch.test.ts Outdated
Comment thread sdk/typescript/src/patch-tui.tsx
@ianw-oai
ianw-oai force-pushed the dev/ianw/interactive-scan-patching branch from 93e9967 to 648adac Compare August 16, 2026 06:38
@ianw-oai
ianw-oai changed the base branch from main to dev/ianw/show-patch-tasks-in-codex August 16, 2026 06:39
Base automatically changed from dev/ianw/show-patch-tasks-in-codex to main August 17, 2026 17:48
@ianw-oai
ianw-oai force-pushed the dev/ianw/interactive-scan-patching branch from 648adac to 21a792c Compare August 17, 2026 18:07
@ianw-oai
ianw-oai force-pushed the dev/ianw/interactive-scan-patching branch from 21a792c to e616944 Compare August 18, 2026 14:54
@ianw-oai
ianw-oai marked this pull request as ready for review August 18, 2026 17:55
@ianw-oai
ianw-oai merged commit 6a50006 into main Aug 18, 2026
37 checks passed
@ianw-oai
ianw-oai deleted the dev/ianw/interactive-scan-patching branch August 18, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants