Skip to content

Commit

Permalink
Hotfix v0.1.3
Browse files Browse the repository at this point in the history
Added protection against bypass by creating community service channels
  • Loading branch information
cymon4380 committed May 25, 2024
1 parent 2a73059 commit fc14616
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src/venv
__pycache__
src/erisprotect.log
.idea
.idea
src/tests
16 changes: 14 additions & 2 deletions src/plugins/antinuke/cogs/listeners/antinuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ async def on_guild_channel_create(self, channel: disnake.abc.GuildChannel):
guild = channel.guild
target = channel
permission = AntiNukePermission.CreateChannels
user = await get_last_audit_log_user(guild, disnake.AuditLogAction.channel_create)

user = None
action = None
async for entry in guild.audit_logs(limit=20):
if entry.action == disnake.AuditLogAction.guild_update or\
(entry.action == disnake.AuditLogAction.channel_create and entry.target == channel):
user = entry.user
action = entry.action
break

if user is None or action is None:
return

if AntiNukePermissions.from_database(user.id, guild).has_permissions(permission):
return
Expand All @@ -53,6 +64,7 @@ async def on_guild_channel_create(self, channel: disnake.abc.GuildChannel):
)

entry.save()

await AntiNukeGuildData.get(guild).add_action(permission)

@commands.Cog.listener()
Expand Down Expand Up @@ -148,7 +160,7 @@ async def on_guild_role_update(self, before: disnake.Role, after: disnake.Role):
async def on_webhooks_update(self, channel: disnake.abc.GuildChannel):
guild = channel.guild
entry = None
async for audit_entry in guild.audit_logs(limit=10):
async for audit_entry in guild.audit_logs(limit=20):
if audit_entry.action in [
disnake.AuditLogAction.webhook_create,
disnake.AuditLogAction.webhook_update,
Expand Down

0 comments on commit fc14616

Please sign in to comment.