openai / openai/codex-security
Repository index cannot return unscanned targets
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.8k
- Forks
- 801
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 257
Description
Summary
list-repositories --status not_scanned cannot return any repositories, even though the workbench persists security targets before they have a scan.
Reproduction / evidence
Current upstream main at 37bf87a692fc72d41f7312cc48808d699d204fba has a legitimate zero-scan target state: create_workspace() calls ensure_security_target() as soon as a workspace is created with a target path, before a scan is started.
workbench_native_indexes.list_repositories() nevertheless builds its output only from latest_scan_by_target.items():
repositories = [
{...}
for target_id, latest_scan in latest_scan_by_target.items()
if (target := targets.get(target_id)) is not None
]
Every repository admitted to that list therefore already has at least one scan.
The status filter then contains:
and args.status != "not_scanned"
So when --status not_scanned is requested, every already-scanned row is rejected and targets with zero scans were never present in the collection to begin with. The result is always empty.
Minimal deterministic state:
- create two
security_targetsrows; - add a completed scan for only one target;
- call
list_repositories(..., status="not_scanned"); - current
mainreturns[]instead of the target with no scans.
Expected behavior
Repository indexing should start from all persisted security_targets:
- scanned targets:
scanCount > 0, withlatestScanpopulated; - unscanned targets:
scanCount == 0, withlatestScan: null; status=scannedshould return only the former;status=not_scannedshould return only the latter;status=open_findingsshould retain its existing semantics.
Root cause
The implementation uses scan history as the primary repository set rather than using security_targets as the primary set and joining scan summary data onto it. The later not_scanned predicate therefore has no possible matching row.
Suggested fix
Build repository rows from all security_targets, use .get() defaults for scan count/latest scan, and apply explicit scanned / not_scanned predicates based on scanCount.
Add a focused regression with one scanned and one unscanned persisted target.
Impact
The native repository index and any UI/tooling that asks for unscanned repositories cannot surface targets that were configured in a workspace but have not yet been scanned. This makes the documented status selector nonfunctional for that state.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at workbench_native_indexes.list_repositories() and trace how security_targets are combined with latest_scan_by_target; review create_workspace() and ensure_security_target() to confirm the zero-scan state. Add a focused regression with one scanned and one unscanned target, then verify scanned, not_scanned, and open_findings filtering behaves as described.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100