lib: add SentryIgnoredException, to easily ignore exceptions from sentry
This commit is contained in:
parent
295c0bae3f
commit
d988f37afc
|
@ -1,5 +1,6 @@
|
||||||
"""passbook core exceptions"""
|
"""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."""
|
"""Error when a PropertyMapping Exception expression could not be parsed or evaluated."""
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
"""passbook password policy exceptions"""
|
"""passbook password policy exceptions"""
|
||||||
|
from passbook.lib.sentry import SentryIgnoredException
|
||||||
|
|
||||||
|
|
||||||
class PasswordPolicyInvalid(Exception):
|
class PasswordPolicyInvalid(SentryIgnoredException):
|
||||||
"""Exception raised when a Password Policy fails"""
|
"""Exception raised when a Password Policy fails"""
|
||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
|
|
|
@ -4,6 +4,10 @@ from structlog import get_logger
|
||||||
LOGGER = 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):
|
def before_send(event, hint):
|
||||||
"""Check if error is database error, and ignore if so"""
|
"""Check if error is database error, and ignore if so"""
|
||||||
from django_redis.exceptions import ConnectionInterrupted
|
from django_redis.exceptions import ConnectionInterrupted
|
||||||
|
@ -29,6 +33,7 @@ def before_send(event, hint):
|
||||||
ValidationError,
|
ValidationError,
|
||||||
OSError,
|
OSError,
|
||||||
RedisError,
|
RedisError,
|
||||||
|
SentryIgnoredException,
|
||||||
)
|
)
|
||||||
if "exc_info" in hint:
|
if "exc_info" in hint:
|
||||||
_exc_type, exc_value, _ = hint["exc_info"]
|
_exc_type, exc_value, _ = hint["exc_info"]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""policy exceptions"""
|
"""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."""
|
"""Exception that should be raised during Policy Evaluation, and can be recovered from."""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""passbook SAML IDP Exceptions"""
|
"""passbook SAML IDP Exceptions"""
|
||||||
|
from passbook.lib.sentry import SentryIgnoredException
|
||||||
|
|
||||||
|
|
||||||
class CannotHandleAssertion(Exception):
|
class CannotHandleAssertion(SentryIgnoredException):
|
||||||
"""This processor does not handle this assertion."""
|
"""This processor does not handle this assertion."""
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
"""passbook saml source exceptions"""
|
"""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."""
|
"""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."""
|
"""Exception raised when SAML Response contains NameID Format not supported."""
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Processor:
|
||||||
raise MissingSAMLResponse("Request does not contain 'SAMLResponse'")
|
raise MissingSAMLResponse("Request does not contain 'SAMLResponse'")
|
||||||
# relay_state = request.POST.get('RelayState', None)
|
# relay_state = request.POST.get('RelayState', None)
|
||||||
# Check if response is compressed, b64 decode it
|
# 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)
|
self._root = ElementTree.fromstring(self._root_xml)
|
||||||
# Verify signed XML
|
# Verify signed XML
|
||||||
self._verify_signed()
|
self._verify_signed()
|
||||||
|
|
Reference in a new issue