fix: harden runtime capture mocks#8
Conversation
PR SummaryMedium Risk Overview Mock generation is expanded and made adaptive. Tests are updated/added to cover TypeScript entrypoints, SDK subpaths, missing externals, namespace imports, dist-rooted imports, and noisy output behavior, plus minor fixture evidence renames. Reviewed by Cursor Bugbot for commit 824d19b. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7235aaa1ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| continue; | ||
| } | ||
| const relative = specifier.slice("openclaw/plugin-sdk/".length); | ||
| const targetPath = path.join(pluginSdkDir, `${relative}.js`); |
There was a problem hiding this comment.
Validate SDK subpaths before creating mock files
The SDK subpath is used verbatim to build targetPath, so a crafted import like openclaw/plugin-sdk/../../../../tmp/pwn escapes pluginSdkDir and writes files outside the temporary workspace during createMockSdkPackage. Because plugin sources are untrusted inputs for inspection, this is an arbitrary file-write vulnerability; reject absolute/traversing segments (or normalize and enforce prefix) before calling mkdir/writeFile.
Useful? React with 👍 / 👎.
| ? path.join(parsed.dir, parsed.name) | ||
| : null; | ||
| const candidates = [ | ||
| base, |
There was a problem hiding this comment.
Resolve extensionless imports to files, not directories
resolveExtensionless checks base first with existsSync, so import "./util" where util/ is a directory returns the directory path and the loader fails with EISDIR before trying index.js/index.ts. This breaks runtime capture for common folder-based module layouts and produces false status: "error" results.
Useful? React with 👍 / 👎.
9710904 to
824d19b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 824d19b. Configure here.
| try { | ||
| await register(api); | ||
| } catch (error) { | ||
| await drainAsyncOutput(); |
There was a problem hiding this comment.
Captured plugin output dropped on failure paths
Medium Severity
installProcessOutputCapture is enabled before importing or registering the plugin, but withProcessOutput is only invoked on the success branches. When entrypoint-import-error or registration-execution-error is thrown, the buffered stdout/stderr from the plugin is silently discarded — exactly when noisy diagnostic output is most valuable. The top-level catch surfaces only the error stack via the original write functions, so consumers never see the captured plugin noise that preceded the failure.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 824d19b. Configure here.


Summary
Retest
npm run checkopenai,telegram,matrix,discord,voice-call,memory-core,browser,slack)@openclaw/matrix,@openclaw/msteams,@openclaw/nostr,openclaw-codex-app-server,openclaw-agent-protocol,@openclaw/openclaw-canon,@shaoxing-xie/openclaw-data-china-stock)