Skip to content

Commit 5f6f55c

Browse files
omarshahinesteipete
authored andcommitted
fix(discord): preserve PluralKit group provenance
1 parent 816d588 commit 5f6f55c

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

‎extensions/discord/src/monitor/dm-command-auth.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,35 @@ describe("resolveDiscordTextCommandAccess", () => {
7171
expect(result.commandAccess.authorized).toBe(false);
7272
expect(result.commandAccess.shouldBlockControlCommand).toBe(true);
7373
});
74+
75+
it("applies the PluralKit provenance downgrade to strict group commands", async () => {
76+
const ordinary = await resolveDiscordTextCommandAccess({
77+
accountId: "default",
78+
sender,
79+
ownerAllowFrom: ["discord:123"],
80+
memberAccessConfigured: false,
81+
memberAllowed: false,
82+
allowNameMatching: false,
83+
allowTextCommands: true,
84+
hasControlCommand: true,
85+
minIdentifierAuthentication: "verified",
86+
});
87+
const pluralKit = await resolveDiscordTextCommandAccess({
88+
accountId: "default",
89+
sender: { id: "pk-member-1", name: "Echo", isPluralKit: true },
90+
ownerAllowFrom: ["pk:pk-member-1"],
91+
memberAccessConfigured: false,
92+
memberAllowed: false,
93+
allowNameMatching: false,
94+
allowTextCommands: true,
95+
hasControlCommand: true,
96+
minIdentifierAuthentication: "verified",
97+
});
98+
99+
expect(ordinary.commandAccess.authorized).toBe(true);
100+
expect(pluralKit.commandAccess.authorized).toBe(false);
101+
expect(pluralKit.commandAccess.shouldBlockControlCommand).toBe(true);
102+
});
74103
});
75104

76105
describe("resolveDiscordDmCommandAccess", () => {

‎extensions/discord/src/monitor/dm-command-auth.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export async function resolveDiscordTextCommandAccess(params: {
252252
conversationParentId?: string;
253253
conversationThreadId?: string;
254254
contextBinding?: ChannelIngressContextBinding;
255+
minIdentifierAuthentication?: IdentifierAuthentication;
255256
}) {
256257
const ownerAllowFrom = (params.ownerAllowFrom ?? []).filter((entry) => entry.trim() !== "*");
257258
const memberAccessGroup = "discord-member-access";
@@ -278,6 +279,9 @@ export async function resolveDiscordTextCommandAccess(params: {
278279
groupPolicy: "allowlist",
279280
policy: {
280281
mutableIdentifierMatching: params.allowNameMatching ? "enabled" : "disabled",
282+
...(params.minIdentifierAuthentication
283+
? { minIdentifierAuthentication: params.minIdentifierAuthentication }
284+
: {}),
281285
},
282286
allowFrom: ownerAllowFrom,
283287
groupAllowFrom: commandGroup,

‎extensions/discord/src/monitor/message-handler.preflight.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ export async function preflightDiscordMessage(
649649
id: sender.id,
650650
name: sender.name,
651651
tag: sender.tag,
652+
isPluralKit: sender.isPluralKit,
652653
},
653654
memberAccessConfigured: hasAccessRestrictions,
654655
memberAllowed,

‎extensions/slack/src/monitor/auth.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const slackIngressIdentity = defineStableChannelIngressIdentity({
147147
kind: SLACK_USER_NAME_KIND,
148148
normalizeEntry,
149149
normalizeSubject: normalizeSlackNameSubject,
150-
authentication: "mutable",
150+
authentication: "mutable" as const,
151151
sensitivity: "pii" as const,
152152
})),
153153
],

0 commit comments

Comments
 (0)