Skip to content

feat(cli): browse historical security findings - #275

Open
mldangelo-oai wants to merge 83 commits into
mainfrom
mdangelo/codex/findings-history-discovery
Open

feat(cli): browse historical security findings#275
mldangelo-oai wants to merge 83 commits into
mainfrom
mdangelo/codex/findings-history-discovery

Conversation

@mldangelo-oai

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

Copy link
Copy Markdown
Collaborator

Summary

Browse saved findings by repository or scan, with consistent occurrence history and triage across lists, details, comparisons, CSV exports, and remediation. Preserve saved details when a checkout is offline while keeping replaced checkout owners isolated.

Changes

  • Extend findings list [REPOSITORY] with --scan, --all-repositories, query/severity/status filters, and pagination. Repository views default to open findings; scan views include all findings. Pages default to 20 and honor larger --limit N values. Home-relative repository paths use the existing CLI path resolver.
  • Add findings show OCCURRENCE_ID and scans show latest. Preserve JSON pagination and automatic paging for the unfiltered interactive repository view.
  • Show effective filters, occurrence IDs, and triage status in terminal views. Make empty pages explain how to restart, expose linked occurrence IDs, and document command defaults, model use, and the SDK history-browsing gap.
  • Share repository scoping across history queries, including registered worktrees, clones, legacy descendants, and recorded ownership epochs. Retain saved comparisons and linked history when a checkout is unavailable, after checking each recorded owner.
  • Aggregate stable and confirmed finding matches without collapsing explicitly uncertain matches. Show the full matched history and use the same triage decision in details, comparisons, and CSV exports. Respect complete scan coverage, explicit reopening, rediscovery after fixed/false-positive decisions, and pending remediation.
  • Apply explicit triage actions to every matched occurrence in scan order so repository, global, and target-filtered views agree. Preserve their existing result counts and remediation checks.
  • Remove the duplicate findings-index path and redundant schema probes. Move finding-detail and artifact projection into a separate module to keep the database module within the portable source budget. Keep existing artifact and credential protections.
  • Share one CLI list flow and paging helper, and remove duplicate triage lookups and representative-only update branches.
  • Sync main and the canonical plugin layout. Bump the bundled plugin to 0.1.88 so cached installations load the updated history modules.
  • Update the Windows scan-root test schema and publish the process-test PID file atomically so an empty file cannot signal readiness.

Testing

  • Full SDK suite with seeds 12345 and 809688597: 2,178 passed, 43 skipped, and no failures in each run.
  • Full plugin Python suite: 1,091 passed, 5 skipped, and 104 subtests passed. Portable-source checker tests: 9 passed.
  • Focused history/ownership/triage/remediation regressions: 151 passed, including closing and reopening matched findings across worktree, global, and target-filtered views.
  • MCP suite: 23 passed.
  • Type/model checks, formatting, Ruff, and portable source compatibility: passed.
  • Packed-artifact inspection and full installed-package smoke: passed, including CLI, NodeNext types, credential locking, all 123 bundled plugin files, MCP initialization, and a nested Codex worker.
  • Built CLI with synthetic saved scans: terminal help, defaults, filters, pagination, finding details, and error recovery passed. All 13 JSON read workflows returned identical data before and after the follow-up changes.

Risk and rollout

This extends the public history CLI with the syntax above and removes the fixed collection-page cap; the default remains 20. The UX cleanup preserves accepted values, defaults, and JSON response fields. There is no database migration or npm package-version change. Completed artifacts, credentials, sealed-artifact checks, and ownership boundaries remain protected. Cached plugin upgrades from 0.1.79, 0.1.85, 0.1.86, and 0.1.87 are covered. Cross-platform CI and Codex reviews run on the pushed head.

Public disclosure review

Existing automated review comments contain access-restricted report references, so the second attestation remains unchecked.

  • 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.

@github-actions github-actions Bot added the enhancement New feature or request label Aug 4, 2026
@mldangelo-oai
mldangelo-oai requested a review from Copilot August 4, 2026 07:23
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Copilot AI 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.

Pull request overview

This PR adds first-class CLI support for browsing historical scan findings, including repository-scoped and scan-scoped finding lists, a dedicated finding-details view, and improved scan-history rendering that makes follow-up actions (pagination, details, matching, comparison) more discoverable.

