mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 12:40:43 +00:00
fix: reject unscoped workspace plugin metadata
This commit is contained in:
@@ -67,7 +67,7 @@ describe("current plugin metadata snapshot", () => {
|
||||
expect(getCurrentPluginMetadataSnapshot({ config, workspaceDir: "/workspace/a" })).toBe(
|
||||
snapshot,
|
||||
);
|
||||
expect(getCurrentPluginMetadataSnapshot({ config })).toBe(snapshot);
|
||||
expect(getCurrentPluginMetadataSnapshot({ config })).toBeUndefined();
|
||||
expect(
|
||||
getCurrentPluginMetadataSnapshot({
|
||||
config: { plugins: { allow: ["other"] } },
|
||||
@@ -79,6 +79,14 @@ describe("current plugin metadata snapshot", () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("rejects a workspace-scoped snapshot when the caller does not provide workspace scope", () => {
|
||||
const config = { plugins: { allow: ["demo"] } };
|
||||
const snapshot = createSnapshot({ config, workspaceDir: "/workspace/a" });
|
||||
setCurrentPluginMetadataSnapshot(snapshot, { config });
|
||||
|
||||
expect(getCurrentPluginMetadataSnapshot({ config })).toBeUndefined();
|
||||
});
|
||||
|
||||
it("rejects a current snapshot when plugin load paths change", () => {
|
||||
const config = { plugins: { load: { paths: ["/plugins/one"] } } };
|
||||
const snapshot = createSnapshot({ config });
|
||||
|
||||
@@ -63,6 +63,9 @@ export function getCurrentPluginMetadataSnapshot(
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
if (snapshot.workspaceDir !== undefined && params.workspaceDir === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (
|
||||
params.workspaceDir !== undefined &&
|
||||
(snapshot.workspaceDir ?? "") !== (params.workspaceDir ?? "")
|
||||
|
||||
Reference in New Issue
Block a user