mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 05:54:26 +01:00
fix: Update URL validation to allow non-local domains
- Modify the check_local_file_access function to only check for local file prefixes and return True if the URL starts with any of them. - Remove the section of code that parsed the URL and checked if the hostname was in a list of local domains. This change fixes the URL validation in the validators.py file. Previously, only local domains were allowed. After the change, non-local domains are allowed again. (Note: this change was made in response to PR #5318 where the validation was modified to allow more local domains, but also accidentally to block any non-local domain.
This commit is contained in:
@@ -86,23 +86,5 @@ def check_local_file_access(url: str) -> bool:
|
|||||||
"file:///",
|
"file:///",
|
||||||
"file://localhost",
|
"file://localhost",
|
||||||
]
|
]
|
||||||
if any(url.startswith(prefix) for prefix in local_file_prefixes):
|
|
||||||
return True
|
return any(url.startswith(prefix) for prefix in local_file_prefixes)
|
||||||
|
|
||||||
# Parse the URL
|
|
||||||
parsed = urlparse(url)
|
|
||||||
|
|
||||||
# List of local hostnames/IPs without considering ports
|
|
||||||
local_domains = [
|
|
||||||
"localhost",
|
|
||||||
"2130706433", # IP representation of 127.0.0.1
|
|
||||||
"127.0.0.1",
|
|
||||||
"0.0.0.0",
|
|
||||||
"0000" # Not sure what this is for, but keeping it as in original
|
|
||||||
]
|
|
||||||
# Check if the domain part of the URL is in local_domains
|
|
||||||
if parsed.hostname in local_domains:
|
|
||||||
return False # We don't restrict localhost access on different ports
|
|
||||||
|
|
||||||
# Return True for anything else that is deemed "local"
|
|
||||||
return True
|
|
||||||
|
|||||||
Reference in New Issue
Block a user