
vÅÏ^ì  ã               @   s  d  d l  m Z d d l m Z m Z m Z m Z d d d d d d	 d
 d h 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 e d e	 i 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+ j d, j e e ƒ ƒ ƒ d d- ƒZ d. d/ „  Z d0 d1 „  Z e e j d2 d3 ƒd4 d5 „  ƒ Z e e j d2 d3 ƒd6 d7 „  ƒ Z e e j d2 d3 ƒd8 d9 „  ƒ Z e e j d2 d3 ƒd: d; „  ƒ Z  e e j d2 d3 ƒd< d= „  ƒ Z! e e j d2 d3 ƒd> d? „  ƒ Z" e e j d2 d3 ƒd@ dA „  ƒ Z# e e j d2 d3 ƒdB dC „  ƒ Z$ e e j d2 d3 ƒdD dE „  ƒ Z% e e j d2 d3 ƒdF dG „  ƒ Z& e e j d2 d3 ƒdH dI „  ƒ Z' e e j d2 d3 ƒdJ dK „  ƒ Z( dL S)Mé    )Úsettingsé   )ÚErrorÚTagsÚWarningÚregisterzno-referrerzno-referrer-when-downgradeÚoriginzorigin-when-cross-originzsame-originzstrict-originzstrict-origin-when-cross-originz
unsafe-urlé2   é   zôYou do not have 'django.middleware.security.SecurityMiddleware' in your MIDDLEWARE so the SECURE_HSTS_SECONDS, SECURE_CONTENT_TYPE_NOSNIFF, SECURE_BROWSER_XSS_FILTER, SECURE_REFERRER_POLICY, and SECURE_SSL_REDIRECT settings will have no effect.Úidzsecurity.W001a3  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.zsecurity.W002a,  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.zsecurity.W004a  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.zsecurity.W005zû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.zsecurity.W006a  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.zsecurity.W008zî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.Z
min_lengthZmin_unique_charszsecurity.W009z4You should not have DEBUG set to True in deployment.zsecurity.W018zöYou have 'django.middleware.clickjacking.XFrameOptionsMiddleware' in your MIDDLEWARE, but X_FRAME_OPTIONS is not set to 'DENY'. Unless there is a good reason for your site to serve other parts of itself in a frame, you should change it to 'DENY'.zsecurity.W019z.ALLOWED_HOSTS must not be empty in deployment.zsecurity.W020z‚You have not set the SECURE_HSTS_PRELOAD setting to True. Without this, your site cannot be submitted to the browser preload list.zsecurity.W021z¶You have not set the SECURE_REFERRER_POLICY setting. Without this, your site will not send a Referrer-Policy header. You should consider enabling this header to protect user privacy.zsecurity.W022zDYou have set the SECURE_REFERRER_POLICY setting to an invalid value.ZhintzValid values are: {}.z, zsecurity.E023c               C   s   d t  j k S)Nz-django.middleware.security.SecurityMiddleware)r   Ú
MIDDLEWARE© r   r   úB/tmp/pip-build-8lau8j11/django/django/core/checks/security/base.pyÚ_security_middlewarew   s    r   c               C   s   d t  j k S)Nz6django.middleware.clickjacking.XFrameOptionsMiddleware)r   r   r   r   r   r   Ú_xframe_middleware{   s    r   ZdeployTc             K   s   t  ƒ  } | r g  St g S)N)r   ÚW001)Úapp_configsÚkwargsÚpassed_checkr   r   r   Úcheck_security_middleware   s    	r   c             K   s   t  ƒ  } | r g  St g S)N)r   ÚW002)r   r   r   r   r   r   Úcheck_xframe_options_middleware…   s    	r   c             K   s$   t  ƒ  p t j } | r g  St g S)N)r   r   ÚSECURE_HSTS_SECONDSÚW004)r   r   r   r   r   r   Ú	check_sts‹   s    r   c             K   s4   t  ƒ  p  t j p  t j d k } | r- g  St g S)NT)r   r   r   ZSECURE_HSTS_INCLUDE_SUBDOMAINSÚW005)r   r   r   r   r   r   Úcheck_sts_include_subdomains‘   s    

r   c             K   s4   t  ƒ  p  t j p  t j d k } | r- g  St g S)NT)r   r   r   ZSECURE_HSTS_PRELOADÚW021)r   r   r   r   r   r   Úcheck_sts_preload›   s    

r   c             K   s*   t  ƒ  p t j d k } | r# g  St g S)NT)r   r   ZSECURE_CONTENT_TYPE_NOSNIFFÚW006)r   r   r   r   r   r   Úcheck_content_type_nosniff¥   s    
r    c             K   s*   t  ƒ  p t j d k } | r# g  St g S)NT)r   r   ZSECURE_SSL_REDIRECTÚW008)r   r   r   r   r   r   Úcheck_ssl_redirect®   s    
r"   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)NÚ
SECRET_KEY)Úgetattrr   ÚlenÚsetr#   Ú SECRET_KEY_MIN_UNIQUE_CHARACTERSÚSECRET_KEY_MIN_LENGTHÚW009)r   r   r   r   r   r   Úcheck_secret_key·   s    r*   c             K   s   t  j } | r g  St g S)N)r   ÚDEBUGÚW018)r   r   r   r   r   r   Úcheck_debugÁ   s    
r-   c             K   s*   t  ƒ  p t j d k } | r# g  St g S)NZDENY)r   r   ZX_FRAME_OPTIONSÚW019)r   r   r   r   r   r   Úcheck_xframe_denyÇ   s    
r/   c             K   s   t  j r g  St g S)N)r   ZALLOWED_HOSTSÚW020)r   r   r   r   r   Úcheck_allowed_hostsÐ   s    r1   c             K   sy   t  ƒ  ru t j d  k r t g St t j t ƒ rS d d „  t j j d ƒ Dƒ } n t t j ƒ } | t k su t	 g Sg  S)Nc             S   s   h  |  ] } | j  ƒ  ’ q Sr   )Ústrip)Ú.0Úvr   r   r   ú	<setcomp>Ü   s   	 z(check_referrer_policy.<locals>.<setcomp>ú,)
r   r   ZSECURE_REFERRER_POLICYÚW022Ú
isinstanceÚstrÚsplitr&   ÚREFERRER_POLICY_VALUESÚE023)r   r   Úvaluesr   r   r   Úcheck_referrer_policyÕ   s    	"r>   N))Zdjango.confr   Ú r   r   r   r   r;   r(   r'   r   r   r   r   r   r!   r)   r,   r.   r0   r   r7   ÚformatÚjoinÚsortedr<   r   r   Úsecurityr   r   r   r   r   r    r"   r*   r-   r/   r1   r>   r   r   r   r   Ú<module>   s|   "															!!!!
!
!	!	!
!!	!