Repository navigation
refactor(plugins): prefer setup descriptors for setup lookup - #64786
Conversation
Greptile SummaryThis PR refactors plugin setup lookup (provider and CLI backend) to prefer manifest
Confidence Score: 4/5Mostly safe to merge, but the async-register early-return in resolvePluginSetupCliBackend diverges from the established pattern and could silently cache a null result for any plugin whose register function returns a Promise. One P1 logic inconsistency: the new cli-backend path treats a returned Promise as a hard failure and caches null, while the analogous provider and registry paths fall through and return whatever was synchronously registered. All other changes are correct and well-tested. src/plugins/setup-registry.ts — specifically the async branch in resolvePluginSetupCliBackend (lines 563-567).
|
|
follow-up is pushed. addressed the Aisle findings by:
also addressed the Greptile review note by:
verified locally with:
|
a737148 to
25a3e67
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bdc7d541fb
ℹ️ 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".
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Insufficient provider ID normalization allows zero-width/Unicode confusable IDs to bypass uniqueness checks
DescriptionThe setup registry’s new ownership/uniqueness enforcement relies on
It does not perform security-hardened identifier canonicalization (e.g., Unicode normalization such as NFKC/NFKD, stripping format characters like zero-width space, or restricting to a safe ASCII slug charset). As a result, a plugin manifest can declare IDs that are visually/confusably identical but compare as distinct after normalization (e.g., Vulnerable code: export function normalizeProviderId(provider: string): string {
const normalized = normalizeLowercaseStringOrEmpty(provider);
// ... alias mapping ...
return normalized;
}RecommendationHarden provider/CLI-backend ID canonicalization and/or restrict allowed characters. A robust approach is:
Example: const STRIP_FORMAT = /[\p{Cf}\p{Cc}]/gu; // format + control
const SAFE_ID = /^[a-z0-9][a-z0-9._+-]*$/;
export function normalizeProviderId(provider: unknown): string {
if (typeof provider !== "string") return "";
const normalized = provider
.normalize("NFKC")
.replace(STRIP_FORMAT, "")
.trim()
.toLowerCase();
if (!SAFE_ID.test(normalized)) return ""; // or throw/diagnose
// apply alias mapping on normalized
// ...
return normalized;
}Also ensure callers reject empty results (""), rather than treating them as a valid identifier in lookups/ownership checks. Analyzed PR: #64786 at commit Last updated on: 2026-04-12T02:35:43Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7fd0e74c6c
ℹ️ 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".
| (plugin) => { | ||
| if (plugin.origin !== "bundled") { | ||
| return []; | ||
| } | ||
| const backendIds = listSetupCliBackendIds(plugin); |
There was a problem hiding this comment.
Reject ambiguous bundled setup backend ids in fallback
When setup-registry cannot be loaded, this fallback now flattens descriptor-owned backend ids from bundled manifests but still resolves by first match later, so two bundled plugins with the same normalized setup.cliBackends id will silently pick one owner instead of failing closed. That bypasses the ambiguity guard added in resolvePluginSetupCliBackend and can misclassify a CLI provider in isCliProvider/setup flows in runtime-unavailable environments.
Useful? React with 👍 / 👎.
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
…w#64786) * refactor(plugins): prefer setup descriptors for setup lookup * fix(plugins): harden setup descriptor lookup * fix(plugins): keep sync cli backend setup results * fix(plugins): resolve setup registry rebase * fix(plugins): preserve fail-closed cli backend lookup * fix(plugins): fail closed on shadowed setup owners * fix(plugins): swallow async setup register rejections
Summary
setup-api, butresolvePluginSetupCliBackend()still built the whole setup registry and loaded every setup module first.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
setup-apimodules.Regression Test Plan (if applicable)
src/plugins/setup-registry.test.ts,src/plugins/setup-registry.runtime.test.tsUser-visible / Behavior Changes
Setup lookup now prefers manifest
setup.providers/setup.cliBackendsdescriptors when present, then falls back tosetup-apionly for the matched plugin that still needs runtime setup hooks.Diagram (if applicable)
Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
setupdescriptors to setup lookup selection logic.Expected
setup-apimodulesActual
Evidence
Verification:
pnpm test:serial src/plugins/setup-registry.test.ts src/plugins/setup-registry.runtime.test.tspnpm lint -- src/plugins/setup-descriptors.ts src/plugins/setup-registry.ts src/plugins/setup-registry.runtime.ts src/plugins/setup-registry.test.ts src/plugins/setup-registry.runtime.test.tspnpm buildKnown unrelated local gate:
pnpm check:host-env-policy:swiftstill fails on freshmaindrift inapps/macos/Sources/OpenClaw/HostEnvSecurityPolicy.generated.swift.Human Verification (required)
Review Conversations
Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations
setup-apiwhenrequiresRuntimeis needed, and the code only narrows selection rather than synthesizing full backend/provider objects.