mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 04:00:22 +00:00
fix(core): unify session-key normalization and plugin boundary checks
This commit is contained in:
@@ -295,6 +295,32 @@ describe("loadOpenClawPlugins", () => {
|
||||
expect(Object.keys(registry.gatewayHandlers)).toContain("allowed.ping");
|
||||
});
|
||||
|
||||
it("loads plugins when source and root differ only by realpath alias", () => {
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = "/nonexistent/bundled/plugins";
|
||||
const plugin = writePlugin({
|
||||
id: "alias-safe",
|
||||
body: `export default { id: "alias-safe", register() {} };`,
|
||||
});
|
||||
const realRoot = fs.realpathSync(plugin.dir);
|
||||
if (realRoot === plugin.dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
const registry = loadOpenClawPlugins({
|
||||
cache: false,
|
||||
workspaceDir: plugin.dir,
|
||||
config: {
|
||||
plugins: {
|
||||
load: { paths: [plugin.file] },
|
||||
allow: ["alias-safe"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const loaded = registry.plugins.find((entry) => entry.id === "alias-safe");
|
||||
expect(loaded?.status).toBe("loaded");
|
||||
});
|
||||
|
||||
it("denylist disables plugins even if allowed", () => {
|
||||
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = "/nonexistent/bundled/plugins";
|
||||
const plugin = writePlugin({
|
||||
|
||||
@@ -530,6 +530,10 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
absolutePath: candidate.source,
|
||||
rootPath: pluginRoot,
|
||||
boundaryLabel: "plugin root",
|
||||
// Discovery stores rootDir as realpath but source may still be a lexical alias
|
||||
// (e.g. /var/... vs /private/var/... on macOS). Canonical boundary checks
|
||||
// still enforce containment; skip lexical pre-check to avoid false escapes.
|
||||
skipLexicalRootCheck: true,
|
||||
});
|
||||
if (!opened.ok) {
|
||||
record.status = "error";
|
||||
|
||||
Reference in New Issue
Block a user