Skip to content

test(scan): cover imported finding paths before persistence - #866

Open
kevin9327 wants to merge 3 commits into
openai:mainfrom
kevin9327:fix/import-json-path-validation
Open

kevin9327 wants to merge 3 commits into
openai:mainfrom
kevin9327:fix/import-json-path-validation

Conversation

@kevin9327

@kevin9327 kevin9327 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Scan imports already validate findings against the shared current-finding contract before creating state. Add regression coverage for unsafe paths in a secondary location and in code evidence, so both dry-run and saved imports continue to reject them before persistence.

Changes

Extend the existing import-validation test table with two traversal-path cases. Each runs in dry-run and saved-import mode and verifies that the historical JSON reader accepts the artifact, while the import rejects it before resolving Python, invoking the workbench, or creating state and output directories. The source file remains intact.

Testing

Ran bun test --timeout 30000 ./tests-ts/findings-import.test.ts ./tests-ts/import-scan.test.ts ./tests-ts/cli-scan-import.test.ts from sdk/typescript, using a private temporary directory. The new rejection cases passed, along with existing real JSON and CSV import tests that verify persisted results, source retention, and indexing.

Risk and rollout

Test coverage only; no runtime changes. Import validation continues to use the shared contract, while historical JSON parsing remains compatible with its other consumers, including owner suggestions.

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.

`scan import --csv` refuses a row whose `path` escapes the repository,
is absolute, or carries a drive letter, backslash or control character.
The `--json` branch of the same command validated only against the
findings JSON schema, which constrains `locations[].path` to a non-empty
string, so the same path was accepted.

`--dry-run` therefore reported such a document as importable, and the
real import failed later in finalization with a message about findings
not being preserved, after the source had already been persisted and a
scan registered.

Apply the existing `safeFindingPath` check to imported JSON finding
locations, reporting the finding index the way the duplicate
`occurrenceId` check beside it already does.
@chatgpt-codex-connector

Copy link
Copy Markdown

Note

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added the bug Something isn't working label Sep 10, 2026
@mldangelo-oai mldangelo-oai changed the title fix(scan): reject unsafe finding location paths in imported JSON fix(findings): reject unsafe finding location paths in imported JSON Oct 8, 2026
@mldangelo-oai mldangelo-oai added area:findings Finding schemas, identity, deduplication, severity, and comparison decisions. and removed area:findings Finding schemas, identity, deduplication, severity, and comparison decisions. labels Oct 8, 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.

Reviewed 4ea06a6 with three independent source-review passes and synthesis. No P0/P1 findings were confirmed. Five focused finding-import tests passed in the completed review. Full integration and cross-platform validation remain outside this review.

@mldangelo-oai mldangelo-oai changed the title fix(findings): reject unsafe finding location paths in imported JSON test(scan): cover imported finding paths before persistence Oct 17, 2026
@github-actions github-actions Bot added skip-release-notes Omit internal changes from generated release notes and removed bug Something isn't working labels Oct 17, 2026

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

skip-release-notes Omit internal changes from generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants