Skip to content

fix(ci): unblock channel import guardrails#49026

Closed
neeravmakwana wants to merge 1 commit into
openclaw:mainfrom
neeravmakwana:fix/channel-import-guardrails
Closed

fix(ci): unblock channel import guardrails#49026
neeravmakwana wants to merge 1 commit into
openclaw:mainfrom
neeravmakwana:fix/channel-import-guardrails

Conversation

@neeravmakwana

Copy link
Copy Markdown
Contributor

Summary

AI-assisted: yes (Cursor). Testing: fully tested locally.

  • Problem: src/plugin-sdk/channel-import-guardrails.test.ts fails on latest main because bundled channel shared/setup files still import broad channel/setup SDK barrels that the guardrail now forbids.
  • Why it matters: this keeps the unit lane red and weakens the import boundaries the guardrail is supposed to enforce.
  • What changed: rewired the guarded Discord, iMessage, Signal, Slack, Telegram, and WhatsApp files to use narrower imports (cli-runtime, direct links/setup-binary helpers, and direct config/meta helpers) instead of the forbidden broad barrels.
  • What did NOT change (scope boundary): no channel behavior, config semantics, or runtime logic changed; this is import-boundary cleanup only.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #

User-visible / Behavior Changes

None.

Security Impact (required)

  • New permissions/capabilities? (Yes/No) No
  • Secrets/tokens handling changed? (Yes/No) No
  • New/changed network calls? (Yes/No) No
  • Command/tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS 26.3.0 (Darwin 25.3.0)
  • Runtime/container: Node 22 + pnpm + Bun/Vitest
  • Model/provider: N/A
  • Integration/channel (if any): Discord, iMessage, Signal, Slack, Telegram, WhatsApp
  • Relevant config (redacted): none

Steps

  1. Check out latest main.
  2. Run bunx vitest run --config vitest.unit.config.ts src/plugin-sdk/channel-import-guardrails.test.ts.
  3. Observe the guardrail failures in extensions/discord/src/shared.ts and extensions/signal/src/setup-core.ts first; additional files are latent because the test aborts on first failure per loop.

Expected

  • The channel import guardrail test passes and bundled channel helpers stay on the intended narrow import seams.

Actual

  • The test fails on latest main due to broad openclaw/plugin-sdk/<channel> and openclaw/plugin-sdk/setup imports in guarded files.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: reproduced the failing guardrail test before the fix; after the fix ran bunx vitest run --config vitest.unit.config.ts src/plugin-sdk/channel-import-guardrails.test.ts, pnpm test:contracts, pnpm build, and pnpm check.
  • Edge cases checked: confirmed there are no remaining guarded same-channel barrel imports in the targeted shared files and no guarded setup-barrel import violations in the targeted setup files.
  • What you did not verify: live channel setup or messaging flows, since this PR only changes import wiring.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.

Compatibility / Migration

  • Backward compatible? (Yes/No) Yes
  • Config/env changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, exact upgrade steps:

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert commit e2ce9a82c.
  • Files/config to restore: the touched channel shared.ts, setup-core.ts, and setup-surface.ts files.
  • Known bad symptoms reviewers should watch for: build-time import resolution failures in bundled channel modules.

Risks and Mitigations

  • Risk: a replacement narrow import path could be wrong for one bundled channel file.
  • Mitigation: pnpm build, pnpm check, pnpm test:contracts, and the targeted guardrail test all pass locally.

Made with Cursor

@aisle-research-bot

aisle-research-bot Bot commented Mar 17, 2026

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

# Severity Title
1 🟡 Medium signal-cli auto-install downloads and installs binaries without integrity verification

1. 🟡 signal-cli auto-install downloads and installs binaries without integrity verification

Property Value
Severity Medium
CWE CWE-494
Location src/plugins/signal-cli-install.ts:217-259

Description

The Signal setup wizard can auto-install signal-cli by downloading the latest release asset from GitHub and extracting it locally, but the download is not integrity-checked.

Key issues:

  • No signature / checksum verification (CWE-494): installSignalCliFromRelease fetches release metadata and downloads the selected asset, then extracts it and marks the signal-cli binary executable.
  • Unrestricted HTTPS redirects: downloadToFile follows redirects and does not restrict the destination host; if the upstream metadata/redirect chain is compromised, the installer could fetch attacker-controlled content.

Vulnerable flow (network -> write -> extract -> later execution):

const response = await fetch("https://api.github.com/repos/AsamK/signal-cli/releases/latest", ...);
...
await downloadToFile(asset.browser_download_url, archivePath);
...
await extractSignalCliArchive(archivePath, installRoot, 60_000);
...
await fs.chmod(cliPath, 0o755)

Impact:

  • A compromised upstream release, poisoned redirect, or other supply-chain event could result in a malicious signal-cli binary being installed and later executed by the application.

Recommendation

Add integrity verification and tighten download policy.

Minimum steps:

  1. Restrict download hosts and redirects to expected GitHub domains.
  2. Verify a checksum or signature for the downloaded archive before extracting.
    • Prefer verifying a release-provided .sha256 (or .asc) asset, or pin known-good hashes per version.

Example (sketch):

import { createHash } from "node:crypto";

function assertAllowedUrl(u: string) {
  const { protocol, hostname } = new URL(u);
  if (protocol !== "https:") throw new Error("signal-cli download must use https");
  const allowed = new Set(["github.com", "objects.githubusercontent.com", "api.github.com"]);
  if (!allowed.has(hostname)) throw new Error(`unexpected download host: ${hostname}`);
}

