Skip to content

fix: address deep review findings (security, correctness, consistency)#935

Merged
jackwener merged 4 commits intomainfrom
fix/deep-review-issues
Apr 10, 2026
Merged

fix: address deep review findings (security, correctness, consistency)#935
jackwener merged 4 commits intomainfrom
fix/deep-review-issues

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

Fixes 7 issues identified during deep project review:

Security (HIGH)

  • Path traversal in plugin manifest: plugin.ts now validates that entry.path resolves within repoRoot before use, preventing directory traversal attacks via malicious plugin manifests
  • Unsafe evaluate() interpolation: cli.ts browser get commands (text/value/attributes) now pass index via JSON.stringify() instead of raw template interpolation, preventing injection

Correctness (MEDIUM)

  • startNetworkCapture idempotency: State reset (_networkEntries, _pendingRequests) now occurs only on first start, preventing data loss when called twice
  • Pre-navigation failure: Failures now emit log.warn() instead of being silently swallowed (was debug-only)
  • validateArgs double-call: Documented the intentional pattern — early call in commanderAdapter (for fast rejection before browser setup) + post-coercion call in execution.ts (for all callers)

Consistency (MEDIUM-LOW)

  • Log module bypass: Replaced console.log/console.error with log.* in commanderAdapter.ts and external.ts so --quiet/--json modes work correctly
  • Error handling: Added PluginError class, converted 13 user-facing plugin errors from plain Error to structured PluginError with hints
  • Code dedup: Removed local isRecord() in plugin.ts, now imports from utils.ts (stricter: excludes arrays)

Test plan

  • All 49 test files pass (585 tests)
  • TypeScript type-check passes
  • Manual test: opencli plugin install with invalid paths
  • Manual test: opencli browser get text <index> with special characters

1. Security: add path traversal guard for plugin manifest entry.path
2. Security: sanitize evaluate() index param via JSON.stringify
3. Correctness: fix startNetworkCapture idempotency (don't wipe entries on re-call)
4. Correctness: log pre-navigation failures instead of silently swallowing
5. Consistency: replace console.log/error with log module in commanderAdapter, external
6. Consistency: add PluginError class, convert user-facing plugin errors
7. Dedup: remove local isRecord() in plugin.ts, use shared utils.ts version
8. Clarify: document intentional double validateArgs call
- Remove chalk dependency, use `styleText` from `node:util` (stable in Node 21+)
- Bump engines to Node >= 21
- Update all 10 source files that used chalk
- Remove stale chalk mock from daemon.test.ts
- One fewer runtime dependency
@jackwener jackwener merged commit 91c208c into main Apr 10, 2026
2 of 13 checks passed
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