ó
®â0_c           @   s°  d  d l  m Z d d l m Z m Z m Z d d l m Z d Z d Z	 e d d d	 ƒZ
 e d
 d d ƒZ e d d d ƒZ e d d d ƒZ e d d d ƒZ e d d d ƒZ e d d d ƒZ e d i e d 6e	 d 6d d ƒZ e d d d ƒZ e d d d ƒZ e d d d ƒZ e d  d d! ƒZ d" „  Z d# „  Z e e j d$ e ƒd% „  ƒ Z e e j d$ e ƒd& „  ƒ Z e e j d$ e ƒd' „  ƒ Z e e j d$ e ƒd( „  ƒ Z e e j d$ e ƒd) „  ƒ Z e e j d$ e ƒd* „  ƒ Z e e j d$ e ƒd+ „  ƒ Z  e e j d$ e ƒd, „  ƒ Z! e e j d$ e ƒd- „  ƒ Z" e e j d$ e ƒd. „  ƒ Z# e e j d$ e ƒd/ „  ƒ Z$ e e j d$ e ƒd0 „  ƒ Z% d1 S(2   iÿÿÿÿ(   t   settingsi   (   t   Tagst   Warningt   register(   t   patch_middleware_messagei2   i   sÜ   You do not have 'django.middleware.security.SecurityMiddleware' in your MIDDLEWARE so the SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, and SECURE_SSL_REDIRECT settings will have no effect.t   ids   security.W001s3  You do not have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE, so your pages will not be served with an 'x-frame-options' header. Unless there is a good reason for your site to be served in a frame, you should consider enabling this header to help prevent clickjacking attacks.s   security.W002s,  You have not set a value for the SECURE_HSTS_SECONDS setting. If your entire site is served only over SSL, you may want to consider setting a value and enabling HTTP Strict Transport Security. Be sure to read the documentation first; enabling HSTS carelessly can cause serious, irreversible problems.s   security.W004s  You have not set the SECURE_HSTS_INCLUDE_SUBDOMAINS setting to True. Without this, your site is potentially vulnerable to attack via an insecure connection to a subdomain. Only set this to True if you are certain that all subdomains of your domain should be served exclusively via SSL.s   security.W005sû   Your SECURE_CONTENT_TYPE_NOSNIFF setting is not set to True, so your pages will not be served with an 'x-content-type-options: nosniff' header. You should consider enabling this header to prevent the browser from identifying content types incorrectly.s   security.W006sü   Your SECURE_BROWSER_XSS_FILTER setting is not set to True, so your pages will not be served with an 'x-xss-protection: 1; mode=block' header. You should consider enabling this header to activate the browser's XSS filtering and help prevent XSS attacks.s   security.W007s  Your SECURE_SSL_REDIRECT setting is not set to True. Unless your site should be available over both SSL and non-SSL connections, you may want to either set this setting True or configure a load balancer or reverse-proxy server to redirect all connections to HTTPS.s   security.W008sî   Your SECRET_KEY has less than %(min_length)s characters or less than %(min_unique_chars)s unique characters. Please generate a long and random SECRET_KEY, otherwise many of Django's security-critical features will be vulnerable to attack.t
   min_lengtht   min_unique_charss   security.W009s4   You should not have DEBUG set to True in deployment.s   security.W018s  You have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE, but X_FRAME_OPTIONS is not set to 'DENY'. The default is 'SAMEORIGIN', but unless there is a good reason for your site to serve other parts of itself in a frame, you should change it to 'DENY'.s   security.W019s.   ALLOWED_HOSTS must not be empty in deployment.s   security.W020s‚   You have not set the SECURE_HSTS_PRELOAD setting to True. Without this, your site cannot be submitted to the browser preload list.s   security.W021c           C   s%   d t  j k p$ t  j o$ d t  j k S(   Ns-   django.middleware.security.SecurityMiddleware(   R    t   MIDDLEWARE_CLASSESt
   MIDDLEWARE(    (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   _security_middlewareo   s    c           C   s%   d t  j k p$ t  j o$ d t  j k S(   Ns6   django.middleware.clickjacking.XFrameOptionsMiddleware(   R    R   R	   (    (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   _xframe_middlewaret   s    t   deployc         K   s    t  ƒ  } | r g  St t ƒ g S(   N(   R
   R   t   W001(   t   app_configst   kwargst   passed_check(    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_security_middlewarey   s    	c         K   s    t  ƒ  } | r g  St t ƒ g S(   N(   R   R   t   W002(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_xframe_options_middleware   s    	c         K   s$   t  ƒ  p t j } | r g  St g S(   N(   R
   R    t   SECURE_HSTS_SECONDSt   W004(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt	   check_sts…   s    c         K   s4   t  ƒ  p  t j p  t j t k } | r- g  St g S(   N(   R
   R    R   t   SECURE_HSTS_INCLUDE_SUBDOMAINSt   Truet   W005(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_sts_include_subdomains‹   s    

c         K   s4   t  ƒ  p  t j p  t j t k } | r- g  St g S(   N(   R
   R    R   t   SECURE_HSTS_PRELOADR   t   W021(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_sts_preload•   s    

c         K   s*   t  ƒ  p t j t k } | r# g  St g S(   N(   R
   R    t   SECURE_CONTENT_TYPE_NOSNIFFR   t   W006(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_content_type_nosniffŸ   s    
c         K   s*   t  ƒ  p t j t k } | r# g  St g S(   N(   R
   R    t   SECURE_BROWSER_XSS_FILTERR   t   W007(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_xss_filter¨   s    
c         K   s*   t  ƒ  p t j t k } | r# g  St g S(   N(   R
   R    t   SECURE_SSL_REDIRECTR   t   W008(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_ssl_redirect±   s    
c         K   sS   t  t d d  ƒ o? t t t j ƒ ƒ t k o? t t j ƒ t k } | rL g  St g S(   Nt
   SECRET_KEY(	   t   getattrR    t   Nonet   lent   setR'   t    SECRET_KEY_MIN_UNIQUE_CHARACTERSt   SECRET_KEY_MIN_LENGTHt   W009(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_secret_keyº   s    c         K   s   t  j } | r g  St g S(   N(   R    t   DEBUGt   W018(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_debugÄ   s    
c         K   s0   t  ƒ  p t j d k } | r# g  St t ƒ g S(   Nt   DENY(   R   R    t   X_FRAME_OPTIONSR   t   W019(   R   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_xframe_denyÊ   s    
c         K   s   t  j r g  St g S(   N(   R    t   ALLOWED_HOSTSt   W020(   R   R   (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   check_allowed_hostsÓ   s    N(&   t   django.confR    t    R   R   R   t   utilsR   R-   R,   R   R   R   R   R   R"   R%   R.   R1   R5   R8   R   R
   R   t   securityR   R   R   R   R   R   R    R#   R&   R/   R2   R6   R9   (    (    (    sB   /tmp/pip-unpacked-wheel-BAJOf3/django/core/checks/security/base.pyt   <module>   sr   														

			
	