diff --git a/passbook/core/exceptions.py b/passbook/core/exceptions.py index 53961e631..01fc51bfe 100644 --- a/passbook/core/exceptions.py +++ b/passbook/core/exceptions.py @@ -1,5 +1,6 @@ """passbook core exceptions""" +from passbook.lib.sentry import SentryIgnoredException -class PropertyMappingExpressionException(Exception): +class PropertyMappingExpressionException(SentryIgnoredException): """Error when a PropertyMapping Exception expression could not be parsed or evaluated.""" diff --git a/passbook/factors/password/exceptions.py b/passbook/factors/password/exceptions.py index f561ec5ac..ca56c03c0 100644 --- a/passbook/factors/password/exceptions.py +++ b/passbook/factors/password/exceptions.py @@ -1,7 +1,8 @@ """passbook password policy exceptions""" +from passbook.lib.sentry import SentryIgnoredException -class PasswordPolicyInvalid(Exception): +class PasswordPolicyInvalid(SentryIgnoredException): """Exception raised when a Password Policy fails""" messages = [] diff --git a/passbook/lib/sentry.py b/passbook/lib/sentry.py index 886696e26..453df529e 100644 --- a/passbook/lib/sentry.py +++ b/passbook/lib/sentry.py @@ -4,6 +4,10 @@ from structlog import get_logger LOGGER = get_logger() +class SentryIgnoredException(Exception): + """Base Class for all errors that are supressed, and not sent to sentry.""" + + def before_send(event, hint): """Check if error is database error, and ignore if so""" from django_redis.exceptions import ConnectionInterrupted @@ -29,6 +33,7 @@ def before_send(event, hint): ValidationError, OSError, RedisError, + SentryIgnoredException, ) if "exc_info" in hint: _exc_type, exc_value, _ = hint["exc_info"] diff --git a/passbook/policies/exceptions.py b/passbook/policies/exceptions.py index 5ff1f4d45..ec27684dd 100644 --- a/passbook/policies/exceptions.py +++ b/passbook/policies/exceptions.py @@ -1,5 +1,6 @@ """policy exceptions""" +from passbook.lib.sentry import SentryIgnoredException -class PolicyException(Exception): +class PolicyException(SentryIgnoredException): """Exception that should be raised during Policy Evaluation, and can be recovered from.""" diff --git a/passbook/providers/saml/exceptions.py b/passbook/providers/saml/exceptions.py index a78218ca6..81b0b1b39 100644 --- a/passbook/providers/saml/exceptions.py +++ b/passbook/providers/saml/exceptions.py @@ -1,5 +1,6 @@ """passbook SAML IDP Exceptions""" +from passbook.lib.sentry import SentryIgnoredException -class CannotHandleAssertion(Exception): +class CannotHandleAssertion(SentryIgnoredException): """This processor does not handle this assertion.""" diff --git a/passbook/sources/saml/exceptions.py b/passbook/sources/saml/exceptions.py index 7f91e2bad..2ea148df8 100644 --- a/passbook/sources/saml/exceptions.py +++ b/passbook/sources/saml/exceptions.py @@ -1,9 +1,10 @@ """passbook saml source exceptions""" +from passbook.lib.sentry import SentryIgnoredException -class MissingSAMLResponse(Exception): +class MissingSAMLResponse(SentryIgnoredException): """Exception raised when request does not contain SAML Response.""" -class UnsupportedNameIDFormat(Exception): +class UnsupportedNameIDFormat(SentryIgnoredException): """Exception raised when SAML Response contains NameID Format not supported.""" diff --git a/passbook/sources/saml/processors/base.py b/passbook/sources/saml/processors/base.py index a094b32bf..db12f35dc 100644 --- a/passbook/sources/saml/processors/base.py +++ b/passbook/sources/saml/processors/base.py @@ -37,7 +37,7 @@ class Processor: raise MissingSAMLResponse("Request does not contain 'SAMLResponse'") # relay_state = request.POST.get('RelayState', None) # Check if response is compressed, b64 decode it - self._root_xml = response = decode_base64_and_inflate(raw_response) + self._root_xml = decode_base64_and_inflate(raw_response) self._root = ElementTree.fromstring(self._root_xml) # Verify signed XML self._verify_signed()