Changes:

  • Introduces codex-security findings list / findings show flows (plus findings defaulting to list) and enhances scans show to support a “latest completed scan” default.
  • Extends the TypeScript renderer to format saved-findings pages and full finding details (locations, evidence, remediation guidance, history links, pagination hints).
  • Expands the bundled Python workbench to support get-finding, richer scan-history scoping for moved/nested checkouts, and global findings indexing improvements (including secondary-location search).

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/typescript/tests-ts/workbench-findings-index.test.ts Adds regression coverage for global findings indexing (scoping, filtering, coverage-read behavior, tamper/noncanonical handling, detail vs preview completeness).
sdk/typescript/tests-ts/scan-history-renderer.test.ts Adds renderer coverage for actionable findings/history output, pagination hints, triage precedence, and next-command suggestions.
sdk/typescript/tests-ts/runtime.test.ts Adds coverage ensuring large get-finding responses are allowed while oversize non-detail workbench responses fail safely without leaking content.
sdk/typescript/tests-ts/cli.test.ts Updates CLI manifest assertions for new findings commands and revised scans show signature.
sdk/typescript/tests-ts/cli-findings.test.ts Adds CLI tests for repository scoping, paging/filter validation, scan selection, and “latest scan” behavior.
sdk/typescript/src/scan-history-renderer.ts Implements new findings/finding render modes, checkout scoping helpers, and improved list/show guidance (pagination, matching, compare suggestions).
sdk/typescript/src/runtime.ts Adds separate workbench stdout limits for list-style commands vs get-finding, with safer maxBuffer error redaction.
sdk/typescript/src/cli.ts Adds findings list/show commands, defaults findings/scans to list, and supports scans show without an explicit scan ID (latest completed).
sdk/typescript/README.md Documents the new scan-history and findings browsing commands and how to page/filter results.
sdk/typescript/_bundled_plugin/scripts/workbench_scan_history.py Improves repository scoping to handle moved checkouts, nested boundaries, and reused paths more safely; includes currentTargetPath projection.
sdk/typescript/_bundled_plugin/scripts/workbench_native_indexes.py Adds multi-target support, legacy-path support, and secondary-location searching for global findings queries.
sdk/typescript/_bundled_plugin/scripts/workbench_db.py Adds get-finding, supports full-details finding serialization, and strips forged metadata fields from stored details while preserving authoritative triage.
sdk/typescript/_bundled_plugin/scripts/workbench_cli.py Extends the workbench CLI surface with get-finding and multi-valued --target-id/--target-path for global findings.
README.md Updates top-level docs to mention scans show latest behavior and the new findings browsing commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_scan_history.py Outdated
Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_native_indexes.py Outdated

@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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 223ecf3e75

ℹ️ 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".

Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_scan_history.py Outdated
Comment thread sdk/typescript/src/scan-history-renderer.ts Outdated
Comment thread sdk/typescript/src/scan-history-renderer.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 223ecf3e75

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.

@mldangelo-oai
mldangelo-oai requested a review from Copilot August 4, 2026 08:11
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

@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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0dc21af02

ℹ️ 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".

Comment thread sdk/typescript/src/cli.ts Outdated
Comment thread sdk/typescript/src/runtime.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: f0dc21af02

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: dc1e121a3d

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.

@kmbroai kmbroai 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.

Reviewed head dc1e121a3d111b5adb9991562a52350c9e9b252e for correctness, necessity, and simplification.

[P2] Ship the changed workbench under a fresh plugin version

Both this head and its base declare bundled plugin 0.1.20. I ran this head's actual bootstrapPlugin with the local native Codex installer: install the base bundle into a new isolated home, then bootstrap this bundle into the same home. The installed workbench_db.py still had the base hash, not this PR's hash. In particular, the new aggregate-status check in require_finding_open was present in the source bundle but absent from the installed workbench.

This matters beyond browser appearance: the SDK's direct workbench calls can use the new bundled code while the installed MCP workbench retains the old per-occurrence remediation guard. A finding dismissed through a matched occurrence can consequently be presented as closed by the new projection without the installed helper receiving the corresponding guard fix. Bump both version declarations, or explicitly land only as part of a coordinated fresh-version release. Test an upgrade from an already installed bundle, not just a clean install. No model call was needed for this cache reproduction.

Current correctness and prior feedback

I checked the full comment history against the current source rather than repeating old findings. The repository-plus---scan conflict is now rejected; aggregate triage reaches remediation checks; targetless scan details use the shared index; grouped counts distinguish occurrences from distinct scans; and the pagination documentation explains repeated nextOffset traversal. A direct SQLite/Git fixture also confirmed that the latest legacy-child/registered-ancestor complaint is fixed: both the modern ancestor scan and legacy child scan are selected.

Necessity and simplification

