Fix code scanning alert no. 2: Incomplete URL substring sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
David Soria Parra
2024-11-24 21:06:37 +00:00
committed by GitHub
parent da12f5fc42
commit d20b245bd3

View File

@@ -72,8 +72,8 @@ def extract_issue_id(issue_id_or_url: str) -> str:
if issue_id_or_url.startswith(("http://", "https://")):
parsed_url = urlparse(issue_id_or_url)
if not parsed_url.netloc.endswith("sentry.io"):
raise SentryError("Invalid Sentry URL. Must be a URL ending with sentry.io")
if not parsed_url.hostname or not parsed_url.hostname.endswith(".sentry.io"):
raise SentryError("Invalid Sentry URL. Must be a URL ending with .sentry.io")
path_parts = parsed_url.path.strip("/").split("/")
if len(path_parts) < 2 or path_parts[0] != "issues":