Conversation
`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.
|
Note You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codex-security scan importhas two input branches in one function. The CSV branch validates each row'spathwithsafeFindingPath, which rejects an absolute path, a drive letter, a backslash, a control character, or a path that walks out of the repository. The JSON branch validates only againstfindings.schema.json, wherelocations[].pathis{"type": "string", "minLength": 1}.The same location path is therefore rejected by
--csvand accepted by--json. Because--dry-runis documented as "Validate the input without saving a scan", the practical effect is that the dry run reports a document as importable when the import cannot succeed: the real run gets as far as finalization, where the plugin's_require_safe_relative_pathrejects the path, and fails withImport finalization did not preserve every input finding; the scan was not completed.— after the source has been persisted under the state directory and a scan registered.Changes
sdk/typescript/src/findings-import.ts: in the JSON branch, check each imported finding'slocations[].pathwith the existingsafeFindingPathhelper, inside the per-finding loop that already reports the finding index for a duplicateoccurrenceId.sdk/typescript/tests-ts/findings-import.test.ts: regression test asserting both formats reject the same unsafe path.Testing
Reproduced through the CLI, before and after, with the same location path in both formats. The CSV was produced by
codex-security export --export-format csvand the JSON is the bundledexamples/completed-scan/findings.json; in each the location path was changed to../../../etc/passwd.Before, on unmodified
main:Running that same JSON import for real:
New test against unmodified
main:After the change, same two commands:
Still accepted, confirmed after the change:
scan import --json examples/completed-scan/findings.json --dry-run→findingCount: 1, exit 0scan import --csv <exported findings.csv> --dry-run→findingCount: 1, exit 0Checks run:
bun test --timeout 30000 ./tests-ts/findings-import.test.ts— 5 pass, 0 failbun test --timeout 30000 ./tests-ts/cli-scan-import.test.ts ./tests-ts/import-scan.test.ts— the same 11 failures before and after the change (diffed the failing-test lists; they are identical). They are pre-existing on this Windows machine: symlink-rejection tests that need symlink creation privilege, plus workbench-database tests.tsc --noEmit(lint) — cleantsc -p tsconfig.ci.json(build:ci) — cleanprettier --checkon both changed files — All matched files use Prettier code style!Risk and rollout
No public CLI surface change: no new command, flag, environment variable, or default, and no change to the accepted CSV set. The new error uses the wording and finding-index convention already used by the neighbouring duplicate-
occurrenceIdcheck in the same loop.Compatibility: a findings JSON whose location paths are already repository-relative imports exactly as before. A document that would previously have been accepted by
--dry-runand then failed during finalization is now rejected up front, with a message naming the finding, and with nothing persisted. The accepted set does not shrink for any input that could previously complete an import.Public disclosure review