Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/models/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime
from decimal import Decimal
from typing import Optional
from urllib.parse import urlparse

from app.db.models import UserStatusCreate

Expand Down Expand Up @@ -173,8 +174,11 @@ def validate_proxy_url(value: str | None) -> str | None:
class DiscordValidator:
@staticmethod
def validate_webhook(value: str | None):
if value and not value.startswith("https://discord.com"):
raise ValueError("Discord webhook must start with 'https://discord.com'")
if value:
parsed = urlparse(value)
# validate scheme and hostname
if parsed.scheme != "https" or parsed.hostname not in {"discord.com"}:
raise ValueError("Discord webhook must use https scheme and point to 'discord.com'")
return value


Expand Down