Skip to content

feat(imports): support OpenGrep reports locally and in Cloud - #1872

Open
mldangelo-oai wants to merge 2 commits into
mainfrom
mdangelo/codex/opengrep-imports
Open

mldangelo-oai wants to merge 2 commits into
mainfrom
mdangelo/codex/opengrep-imports

Conversation

@mldangelo-oai

@mldangelo-oai mldangelo-oai commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Import native OpenGrep JSON, plain or gzip-compressed, into the local workbench or publish it to Cloud. Imports preserve scanner evidence, including ignored matches and raw severity. They leave findings unassessed.

Changes

  • codex-security publish findings accepts --provider opengrep with --to local or --to cloud and requires --source-repository-url. Set CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1 in the command environment to enable external imports. Local imports check that URL against configured Git remotes even when no findings are ready. SDK callers can use normalizeOpenGrepFindings and readOpenGrepFindings.
  • Both destinations use the existing semgrep provider and record OpenGrep as the scanner origin. The importer groups traces by rule, path and source range, so a change in scanner fingerprints or result order does not create a second record.
  • An invalid trace does not hide valid siblings. Exclusions identify the input position and reason. Local imports can retain evidence over 256 KiB; Cloud excludes the occurrence if traces that each fit on their own exceed that limit together.
  • Previews and results return the scanner's report metadata once. Each finding stores its original observations, scanner version and diagnostic count. Diagnostics survive readback retries, and saved publication JSON keeps the message from JavaScript Error values inside scanner diagnostics. If only a scanner diagnostic changes, Cloud treats the report as a different publication. Retrying the original report resumes its saved upload without sending the findings twice.

Testing

  • Tested the PR with main at 796fa130: OpenGrep 1.32.0 scanned two synthetic Python taint flows, one in a subdirectory and one in a filename with a literal backslash. Both import targets preserved the distinct occurrence IDs, paths and raw traces across JSON, gzip and reversed result order. Local SQLite import created two unassessed records; replay left both unchanged. Local import rejected a mismatched source repository for both an empty report and one with all results excluded.
  • Source CI passed on Linux, macOS and Windows for head 2e579df0 tested with main at 34c97c82. The regression cases cover gzip input, SQLite import and replay, trace exclusions at the Cloud boundary, and a readback retry that preserves diagnostics without uploading the same finding twice.
  • The local npm archive contained both reader modules, their declarations and maps. The hosted installed-package check loaded both OpenGrep SDK exports and compiled the TypeScript consumer. Cloud publication and readback used a fake transport; a live Cloud import was not run.

Risk and rollout

The reader-routing prerequisite has merged; this PR targets main. Cloud deployments must already support the Semgrep import contract. Moving a match creates a new occurrence; omitting it from a later report does not close the old one. A completed upload does not establish scan coverage or an assessed severity.

Public disclosure review

One attestation remains open for existing CI output.

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

@alandelong-oai alandelong-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.

Thanks for adding OpenGrep imports. This owner-level merge-safety review found one packaging blocker: both new modules need entries in the distribution manifest before the package and container checks can pass. Details are inline.

The 141 reader tests, 46 base/head Semgrep parity cases, 13 built API/CLI preview controls, builds, types and formatting passed. Packing succeeds, but archive validation fails locally with the same unexpected-file error as CI. Persistence roundtrips remain unverified locally: filesystem trust guards stopped the direct cases, and the local CLI import test exited 2. Cloud controls used a synthetic transport; no live upload was tested.

Comment thread sdk/typescript/src/index.ts

@alandelong-oai alandelong-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.

Thanks for fixing the package manifest and extending the installed-consumer checks. Both new modules now ship with their declarations and maps, and the earlier packaging finding is fixed. I reviewed all 20 changed files and found no remaining material issue.

Fresh validation passed: 141 reader tests, 100 package regressions, 46 base/head Semgrep parity cases, builds, types and formatting; actual archive validation; and installed exports, native loading, CLI previews and strict TypeScript consumers. The hosted package build and four Ubuntu installed-package jobs also passed.

The remaining hosted matrix is still running. I did not rerun the full local SDK or installed smoke suites, or qualify SQLite/Cloud write roundtrips locally; earlier protected-fixture failures remain a local coverage limit. No live scanner, Cloud account or model was used.

@mldangelo-oai
mldangelo-oai marked this pull request as ready for review October 23, 2026 07:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-10-25T21:02:04.508861Z 02a2137 New commits
🔒 Security Review ✅ Completed 2026-10-25T21:01:59.733836Z 02a2137 New commits
ℹ️ 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.

@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: 12a3bb5da7

ℹ️ 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/external-findings-read.ts Outdated
Base automatically changed from mdangelo/codex/import-reader-routing to main October 23, 2026 20:02
@github-actions github-actions Bot added the enhancement New feature or request label Oct 23, 2026

@alandelong-oai alandelong-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.

Thanks for the updates. The grouped OpenGrep evidence, report diagnostics, source provenance, and Semgrep compatibility paths look sound. Reader tests, base/head compatibility comparisons, type/format checks, portable checks, and the package archive validation passed. Local storage and persisted Cloud roundtrips remain limited by this runner’s filesystem protections; the broader installed-package smoke stopped at an unrelated Git fixture check.

@mldangelo-oai
mldangelo-oai force-pushed the mdangelo/codex/opengrep-imports branch from 2e579df to 5019bd1 Compare October 25, 2026 20:48

@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: 5019bd1099

ℹ️ 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 on lines +175 to +181
id = stableId("opengrep-location", [
parsed.rule,
parsed.path ?? parsed.rawPath,
parsed.line,
parsed.column,
parsed.endLine,
parsed.endColumn,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve distinct matches sharing a source range

When OpenGrep emits multiple matches for the same rule and source range but with different metavariable bindings, their fingerprint bases distinguish separate findings; this key ignores the fingerprint entirely and groups every such result into one record. projectGroup then publishes only one source finding and selects one observation for the typed evidence, so local and Cloud imports silently collapse distinct scanner results. Include the stable portion of the fingerprint in the identity while removing only its unstable occurrence counter.

Useful? React with 👍 / 👎.

Comment thread sdk/typescript/src/external-findings-read.ts
Comment thread sdk/typescript/src/external-findings-publish.ts

@alandelong-oai alandelong-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.

Thanks for the OpenGrep support. No material issues found. Location-based grouping preserves the raw observations, imports stay unassessed behind the existing opt-in, and checkpoint identity now separates changed diagnostics while preserving report-free compatibility.

Focused import, preview and checkpoint checks, builds, type/format checks and portable source checks passed. Persisted roundtrips and complete installed-package smoke coverage remain limited by filesystem fixtures here; current hosted CI is still running.

This branch has not been deployed

No deployments
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