fix: address deep review findings (security, correctness, consistency)#935
Merged
fix: address deep review findings (security, correctness, consistency)#935
Conversation
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
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
Fixes 7 issues identified during deep project review:
Security (HIGH)
plugin.tsnow validates thatentry.pathresolves withinrepoRootbefore use, preventing directory traversal attacks via malicious plugin manifestsevaluate()interpolation:cli.tsbrowser get commands (text/value/attributes) now passindexviaJSON.stringify()instead of raw template interpolation, preventing injectionCorrectness (MEDIUM)
startNetworkCaptureidempotency: State reset (_networkEntries,_pendingRequests) now occurs only on first start, preventing data loss when called twicelog.warn()instead of being silently swallowed (was debug-only)validateArgsdouble-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)
console.log/console.errorwithlog.*incommanderAdapter.tsandexternal.tsso--quiet/--jsonmodes work correctlyPluginErrorclass, converted 13 user-facing plugin errors from plainErrorto structuredPluginErrorwith hintsisRecord()inplugin.ts, now imports fromutils.ts(stricter: excludes arrays)Test plan
opencli plugin installwith invalid pathsopencli browser get text <index>with special characters