Finding IDs, full detail, filtering, and explicit pagination are useful additions. This PR also rewrites repository ownership discovery, active/resolved projection, semantic grouping, triage propagation, and scan ordering. Those are correctness changes, not merely a browser, and should be separated from terminal presentation where practical.

Use #456's generation/scope model as the shared foundation instead of maintaining a second ownership-epoch implementation here. Preserve one aggregate-status computation for lists, details, and action guards. The TTY-only auto-pagination loop is optional convenience; a consistently paged interface would remove a special execution path and repeated index reconstruction without losing access to any finding.

Verification

Four focused index, repository-findings, CLI, and renderer suites: 71 passed, 0 failed, with cached dependencies. Also ran the ancestor-scope and real local plugin-upgrade probes. No production history, live remediation, or native Windows execution was exercised.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T08:24:34.392990Z 8b1105e Manual request
🔒 Security Review Completed 2026-08-30T08:30:50.646113Z 8b1105e New commits

Security findings

Advisory findings (7)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review the current head 2758576.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 275857616b

ℹ️ 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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf65c935b9

ℹ️ 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".

Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_scan_history.py Outdated
Comment thread sdk/typescript/src/cli.ts Outdated

@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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b9f7772f2

ℹ️ 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".

Comment thread sdk/typescript/src/cli.ts Outdated
Comment thread plugins/codex-security/scripts/workbench_scan_history.py

@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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea7b063899

ℹ️ 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".

Comment thread sdk/typescript/_bundled_plugin/scripts/workbench_db.py Outdated
@kmbroai

kmbroai commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Non-CI blockers on exact head ea7b0638 that should be addressed before merge:

  1. Keep legacy scan history inside the verified checkout owner. repository_scan_scope excludes only an exact-path owner, so a targetless child scan from a previous owner can still be selected; get-scan then returns its saved findings/configuration without the ownership check used by get-finding. Exclude targetless scans claimed by any registered ancestor and apply the same owner verification before returning scan details.

  2. Make an explicit reopen override aggregate triage. set_finding_triage compares the requested state only with the selected occurrence's local row. If that row is already locally open while a matched occurrence supplies the newer aggregate closure, no decision is appended and the finding remains closed. Compare against aggregate state, or always record an explicit decision when the requested aggregate state differs.

  3. Preserve home-relative repository paths. findings list ~/repo used to go through resolveCliPath; the new plain resolve() call interprets it as <cwd>/~/repo. Reuse resolveCliPath here.

  4. Keep saved comparisons readable when the checkout is unavailable. _same_registered_repository rejects a failed stat() before compare_scans reads a cached comparison. Use the latest recorded ownership epoch when the path is absent, while continuing to reject an existing path with a conflicting identity.

  5. Remove the arbitrary 20-row maximum. Keeping 20 as the default page size is fine, but rejecting --limit 100 and clamping direct workbench callers forces unnecessary requests and conflicts with the package rule against arbitrary local-input limits.

The branch is also currently merge-conflicting. When updating it to current main, please apply the plugin changes in the canonical plugin source and regenerate the bundled SDK payload rather than treating the generated copy as the owner.

I independently reproduced the ownership-scope selection, explicit-reopen no-op, and unavailable-checkout comparison failures. The five corresponding review threads remain unresolved on this head.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Current head: 85a5ce80c74c363d4cfc4a7b464141378fdcc3ba.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex security review

Current head: 85a5ce80c74c363d4cfc4a7b464141378fdcc3ba.

@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 Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85a5ce80c7

ℹ️ 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".

Comment thread plugins/codex-security/scripts/workbench_db.py Outdated
Comment thread plugins/codex-security/scripts/workbench_db.py
Comment thread plugins/codex-security/scripts/workbench_finding_results.py
@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Current head: fc0d75a04b8ac238b3d1ee8af1b16e5e88b3a329.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex security review

Current head: fc0d75a04b8ac238b3d1ee8af1b16e5e88b3a329.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Unknown error
ℹ️ 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: fc0d75a04b

ℹ️ 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".

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

Please review the current head, 8b1105e4f80096a8af4a52d0ab3f14e5686ee81a, including the shared CLI paging flow and explicit triage across matched occurrences.

@mldangelo-oai

Copy link
Copy Markdown
Collaborator Author

@codex security review

Please review the current head, 8b1105e4f80096a8af4a52d0ab3f14e5686ee81a, including the preserved ownership and remediation checks around matched finding triage.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 8b1105e4f8

ℹ️ 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".

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.

5 participants