Przeglądaj źródła

Merge pull request #5978 from jathanism/jathanism-fix-invalid-release_check_url

Fix use of `URLValidator` to correctly validate `RELEASE_CHECK_URL`
Jeremy Stretch 4 lat temu
rodzic
commit
7e437455c1
1 zmienionych plików z 7 dodań i 4 usunięć
  1. 7 4
      netbox/netbox/settings.py

+ 7 - 4
netbox/netbox/settings.py

@@ -123,13 +123,16 @@ TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
 
 # Validate update repo URL and timeout
 if RELEASE_CHECK_URL:
-    try:
-        URLValidator(RELEASE_CHECK_URL)
-    except ValidationError:
-        raise ImproperlyConfigured(
+    validator = URLValidator(
+        message=(
             "RELEASE_CHECK_URL must be a valid API URL. Example: "
             "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
 if RELEASE_CHECK_TIMEOUT < 3600: