1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fix use of URLValidator to correctly validate RELEASE_CHECK_URL

This commit is contained in:
jathanism
2021-03-13 11:39:21 -08:00
parent a94e5c7403
commit 68082a88a7

View File

@ -123,13 +123,16 @@ TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
# Validate update repo URL and timeout # Validate update repo URL and timeout
if RELEASE_CHECK_URL: if RELEASE_CHECK_URL:
try: validator = URLValidator(
URLValidator(RELEASE_CHECK_URL) message=(
except ValidationError:
raise ImproperlyConfigured(
"RELEASE_CHECK_URL must be a valid API URL. Example: " "RELEASE_CHECK_URL must be a valid API URL. Example: "
"https://api.github.com/repos/netbox-community/netbox" "https://api.github.com/repos/netbox-community/netbox"
) )
)
try:
validator(RELEASE_CHECK_URL)
except ValidationError as err:
raise ImproperlyConfigured(str(err))
# Enforce a minimum cache timeout for update checks # Enforce a minimum cache timeout for update checks
if RELEASE_CHECK_TIMEOUT < 3600: if RELEASE_CHECK_TIMEOUT < 3600: