From 4a07582d5d5ac306a66642463c7f4ea5c8e6ef5d Mon Sep 17 00:00:00 2001 From: Frisk Date: Sun, 15 Sep 2024 19:38:42 +0200 Subject: [PATCH] Fixed leeks --- src/queue_handler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/queue_handler.py b/src/queue_handler.py index d1fd218..d997355 100644 --- a/src/queue_handler.py +++ b/src/queue_handler.py @@ -1,6 +1,7 @@ import asyncio import collections import logging +import re from typing import Union, Optional from src.database import db @@ -14,8 +15,14 @@ class UpdateDB: self.updated: list[tuple[str, tuple[Union[str, int], ...]]] = [] def json(self): + def remove_webhooks(arg): + re_match = re.match(r"^(\d{17,20})/[a-zA-Z0-9_-]{68}$", arg) + if re_match is not None: + return f"{re_match.group(1)}/[CENSORED DISCORD WEBHOOK TOKEN]" + else: + return arg # since pickled Discord messages are bytes object which is not serializable, we strip it here - return [(item[0], [arg for arg in item[1] if not isinstance(arg, bytes)]) for item in self.updated] + return [(item[0], [remove_webhooks(arg) for arg in item[1] if not isinstance(arg, bytes)]) for item in self.updated] def add(self, sql_expression: tuple[str, tuple[Union[str, int, bytes], ...]]): self.updated.append(sql_expression)