Skip to content

Commit

Permalink
Refs #32311 -- Fixed CSRF_FAILURE_VIEW system check errors code.
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani committed Jan 12, 2021
1 parent fdc3d9d commit ba3fb2e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions django/core/checks/security/csrf.py
Expand Up @@ -54,7 +54,7 @@ def check_csrf_failure_view(app_configs, **kwargs):
"The CSRF failure view '%s' could not be imported." %
settings.CSRF_FAILURE_VIEW
)
errors.append(Error(msg, id='security.E025'))
errors.append(Error(msg, id='security.E102'))
else:
try:
inspect.signature(view).bind(None, reason=None)
Expand All @@ -63,5 +63,5 @@ def check_csrf_failure_view(app_configs, **kwargs):
"The CSRF failure view '%s' does not take the correct number of arguments." %
settings.CSRF_FAILURE_VIEW
)
errors.append(Error(msg, id='security.E024'))
errors.append(Error(msg, id='security.E101'))
return errors
8 changes: 4 additions & 4 deletions docs/ref/checks.txt
Expand Up @@ -495,16 +495,16 @@ The following checks are run if you use the :option:`check --deploy` option:
should consider enabling this header to protect user privacy.
* **security.E023**: You have set the :setting:`SECURE_REFERRER_POLICY` setting
to an invalid value.
* **security.E024**: The CSRF failure view ``'path.to.view'`` does not take the
correct number of arguments.
* **security.E025**: The CSRF failure view ``'path.to.view'`` could not be
imported.

The following checks verify that your security-related settings are correctly
configured:

* **security.E100**: :setting:`DEFAULT_HASHING_ALGORITHM` must be ``'sha1'`` or
``'sha256'``.
* **security.E101**: The CSRF failure view ``'path.to.view'`` does not take the
correct number of arguments.
* **security.E102**: The CSRF failure view ``'path.to.view'`` could not be
imported.

Signals
-------
Expand Down
6 changes: 3 additions & 3 deletions tests/check_framework/test_security.py
Expand Up @@ -486,13 +486,13 @@ def test_failure_view_import_error(self):
[
Error(
"The CSRF failure view '' could not be imported.",
id='security.E025',
id='security.E102',
)
],
)

@override_settings(
CSRF_FAILURE_VIEW=f'{__name__}.failure_view_with_invalid_signature',
CSRF_FAILURE_VIEW='check_framework.test_security.failure_view_with_invalid_signature',
)
def test_failure_view_invalid_signature(self):
msg = (
Expand All @@ -502,5 +502,5 @@ def test_failure_view_invalid_signature(self):
)
self.assertEqual(
csrf.check_csrf_failure_view(None),
[Error(msg, id='security.E024')],
[Error(msg, id='security.E101')],
)

0 comments on commit ba3fb2e

Please sign in to comment.