Skip to content

Commit

Permalink
fix: some access control issues
Browse files Browse the repository at this point in the history
  • Loading branch information
skelmis committed Apr 12, 2024
1 parent 7e2d630 commit f0293ad
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
- [ ] New localizations have been added
- [ ] Documentation on ``docs.suggestions.gg`` has been updated
- [ ] Do these changes make sure not to expose anonymous suggestion authors?
- [ ] Do these changes have the correct default discord permissions setup?
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
aiodns==3.0.0
aiohttp==3.8.1
aiosignal==1.2.0
alaric==1.2.0
anyio==4.2.0
async-timeout==4.0.2
attrs==21.4.0
Bot-Base==1.7.1
Brotli==1.0.9
black==24.3.0
causar==0.2.0
cchardet==2.1.7
certifi==2023.11.17
Expand Down
3 changes: 1 addition & 2 deletions suggestions/abc/loadable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

@runtime_checkable
class Loadable(Protocol):
async def load(self):
...
async def load(self): ...
11 changes: 6 additions & 5 deletions suggestions/cogs/blacklist_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def __init__(self, bot):
self.bot: SuggestionsBot = bot
self.state: State = self.bot.state

@commands.slash_command()
async def user(self, interaction: disnake.GuildCommandInteraction):
...
@commands.slash_command(
dm_permission=False,
default_member_permissions=disnake.Permissions(manage_guild=True),
)
async def user(self, interaction: disnake.GuildCommandInteraction): ...

@user.sub_command_group()
async def blocklist(self, interaction: disnake.GuildCommandInteraction):
...
async def blocklist(self, interaction: disnake.GuildCommandInteraction): ...

@blocklist.sub_command()
async def add(
Expand Down
18 changes: 9 additions & 9 deletions suggestions/cogs/help_guild_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ async def instance_info(
cluster_id = (
1
if shard_id < 10
else 2
if shard_id < 20
else 3
if shard_id < 30
else 4
if shard_id < 40
else 5
if shard_id < 50
else 6
else (
2
if shard_id < 20
else (
3
if shard_id < 30
else 4 if shard_id < 40 else 5 if shard_id < 50 else 6
)
)
)

await interaction.send(
Expand Down
12 changes: 10 additions & 2 deletions suggestions/cogs/suggestions_message_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def __init__(self, bot: SuggestionsBot):
self.state: State = self.bot.state
self.stats: Stats = self.bot.stats

@commands.message_command(name="Approve suggestion")
@commands.message_command(
name="Approve suggestion",
dm_permission=False,
default_member_permissions=disnake.Permissions(manage_guild=True),
)
@cooldowns.cooldown(1, 3, bucket=InteractionBucket.author)
@checks.ensure_guild_has_logs_channel_or_keep_logs()
async def approve_suggestion(self, interaction: disnake.GuildCommandInteraction):
Expand Down Expand Up @@ -71,7 +75,11 @@ async def approve_suggestion(self, interaction: disnake.GuildCommandInteraction)
self.stats.type.APPROVE_BY_MESSAGE_COMMAND,
)

@commands.message_command(name="Reject suggestion")
@commands.message_command(
name="Reject suggestion",
dm_permission=False,
default_member_permissions=disnake.Permissions(manage_guild=True),
)
@cooldowns.cooldown(1, 3, bucket=InteractionBucket.author)
@checks.ensure_guild_has_logs_channel_or_keep_logs()
async def reject_suggestion(self, interaction: disnake.GuildCommandInteraction):
Expand Down
5 changes: 2 additions & 3 deletions suggestions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ class BlocklistedUser(CheckFailure):
class PartialResponse(Exception):
"""A garven route returned a partial response when we require a full response"""


class ConflictingHandlerInformation(disnake.DiscordException):
"""Raised when an InteractionHandler class gets both content and a translation key"""


class InvalidFileType(disnake.DiscordException):
"""The file you attempted to upload is not allowed."""

12 changes: 4 additions & 8 deletions suggestions/low_level/message_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ async def edit(
allowed_mentions: Optional[AllowedMentions] = ...,
view: Optional[View] = ...,
components: Optional[Components[MessageUIComponent]] = ...,
) -> None:
...
) -> None: ...

@overload
async def edit(
Expand All @@ -54,8 +53,7 @@ async def edit(
allowed_mentions: Optional[AllowedMentions] = ...,
view: Optional[View] = ...,
components: Optional[Components[MessageUIComponent]] = ...,
) -> None:
...
) -> None: ...

@overload
async def edit(
Expand All @@ -70,8 +68,7 @@ async def edit(
allowed_mentions: Optional[AllowedMentions] = ...,
view: Optional[View] = ...,
components: Optional[Components[MessageUIComponent]] = ...,
) -> None:
...
) -> None: ...

@overload
async def edit(
Expand All @@ -86,8 +83,7 @@ async def edit(
allowed_mentions: Optional[AllowedMentions] = ...,
view: Optional[View] = ...,
components: Optional[Components[MessageUIComponent]] = ...,
) -> None:
...
) -> None: ...

async def edit(self, content: Optional[str] = MISSING, **fields: Any) -> None:
if self._state.allowed_mentions is not None:
Expand Down
1 change: 1 addition & 0 deletions suggestions/telemetry/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module is standalone for the bot but provides
useful insights and telemetry to repeated information.
"""

import asyncio
import shutil
from pathlib import Path
Expand Down
6 changes: 2 additions & 4 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ async def assert_stats_count(
member_id: int,
guild_id: int,
should_be_none: bool,
):
...
): ...


@overload
Expand All @@ -26,8 +25,7 @@ async def assert_stats_count(
field: str,
success_count: int = 0,
failure_count: int = 0,
):
...
): ...


async def assert_stats_count(
Expand Down
1 change: 1 addition & 0 deletions tests/test_disnake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests library modifications to ensure changes work"""

from unittest.mock import Mock

import disnake
Expand Down

0 comments on commit f0293ad

Please sign in to comment.