Browse Source

Merge pull request #3871 from getsentry/fix-strict-networks

Fix handling of invalid IP networks
David Cramer 8 years ago
parent
commit
267e898a9e
3 changed files with 3 additions and 3 deletions
  1. 1 1
      src/sentry/http.py
  2. 1 1
      src/sentry/utils/http.py
  3. 1 1
      src/sentry/utils/validators.py

+ 1 - 1
src/sentry/http.py

@@ -35,7 +35,7 @@ USER_AGENT = 'sentry/{version} (https://getsentry.com)'.format(
 )
 
 DISALLOWED_IPS = {
-    ipaddress.ip_network(six.text_type(i))
+    ipaddress.ip_network(six.text_type(i), strict=False)
     for i in settings.SENTRY_DISALLOWED_IPS
 }
 

+ 1 - 1
src/sentry/utils/http.py

@@ -179,7 +179,7 @@ def is_valid_ip(ip_address, project):
             return False
 
         # Check to make sure it's actually a range before
-        if '/' in addr and ipaddress.ip_address(six.text_type(ip_address)) in ipaddress.ip_network(six.text_type(addr)):
+        if '/' in addr and ipaddress.ip_address(six.text_type(ip_address)) in ipaddress.ip_network(six.text_type(addr), strict=False):
             return False
 
     return True

+ 1 - 1
src/sentry/utils/validators.py

@@ -12,7 +12,7 @@ def validate_ip(value, required=True):
         return
 
     # will raise a ValueError
-    ipaddress.ip_network(six.text_type(value))
+    ipaddress.ip_network(six.text_type(value), strict=False)
     return value