mirror of
https://github.com/safishamsi/graphify.git
synced 2026-10-26 16:46:41 +00:00
fix(security): reject malformed URL ports
This commit is contained in:
1 parent
847a93f3ca
commit
55a4fbcddc
1 file changed
+7
@@ -115,6 +115,13 @@ def validate_url(url: str) -> str:
|
||||
f"Got: {url!r}"
|
||||
)
|
||||
|
||||
try:
|
||||
port = parsed.port
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"Blocked URL with an invalid port. Got: {url!r}") from exc
|
||||
if port == 0:
|
||||
raise ValueError(f"Blocked URL with port 0. Got: {url!r}")
|
||||
|
||||
hostname = parsed.hostname
|
||||
if hostname:
|
||||
# Block known cloud metadata hostnames
|
||||
|
||||
Reference in new issue
Block a user