Skip to content

Potential fix for code scanning alert no. 2: Incomplete URL substring sanitization - #5

Merged
M03ED merged 1 commit into
nextfrom
url-substring-sanitization
Sep 25, 2025
Merged

Potential fix for code scanning alert no. 2: Incomplete URL substring sanitization#5
M03ED merged 1 commit into
nextfrom
url-substring-sanitization

Conversation

@M03ED

@M03ED M03ED commented Sep 25, 2025

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/PasarGuard/panel/security/code-scanning/2

To fix the problem, update the Discord webhook URL validation to robustly check the hostname using URL parsing rather than simple string matching. Specifically:

  • Parse the URL using urllib.parse.urlparse.
  • Verify that the scheme is HTTPS and the netloc/host is either exactly discord.com or a documented canonical subdomain (if allowed), such as discord.com (and optionally discordapp.com if relevant).
  • Reject URLs that do not meet these requirements.
  • Make these changes within class DiscordValidator, specifically in the validate_webhook method, replacing the string prefix check.

You'll need to:

  • Import urlparse from urllib.parse (if not present).
  • Adjust the method to parse the URL, handle possible errors (such as poorly formed URLs), and ensure the host and scheme are as required.
  • Only accept the webhook URL if both the scheme and host match.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@M03ED
M03ED changed the base branch from main to next September 25, 2025 10:26
@M03ED
M03ED marked this pull request as ready for review September 25, 2025 10:29
@M03ED
M03ED merged commit d182d9e into next Sep 25, 2025
15 checks passed
@M03ED
M03ED deleted the url-substring-sanitization branch September 25, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant