openclaw - ✅(Solved) Fix Install scanner blocks plugins that ship unit tests containing env-var + fetch mocks [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#66840Fetched 2026-04-15 06:24:10
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
cross-referenced ×3referenced ×3commented ×1

On OpenClaw 2026.4.14 the install-time static scanner was upgraded from warn to block when it detects process.env.X access + fetch() calls in the same file. This breaks installation of any plugin whose ClawHub-stored archive contains test files that mock environment variables and the network, which is a standard unit-testing pattern for code that reads opt-out flags (DO_NOT_TRACK, AXONFLOW_TELEMETRY) and sends telemetry.

Related issue: openclaw/openclaw#66618 (the scoped-package ENOENT bug, now fixed in 2026.4.14).

Error Message

On OpenClaw 2026.4.14 the install-time static scanner was upgraded from warn to block when it detects process.env.X access + fetch() calls in the same file. This breaks installation of any plugin whose ClawHub-stored archive contains test files that mock environment variables and the network, which is a standard unit-testing pattern for code that reads opt-out flags (DO_NOT_TRACK, AXONFLOW_TELEMETRY) and sends telemetry.

Root Cause

The test file (tests/telemetry.test.ts) legitimately does:

// Setup for telemetry opt-out tests
process.env.DO_NOT_TRACK = "1";
global.fetch = jest.fn();

This is the standard pattern for unit-testing any code that reads env vars and makes HTTP calls, which includes:

  • Telemetry opt-out (most OSS plugins)
  • Feature flag resolution
  • Auth token refresh
  • Retry/timeout configuration

The current scanner treats this test-file co-location as equivalent to a runtime exfiltration vector.

Fix Action

Fix / Workaround

Workarounds for plugin authors today

PR fix notes

PR #40: release(v1.2.3): exclude tests from ClawHub archive

Description (problem / solution / changelog)

Summary

Ships v1.2.3 to unblock `openclaw plugins install @axonflow/openclaw` on the just-released OpenClaw 2026.4.14, where our unit tests were triggering the install-time scanner.

Background

OpenClaw 2026.4.14 (released April 15 UTC) landed two relevant changes:

  1. Fixed scoped-package ENOENT bug (openclaw/openclaw#66618) — the bug we filed yesterday. Users on 2026.4.14+ can now use the primary install command without the `npm pack` workaround.
  2. Install scanner upgraded from warn → block on files that combine `process.env.X` access with `fetch()` calls. Our `tests/telemetry.test.ts` mocks both for opt-out coverage, which the scanner treats as "possible credential harvesting" and blocks installation. Filed upstream: openclaw/openclaw#66840.

Change

New `.clawhubignore` (gitignore-syntax, natively supported by `clawhub package publish`) excludes: `tests/`, `tests/`, `.{test,spec}.{ts,js}`, `src/`, `scripts/`, `.github/`, `tsconfig.json`, `jest.config.`, `.eslintrc`, `.prettierrc*`, `coverage/`, `.tgz`, `dist/**/.map`.

Runtime artifacts that still ship to ClawHub: `dist/`, `openclaw.plugin.json`, `policies/`, `package.json`, `README.md`, `CHANGELOG.md`, `LICENSE`.

Verification (local, against OpenClaw 2026.4.14)

  • `npm test` — 107/107 passing
  • `npm pack` tgz contains no test files
  • `openclaw plugins install ./axonflow-openclaw-1.2.3.tgz` installs cleanly with no warnings or blocks
  • Plugin loads and connects to AxonFlow correctly

Test plan

  • CI green
  • After merge + tag v1.2.3, verify `openclaw plugins install @axonflow/openclaw` works end-to-end via ClawHub on 2026.4.14

Changed files

  • .clawhubignore (added, +77/-0)
  • CHANGELOG.md (modified, +9/-0)
  • clawhub/1.4.0/SKILL.md (modified, +1/-14)
  • package.json (modified, +1/-1)
  • src/index.ts (modified, +1/-1)

PR #66854: fix: skip test files in install security scanner

Description (problem / solution / changelog)

Summary

Skip test files during the install-time security scan to prevent false positives from standard unit-testing patterns.

Root Cause

The install-time static scanner flags test files containing process.env.X + fetch() patterns as dangerous code (possible credential harvesting). This is a standard unit-testing pattern for code that reads environment variables and makes HTTP calls (telemetry opt-out, feature flags, auth token refresh, etc.). The scanner treats this test-file co-location as equivalent to a runtime exfiltration vector.

Fix

Added isTestFile() helper that filters out files matching test patterns from the scanner:

  • tests/ and test/ directories
  • __tests__/ directories
  • *.test.{ts,js,mts,mjs,cts,cjs,tsx,jsx} files
  • *.spec.{ts,js,mts,mjs,cts,cjs,tsx,jsx} files

The filter applies to both forced files (--include) and walked files during directory traversal.

Test Plan

  • Install a plugin with test files containing env+fetch mocks — should no longer be blocked
  • Install a plugin with actual dangerous code in source files — should still be blocked
  • Existing scanner tests pass

Closes openclaw#66840

Changed files

  • src/security/skill-scanner.ts (modified, +17/-1)

PR #67050: fix: skip test files and directories in install security scanner

Description (problem / solution / changelog)

Summary

The install-time security scanner blocks plugins that ship unit tests containing process.env access + fetch() calls in the same file. This is a standard unit-testing pattern (mocking env vars and network for telemetry opt-out tests, feature flag tests, etc.) and triggers false-positive "credential harvesting" findings.

Changes

In walkDirWithLimit (src/security/skill-scanner.ts):

  • Skip common test directories: tests/, __tests__/, test/, __mocks__/, __fixtures__/
  • Skip test file patterns: *.test.*, *.spec.*, *.mock.*

These files are never loaded at plugin runtime and should not be scanned for security threats.

Impact

Plugins like @axonflow/openclaw that include test files in their ClawHub archive will no longer be blocked during installation due to false-positive security findings from test mocks.

Fixes #66840

Changed files

  • src/security/skill-scanner.ts (modified, +20/-0)

Code Example

openclaw plugins install @axonflow/openclaw@1.2.2

---

ClawHub code-plugin @axonflow/openclaw@1.2.2 channel=community verification=source-linked
Downloading plugin @axonflow/openclaw@1.2.2 from ClawHub…
Extracting .../openclaw.zip…
Plugin manifest id "axonflow-governance" differs from npm package name "@axonflow/openclaw"; using manifest id as the config key.
WARNING: Plugin "axonflow-governance" contains dangerous code patterns:
  Environment variable access combined with network send — possible credential harvesting
  (.../package/tests/telemetry.test.ts:7)
Plugin "axonflow-governance" installation blocked: dangerous code patterns detected: ...

---

// Setup for telemetry opt-out tests
process.env.DO_NOT_TRACK = "1";
global.fetch = jest.fn();
RAW_BUFFERClick to expand / collapse

Summary

On OpenClaw 2026.4.14 the install-time static scanner was upgraded from warn to block when it detects process.env.X access + fetch() calls in the same file. This breaks installation of any plugin whose ClawHub-stored archive contains test files that mock environment variables and the network, which is a standard unit-testing pattern for code that reads opt-out flags (DO_NOT_TRACK, AXONFLOW_TELEMETRY) and sends telemetry.

Related issue: openclaw/openclaw#66618 (the scoped-package ENOENT bug, now fixed in 2026.4.14).

Reproduction

openclaw plugins install @axonflow/[email protected]

Output:

ClawHub code-plugin @axonflow/[email protected] channel=community verification=source-linked
Downloading plugin @axonflow/[email protected] from ClawHub…
Extracting .../openclaw.zip…
Plugin manifest id "axonflow-governance" differs from npm package name "@axonflow/openclaw"; using manifest id as the config key.
WARNING: Plugin "axonflow-governance" contains dangerous code patterns:
  Environment variable access combined with network send — possible credential harvesting
  (.../package/tests/telemetry.test.ts:7)
Plugin "axonflow-governance" installation blocked: dangerous code patterns detected: ...

ClawHub's own package scanner marks the same package Benign, HIGH CONFIDENCE — the scan summary explicitly notes the flagged lines are in the tests/ directory.

Analysis

The test file (tests/telemetry.test.ts) legitimately does:

// Setup for telemetry opt-out tests
process.env.DO_NOT_TRACK = "1";
global.fetch = jest.fn();

This is the standard pattern for unit-testing any code that reads env vars and makes HTTP calls, which includes:

  • Telemetry opt-out (most OSS plugins)
  • Feature flag resolution
  • Auth token refresh
  • Retry/timeout configuration

The current scanner treats this test-file co-location as equivalent to a runtime exfiltration vector.

Suggested fix (in order of preference)

  1. Don't scan test files at install time. The scanner already knows the file path. Skip tests/**, __tests__/**, **/*.test.{ts,js}, **/*.spec.{ts,js} by default.
  2. Scan only entry points (the files actually loaded by the plugin runtime, starting from main or exports in package.json). Test files are never loaded at runtime.
  3. Make the co-location check weaker: require the env read and the fetch to be in the same function or control-flow graph, not just the same file.

Workarounds for plugin authors today

  • Add a .clawhubignore file excluding tests/, __tests__/, *.test.*, *.spec.* before clawhub package publish. This keeps tests out of the ClawHub-stored archive. (Mechanism discovered in packages/clawhub/src/cli/commands/packages.ts.)
  • Or: install from npm directly: TGZ=\$(npm pack @scope/name | tail -1); openclaw plugins install "./\$TGZ" — npm packages normally exclude tests via the files field.

Impact

Affects every plugin on ClawHub that:

  • Ships with its unit tests in the source tree at publish time (the default when authors run clawhub package publish .), AND
  • Tests code that reads environment variables AND makes HTTP calls

This is a very common combination — essentially any plugin with opt-out telemetry or network-sensitive config tests.

Environment

  • OpenClaw: 2026.4.14 (323493f)
  • ClawHub CLI: v0.9.0

extent analysis

TL;DR

The most likely fix is to modify the install-time static scanner to exclude test files or scan only entry points, as the current scanner is blocking plugin installations due to false positives in test files.

Guidance

  • The issue is caused by the scanner treating test files as equivalent to runtime exfiltration vectors, so excluding test files or scanning only entry points could resolve the issue.
  • Plugin authors can use workarounds such as adding a .clawhubignore file to exclude test files or installing from npm directly.
  • To verify the fix, test the installation of plugins that were previously blocked due to the scanner's false positives.
  • The scanner's behavior can be modified to make the co-location check weaker, requiring the env read and the fetch to be in the same function or control-flow graph.

Example

// Example of a test file that triggers the scanner's false positive
process.env.DO_NOT_TRACK = "1";
global.fetch = jest.fn();

This example shows the standard pattern for unit-testing code that reads env vars and makes HTTP calls, which is being incorrectly flagged by the scanner.

Notes

The issue affects every plugin on ClawHub that ships with unit tests in the source tree and tests code that reads environment variables and makes HTTP calls. The scanner's current behavior is overly restrictive and needs to be modified to allow for legitimate test files.

Recommendation

Apply the workaround of adding a .clawhubignore file to exclude test files or installing from npm directly, as this is a temporary solution until the scanner's behavior is modified to correctly handle test files.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING