mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 07:51:12 +00:00
* fix(plugins): canonicalize manifest plugin ids to lowercase Plugin config policy lists (plugins.deny, plugins.allow, plugins.entries) are lowercase-normalized through normalizePluginId, but a plugin's self-declared manifest id was only trimmed, never lowercased. A plugin publishing "id": "Malicious-Scraper" therefore never matched an operator denylist entry of "malicious-scraper" and fell through to default activation, loading its hooks, channels, secret integrations, and tools. The same gap let a mixed-case spelling evade the core reserved-id check. Canonicalize the id at the manifest parse boundary where PluginManifestRecord.id is minted, so every downstream policy consumer compares against the same canonical form. * test(plugins): prove mixed-case deny at gateway startup * test(plugins): assert denied gateway record is absent * test(plugins): materialize allowed secret fixture * fix(plugins): compare a derived policy key instead of rewriting manifest identity Manifest ids stay exactly as declared. Deny, allow, and per-entry checks now compare a lowercase policy key derived at each enforcement boundary, matching the lowercase-normalized config lists. The previous approach lowercased PluginManifestRecord.id at the parse boundary. That id is also matched against the plugin runtime export id, and a mismatch is a hard load failure, so an existing plugin declaring the same mixed-case id in both its manifest and its runtime export would stop loading after upgrade. The Gateway fixture now declares a mixed-case manifest id with a matching mixed-case runtime export, covering that upgrade case, and drops the allowlist that previously scoped discovery by a lowercase id and masked the denylist behavior under test. * fix(plugins): close mixed-case policy gaps * test(plugins): use tracked policy fixture temp dir --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
14 lines
803 B
TypeScript
14 lines
803 B
TypeScript
// Derives the case-insensitive key used to match plugin ids against config policy lists.
|
|
import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
|
|
|
|
/**
|
|
* Canonicalizes a plugin id for comparison against `plugins.allow`, `plugins.deny`, and
|
|
* `plugins.entries`, which are lowercase-normalized when config is normalized. A manifest declares
|
|
* its id in whatever case its author chose, so policy must compare this derived key rather than the
|
|
* declared id. The declared id itself stays untouched: the loader matches it against the plugin's
|
|
* runtime export id, and rewriting it would break plugins whose export matches a mixed-case manifest.
|
|
*/
|
|
export function normalizePluginPolicyId(id: string): string {
|
|
return normalizeOptionalLowercaseString(id) ?? "";
|
|
}
|