fix(briefs): enforce bridge user scope

This commit is contained in:
Dotta committed 2026-05-24 02:54:00 +00:00
1 parent 5584df1747
commit 6e684f4b53
2 files changed
+14 -3

No files matched your search

+6 -3
View File
@@ -340,9 +340,11 @@ async function refreshIssueTree(
ctx: PluginContext,
store: ReturnType<typeof createBriefsStore>,
rawInput: Record<string, unknown>,
request?: PluginBridgeRequestContext,
) {
const companyId = stringParam(rawInput.companyId, "companyId");
const userId = stringParam(rawInput.userId, "userId");
if (request) assertTrustedBridgeUserScope(userId, request);
const rootIssueId = stringParam(rawInput.rootIssueId, "rootIssueId");
const card = await saveBriefCard(
ctx,
@@ -439,16 +441,17 @@ const plugin = definePlugin({
};
});
ctx.actions.register("save-deterministic-card", async (params) => {
ctx.actions.register("save-deterministic-card", async (params, request) => {
const input = bridgeParams(params);
const bundle = objectParam(input.bundle, "bundle") as BriefsSourceBundle;
assertTrustedBridgeUserScope(stringParam(bundle.userId, "bundle.userId"), request);
const options = (input.options && typeof input.options === "object" ? input.options : {}) as DeterministicBriefOptions;
const card = await saveBriefCard(ctx, store, bundle, options);
return { card };
});
ctx.actions.register("refresh-issue-tree", async (params) => {
return refreshIssueTree(ctx, store, bridgeParams(params));
ctx.actions.register("refresh-issue-tree", async (params, request) => {
return refreshIssueTree(ctx, store, bridgeParams(params), request);
});
ctx.actions.register("reconcile-managed-agent", async (params) => {
@@ -280,6 +280,14 @@ describe("Briefs managed resources", () => {
routineKey: BRIEFS_MANAGED_ROUTINE_KEYS[0],
variables: { userId: "victim-user" },
}, context)).rejects.toThrow("Briefs user scope mismatch");
await expect(harness.performAction("save-deterministic-card", {
bundle: { userId: "victim-user" },
}, context)).rejects.toThrow("Briefs user scope mismatch");
await expect(harness.performAction("refresh-issue-tree", {
companyId,
userId: "victim-user",
rootIssueId: "issue-1",
}, context)).rejects.toThrow("Briefs user scope mismatch");
});
});