diff options
| author | Ed Morley <emorley@mozilla.com> | 2016-07-26 13:05:27 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-10 20:31:01 -0400 |
| commit | 7399fee6c3bb7eded1ecf5855d71520db299d79d (patch) | |
| tree | 8f767de16e2a46eea82aaffd1c83506c94a67baa /django | |
| parent | 3c2447dd13e495d57700ca8447896acd85044444 (diff) | |
Refs #26947 -- Added a deployment system check for SECURE_HSTS_PRELOAD.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/checks/security/base.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/django/core/checks/security/base.py b/django/core/checks/security/base.py index eee7f854c8..f482f77153 100644 --- a/django/core/checks/security/base.py +++ b/django/core/checks/security/base.py @@ -101,6 +101,12 @@ W020 = Warning( id='security.W020', ) +W021 = Warning( + "You have not set the SECURE_HSTS_PRELOAD setting to True. Without this, " + "your site cannot be submitted to the browser preload list.", + id='security.W021', +) + def _security_middleware(): return ("django.middleware.security.SecurityMiddleware" in settings.MIDDLEWARE_CLASSES or @@ -141,6 +147,16 @@ def check_sts_include_subdomains(app_configs, **kwargs): @register(Tags.security, deploy=True) +def check_sts_preload(app_configs, **kwargs): + passed_check = ( + not _security_middleware() or + not settings.SECURE_HSTS_SECONDS or + settings.SECURE_HSTS_PRELOAD is True + ) + return [] if passed_check else [W021] + + +@register(Tags.security, deploy=True) def check_content_type_nosniff(app_configs, **kwargs): passed_check = ( not _security_middleware() or |
