Skip to content

fix(scanner): reject invalid scan paths#17

Merged
NhanAZ merged 1 commit into
mainfrom
agent/missing-scan-path-error
Jun 9, 2026
Merged

fix(scanner): reject invalid scan paths#17
NhanAZ merged 1 commit into
mainfrom
agent/missing-scan-path-error

Conversation

@NhanAZ

@NhanAZ NhanAZ commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

What changed

Validate the scan target before file discovery and return a scanner error when the path is missing, inaccessible, or not a directory. Add CLI regression coverage for missing paths and file paths.

Why

Invalid scan paths were treated as empty repositories, producing a clean result with exit code 0. This violated the documented exit-code contract and could hide invocation mistakes in local scripts or CI.

Testing

  • npm run prepublishOnly - passed; build succeeded and 62 tests passed.
  • npm run lint - passed.
  • node bin/opk scan src/cli --json - passed with 0 findings.
  • npm run scan - exited 1 with the existing 18 errors and 33 warnings from repository fixtures and rule definitions.
  • npm pack --dry-run --json - passed with 43 package files.

Risks

Callers that previously passed a file path and received a clean result will now receive exit code 2. This matches the documented directory-only CLI contract.

Follow-up

Add scanner coverage for invalid exclusion regular expressions in opk.config.json.

@NhanAZ NhanAZ marked this pull request as ready for review June 9, 2026 19:40
@NhanAZ NhanAZ merged commit 18493aa into main Jun 9, 2026
3 checks passed
@NhanAZ NhanAZ deleted the agent/missing-scan-path-error branch June 9, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant