Repository navigation
fix(bot): only post review and log entries to channels of the form's guild - #312
Merged
Merged
Conversation
…guild Channel ids in form settings and the guild bot config are only validated as snowflakes, and client.channels.fetch resolves any channel the bot can see on any server. A form manager could set the review channel to a channel on a server of their own and receive the applicants' names and answer previews there. The bot now drops a review or log delivery when the fetched channel does not belong to the guild the notification is for. The Accept/Reject buttons were already scoped to the guild.
|
Graphify reviews are paused for this workspace because nobody has used it in 7 days. A workspace owner can resume reviews from the Repositories page: https://app.graphify.com/msk-scripts/repositories |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The bot now checks that the review channel and the log channel belong to the guild a notification is for. If the fetched channel is on another server (or is a DM), the delivery is dropped with a warning instead of being posted.
Channel ids in
Form.settings.reviewChannelIdand in the guild bot config are only validated as snowflakes when saved.client.channels.fetchresolves any channel the bot can see, on any server it was invited to. So a per-form manager could set the review channel to a channel on a server of their own, invite the bot there, and receive applicant names plus the answer preview of every new submission.This came up in a real case: a form manager pointed a form's review channel at a channel outside the guild and invited the bot to that server minutes later. No data left the guild because the form had no submissions, but nothing in the code prevented it.
Changes:
apps/bot/src/channel-scope.ts: pureisChannelInGuild(channel, discordGuildId)helperapps/bot/src/notifications.ts:deliverReviewanddeliverLogload the guild'sdiscordGuildIdand drop deliveries to foreign channelsapps/bot/src/channel-scope.test.ts: tests for own guild, foreign guild, DMs and a missing guild iddocs/features.md: one line noting that review and log channels must be on the guild's own serverAlready scoped before this PR: the Accept/Reject buttons (
review-actions.tscomparesinteraction.guildId),/forms post(fetches throughinteraction.guild.channels) and role grants (client.guilds.fetch(discordGuildId)).Type of change
Checklist
pnpm lint,pnpm typecheck,pnpm buildpass locally (bot package: lint, typecheck, tests; the rest is left to CI)true, the foreign guild and DM tests fail.envvalues committedLinked issues
None