async function sha256File(filePath: string): Promise<string> {
  const buf = await fs.readFile(filePath);
  return createHash("sha256").update(buf).digest("hex");
}// before download
assertAllowedUrl(asset.browser_download_url);// after download, compare to an expected hash (from a signed/verified source)
const got = await sha256File(archivePath);
if (got !== expectedSha256) throw new Error("signal-cli archive checksum mismatch");

Also consider:

  • Avoid installing from releases/latest; allow pinning a specific version.
  • Prefer OS package managers where possible (and still validate provenance).

Analyzed PR: #49026 at commit e2ce9a8

Last updated on: 2026-03-17T14:05:22Z

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web size: S labels Mar 17, 2026
@greptile-apps

greptile-apps Bot commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a failing CI guardrail test (channel-import-guardrails.test.ts) by replacing broad channel-specific SDK barrel imports (e.g. openclaw/plugin-sdk/discord, openclaw/plugin-sdk/whatsapp, etc.) and setup barrel helper imports (formatDocsLink, formatCliCommand, detectBinary, installSignalCli) with narrower, direct module paths across six channel extensions (Discord, iMessage, Signal, Slack, Telegram, WhatsApp). The change is purely import-boundary cleanup with no runtime behavior changes.

  • The narrow replacement paths (src/terminal/links.js, src/channels/plugins/config-schema.js, src/channels/registry.js, src/plugins/setup-binary.js, etc.) all exist and export the expected symbols.
  • Unused imports in extensions/whatsapp/src/shared.ts: deleteAccountFromConfigSection and setAccountEnabledInConfigSection are imported from ../../../src/channels/plugins/config-helpers.js but are never called. WhatsApp's setAccountEnabled and deleteAccount config methods are implemented inline (as they were in the original file), not via these helpers. These symbols were not present in the original openclaw/plugin-sdk/whatsapp import either — they appear to have been added by mistake while mirroring the pattern from imessage/src/shared.ts and signal/src/shared.ts.

Confidence Score: 4/5

  • Safe to merge with one minor cleanup: two dead imports in whatsapp/src/shared.ts should be removed.
  • All 16 files make correct, targeted import substitutions and the guardrail test will pass. The one deduction is for the two unused imports (deleteAccountFromConfigSection, setAccountEnabledInConfigSection) added to extensions/whatsapp/src/shared.ts — they cause no runtime issues but represent unnecessary dead code introduced by this PR.
  • extensions/whatsapp/src/shared.ts — contains two unused imports that should be removed.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/whatsapp/src/shared.ts
Line: 13-16

Comment:
**Unused imports introduced by this PR**

`deleteAccountFromConfigSection` and `setAccountEnabledInConfigSection` are imported here but are never called anywhere in this file. WhatsApp's `setAccountEnabled` (lines 127–147) and `deleteAccount` (lines 148–162) are implemented inline with their own spread logic, so they don't delegate to these helpers.

The original `whatsapp/src/shared.ts` did not import these functions at all — they were not in the old `openclaw/plugin-sdk/whatsapp` barrel either. These appear to have been added by mistake while mechanically mirroring the pattern from `imessage/src/shared.ts` and `signal/src/shared.ts`, which do use the helpers.

These dead imports should be removed:

```suggestion
import { buildChannelConfigSchema } from "../../../src/channels/plugins/config-schema.js";
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: e2ce9a8

Comment on lines +13 to +16
import {
deleteAccountFromConfigSection,
setAccountEnabledInConfigSection,
} from "../../../src/channels/plugins/config-helpers.js";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unused imports introduced by this PR

deleteAccountFromConfigSection and setAccountEnabledInConfigSection are imported here but are never called anywhere in this file. WhatsApp's setAccountEnabled (lines 127–147) and deleteAccount (lines 148–162) are implemented inline with their own spread logic, so they don't delegate to these helpers.

The original whatsapp/src/shared.ts did not import these functions at all — they were not in the old openclaw/plugin-sdk/whatsapp barrel either. These appear to have been added by mistake while mechanically mirroring the pattern from imessage/src/shared.ts and signal/src/shared.ts, which do use the helpers.

These dead imports should be removed:

Suggested change
import {
deleteAccountFromConfigSection,
setAccountEnabledInConfigSection,
} from "../../../src/channels/plugins/config-helpers.js";
import { buildChannelConfigSchema } from "../../../src/channels/plugins/config-schema.js";
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/whatsapp/src/shared.ts
Line: 13-16

Comment:
**Unused imports introduced by this PR**

`deleteAccountFromConfigSection` and `setAccountEnabledInConfigSection` are imported here but are never called anywhere in this file. WhatsApp's `setAccountEnabled` (lines 127–147) and `deleteAccount` (lines 148–162) are implemented inline with their own spread logic, so they don't delegate to these helpers.

The original `whatsapp/src/shared.ts` did not import these functions at all — they were not in the old `openclaw/plugin-sdk/whatsapp` barrel either. These appear to have been added by mistake while mechanically mirroring the pattern from `imessage/src/shared.ts` and `signal/src/shared.ts`, which do use the helpers.

These dead imports should be removed:

```suggestion
import { buildChannelConfigSchema } from "../../../src/channels/plugins/config-schema.js";
```

How can I resolve this? If you propose a fix, please make it concise.

@neeravmakwana

Copy link
Copy Markdown
Contributor Author

Closing this draft and replacing it after full validation.

While rerunning the full pnpm test gate from CONTRIBUTING.md, I hit an unrelated existing failure in src/media-understanding/apply.echo-transcript.test.ts, so I’m not going to leave this PR open as if the repo-level test gate were green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant