zulip/zproject
Alex Vandiver 596cf2580b sentry: Ignore all SuspiciousOperation loggers.
django.security.DisallowedHost is only one of a set of exceptions that
are "SuspiciousOperation" exceptions; all return a 400 to the user
when they bubble up[1]; all of them are uninteresting to Sentry.
While they may, in bulk, show a mis-configuration of some sort of the
application, such a failure should be detected via the increase in
400's, not via these, which are uninteresting individually.

While all of these are subclasses of SuspiciousOperation, we enumerate
them explicitly for a number of reasons:

 - There is no one logger we can ignore that captures all of them.
   Each of the errors uses its own logger, and django does not supply
   a `django.security` logger that all of them feed into.

 - Nor can we catch this by examining the exception object.  The
   SuspiciousOperation exception is raised too early in the stack for
   us to catch the exception by way of middleware and check
   `isinstance`.  But at the Sentry level, in `add_context`, it is no
   longer an exception but a log entry, and as such we have no
   `isinstance` that can be applied; we only know the logger name.

 - Finally, there is the semantic argument that while we have decided
   to ignore this set of security warnings, we _may_ wish to log new
   ones that may be added at some point in the future.  It is better
   to opt into those ignores than to blanket ignore all messages from
   the security logger.

This moves the DisallowedHost `ignore_logger` to be adjacent to its
kin, and not on the middleware that may trigger it.  Consistency is
more important than locality in this case.

Of these, the DisallowedHost logger if left as the only one that is
explicitly ignored in the LOGGING configuration in
`computed_settings.py`; it is by far the most frequent, and the least
likely to be malicious or impactful (unlike, say, RequestDataTooBig).

[1] https://docs.djangoproject.com/en/3.0/ref/exceptions/#suspiciousoperation
2020-08-12 16:08:38 -07:00
..
jinja2 python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
__init__.py Rename Django project to zproject. 2013-08-07 11:04:03 -04:00
backends.py python: Replace ujson with orjson. 2020-08-11 10:55:12 -07:00
computed_settings.py memcached: Switch from pylibmc to python-binary-memcached. 2020-08-06 12:51:14 -07:00
config.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
configured_settings.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
default_settings.py apple_auth: Change BUNDLE_ID setting to APP_ID everywhere. 2020-07-28 17:12:49 -07:00
dev_settings.py dev_settings: Add EMAIL_PORT setting in zproject/dev_settings.py. 2020-08-04 11:03:40 -07:00
dev_urls.py urls: Migrate dev urls to use modern django patterns. 2020-06-23 15:02:44 -07:00
email_backends.py dev_settings: Add EMAIL_PORT setting in zproject/dev_settings.py. 2020-08-04 11:03:40 -07:00
legacy_urls.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
prod_settings_template.py docs: Capitalize Markdown consistently. 2020-08-11 10:23:06 -07:00
sentry.py sentry: Ignore all SuspiciousOperation loggers. 2020-08-12 16:08:38 -07:00
settings.py python: Add noqa comments for the specific star imports we allow. 2020-06-11 15:36:43 -07:00
terms.md.template docs: Capitalize Markdown consistently. 2020-08-11 10:23:06 -07:00
test_extra_settings.py apple_auth: Change BUNDLE_ID setting to APP_ID everywhere. 2020-07-28 17:12:49 -07:00
test_settings.py python: Sort imports with isort. 2020-06-11 16:45:32 -07:00
urls.py drafts: Add an API endpoint for fetching drafts. 2020-07-28 17:18:35 -07:00
wsgi.py wsgi: Try to avoid extra django.setup calls. 2020-06-18 20:16:34 -07:00