§
    ÎÑßjø8  ã                   óF   — d Z ddlZddlZddlZddlZ G d„ de¦  «        ZdS )z,Checker for CherryPy sites and mounted apps.é    Nc                   ó¤   — e Zd ZdZdZ	 d„ Zd„ Zdd„ZdZd„ Z	d	„ Z
d
„ Zd„ Zd„ Zdddddddddddœ
Zi Zd„ Zd„ Zg Zd„ Zd„ Zi Zd„ Zd„ Zd„ Zd„ ZdS )ÚCheckeraÕ  A checker for CherryPy sites and their mounted applications.

    When this object is called at engine startup, it executes each
    of its own methods whose names start with ``check_``. If you wish
    to disable selected checks, simply add a line in your global
    config which sets the appropriate method to False::

        [global]
        checker.check_skipped_app_config = False

    You may also dynamically add or replace ``check_*`` methods in this way.
    Tc                 ó.   — |                       ¦   «          dS )zInitialize Checker instance.N)Ú_populate_known_types)Úselfs    úG/opt/saltstack/salt/lib/python3.11/site-packages/cherrypy/_cpchecker.pyÚ__init__zChecker.__init__   s   € à×"Ò"Ñ$Ô$Ð$Ð$Ð$ó    c                 ó6  — | j         r‘t          j        }| j        t          _        	 t          | ¦  «        D ]C}|                     d¦  «        r,t          | |¦  «        }|rt          |d¦  «        r
 |¦   «          ŒD	 |t          _        dS # |t          _        w xY wdS )zRun all check_* methods.Úcheck_Ú__call__N)ÚonÚwarningsÚformatwarningÚdirÚ
startswithÚgetattrÚhasattr)r   ÚoldformatwarningÚnameÚmethods       r   r   zChecker.__call__   s¶   € àŒ7ð 
	:Ý'Ô5ÐØ%)Ô%7�HÔ"ð:Ý ™IœIð %ð %�DØ—’ xÑ0Ô0ð %Ý!(¨¨tÑ!4Ô!4˜Ø!ð %¥g¨f°jÑ&AÔ&Að %Ø"˜F™HœH˜Høð	%ð *:•Ô&Ð&Ð&øÐ)9•Ô&Ð9Ð9Ð9Ð9ð
	:ð 
	:s   ¦AB ÂBNc                 ó   — d|z  S )zFormat a warning.zCherryPy Checker:
%s

© )r   ÚmessageÚcategoryÚfilenameÚlinenoÚlines         r   r   zChecker.formatwarning,   s   € à*¨WÑ4Ð4r
   Fc                 óî  — t           j        j                             ¦   «         D ]Ð\  }}t	          |t           j        ¦  «        sŒ |j        sŒ(|dk    rŒ/|                     d¦  «                             d¦  «        }|j         	                    ¦   «         D ]_}|                     d¦  «                             d¦  «        }|dt          |¦  «        …         |k    rt          j        d|›d|›�¦  «         Œ`ŒÑdS )z;Check for App config with sections that repeat script_name.Ú ú/NúThe application mounted at z5 has config entries that start with its script name: )ÚcherrypyÚtreeÚappsÚitemsÚ
isinstanceÚApplicationÚconfigÚstripÚsplitÚkeysÚlenr   Úwarn)r   ÚsnÚappÚsn_atomsÚkeyÚ	key_atomss         r   Ú4check_app_config_entries_dont_start_with_script_namez<Checker.check_app_config_entries_dont_start_with_script_name3   s  € å”}Ô)×/Ò/Ñ1Ô1ð 	Oð 	O‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØ”:ð ØØ�RŠxˆxØØ—x’x ‘}”}×*Ò*¨3Ñ/Ô/ˆHØ”z—’Ñ(Ô(ð Oð O�ØŸIšI c™NœN×0Ò0°Ñ5Ô5�	Ø˜^�c (™mœm˜^Ô,°Ò8Ð8Ý”M�MàIKÈÈØILÈðNñOô Oð OøðOð	Oð 	Or
   c                 ó6  — t           j        j                             ¦   «         D ]ô\  }}t	          |t           j        ¦  «        sŒ g }|j                             ¦   «         D ]l\  }}|                     d¦  «        rR|                     ¦   «         D ]=\  }}dD ]5}|                     |¦  «        r|                     d|›d|›d|›�¦  «         Œ6Œ>Œm|rJ| 	                    dd|z  ¦  «         t          j        t          j                             |¦  «        ¦  «         ŒõdS )	z<Check for mounted Applications that have site-scoped config.r!   )zengine.zserver.ztree.zchecker.ú[z] z = r   zÓThe application mounted at %r contains the following config entries, which are only allowed in site-wide config. Move them to a [global] section and pass them to cherrypy.config.update() instead of tree.mount().N)r#   r$   r%   r&   r'   r(   r)   r   ÚappendÚinsertr   r.   ÚosÚlinesepÚjoin)	r   r/   r0   ÚmsgÚsectionÚentriesr2   ÚvalueÚns	            r   Ú'check_site_config_entries_in_app_configz/Checker.check_site_config_entries_in_app_configE   sW  € å”}Ô)×/Ò/Ñ1Ô1ð 	4ð 	4‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØàˆCØ$'¤J×$4Ò$4Ñ$6Ô$6ð Bð BÑ �˜Ø×%Ò% cÑ*Ô*ð BØ&-§m¢m¡o¤oð Bð B™
˜˜UØ!Lð Bð B˜AØ"Ÿ~š~¨aÑ0Ô0ð BØ #§
¢
 
Ø,3¨G¨G°S°S°S¸%¸%ð,Añ !Bô !Bð !BøðBøð ð 4Ø—
’
˜1ð6ð 9;ñ	;ñ<ô <ð <õ ”�bœjŸošo¨cÑ2Ô2Ñ3Ô3Ð3øð'	4ð 	4r
   c                 óì   — t           j        j                             ¦   «         D ]O\  }}t	          |t           j        ¦  «        sŒ |j        s(d|z  }| j        r|dz  }t          j	        |¦  «          dS ŒPdS )z3Check for mounted Applications that have no config.z2The Application mounted at %r has an empty config.zÄ It looks like the config you passed to cherrypy.config.update() contains application-specific sections. You must explicitly pass application config via cherrypy.tree.mount(..., config=app_config)N)
r#   r$   r%   r&   r'   r(   r)   Úglobal_config_contained_pathsr   r.   )r   r/   r0   r<   s       r   Úcheck_skipped_app_configz Checker.check_skipped_app_config\   s—   € å”}Ô)×/Ò/Ñ1Ô1ð 	ð 	‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØ”:ð 	ØJÈRÑO�ØÔ5ð KØð Jñ K�Cõ
 ”˜cÑ"Ô"Ð"Ø��ð	ð	ð 	r
   c           	      ó`  — t           j        j                             ¦   «         D ]‰\  }}t	          |t           j        ¦  «        sŒ |j        sŒ(|j                             ¦   «         D ]G}|                     d¦  «        s| 	                    d¦  «        rt          j        d|›d|›d�¦  «         ŒHŒŠdS )z?Check for App config with extraneous brackets in section names.r6   ú]r"   z4 has config section names with extraneous brackets: zR. Config *files* need brackets; config *dicts* (e.g. passed to tree.mount) do not.N)r#   r$   r%   r&   r'   r(   r)   r,   r   Úendswithr   r.   )r   r/   r0   r2   s       r   Úcheck_app_config_bracketsz!Checker.check_app_config_bracketsl   sÖ   € å”}Ô)×/Ò/Ñ1Ô1ð 	Kð 	K‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØ”:ð ØØ”z—’Ñ(Ô(ð Kð K�Ø—>’> #Ñ&Ô&ð K¨#¯,ª,°sÑ*;Ô*;ð KÝ”M�Mð BDÀÀÀSÀSÀSðJñKô Kð KøðKð	Kð 	Kr
   c                 ó�  — t           j        }t           j        j                             ¦   «         D �]”\  }}t          |t           j        ¦  «        sŒ!||_        |j        D �]c}| 	                    |dz   ¦  «         |j        j
        } |dd¦  «        �r/d} |d¦  «        } |d¦  «        }|€d}nñd}	t          j                             |¦  «        rW|}	|rRd	}t          j                             ||d
d…         ¦  «        }
t          j                             |
¦  «        r	|d|
›d�z  }nI|sd}nDt          j                             ||¦  «        }	t          j                             |	¦  «        s|	›d�}|	r.t          j                             |	¦  «        s|r|dz  }|d|	z  z  }|rt!          j        |›d|›d|›d|›�¦  «         �Œe�Œ–dS )z4Check Application config for incorrect static paths.z/dummy.htmlztools.staticdir.onFr    ztools.staticdir.rootztools.staticdir.dirNztools.staticdir.dir is not set.z8dir is an absolute path, even though a root is provided.é   z0
If you meant to serve the filesystem folder at z$, remove the leading slash from dir.z,dir is a relative path and no root provided.z is not an absolute path.ú
z3%r (root + dir) is not an existing filesystem path.z
section: [z]
root: z
dir: )r#   Úrequestr$   r%   r&   r'   r(   r0   r)   Úget_resourceÚgetr9   ÚpathÚisabsr;   Úexistsr   r.   )r   rL   r/   r0   r=   Úconfr<   Úrootr   ÚfulldirÚtestdirs              r   Úcheck_static_pathszChecker.check_static_paths{   sA  € õ Ô"ˆÝ”}Ô)×/Ò/Ñ1Ô1ð /	Cñ /	C‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØˆGŒKØœ:ð +Cñ +C�à×$Ò$ W¨}Ñ%<Ñ=Ô=Ð=Ø”~Ô)�à�4Ð,¨eÑ4Ô4ñ &CØ�CØ˜4Ð 6Ñ7Ô7�DØ˜$Ð4Ñ5Ô5�CØ�{Ø?˜˜à"$˜Ýœ7Ÿ=š=¨Ñ-Ô-ð 3Ø&)˜GØ#ð Pð(D å*,¬'¯,ª,°t¸SÀÀÀ¼WÑ*EÔ*E Ý#%¤7§>¢>°'Ñ#:Ô#:ð !PØ$' Cð FMÀWÀWð)Oñ%P Cøð
 $(ð 3ð%8ð !$ õ +-¬'¯,ª,°t¸SÑ*AÔ*A Ý')¤w§}¢}°WÑ'=Ô'=ð !3à(/¨¨ð,2 Cð #ð B­2¬7¯>ª>¸'Ñ+BÔ+Bð BØ"ð ,Ø # t¡ Øð %7Ø9@ñ%Añ B˜Cð ð CÝ œØ),¨¨¨g¨g¨g°t°t°t¸S¸Sð'Bñ Cô Cð CùñU+Cð	/	Cð /	Cr
   ztools.response_headers.headerszlog.access_filezlog.error_fileztools.log_headers.onz
log.screenzrequest.show_tracebackszrequest.throw_errorszDcherrypy.tree.mount(profiler.make_app(cherrypy.Application(Root()))))
zserver.default_content_typeÚlog_access_fileÚlog_config_optionsÚlog_fileÚlog_file_not_foundÚlog_request_headersÚlog_to_screenÚshow_tracebacksÚthrow_errorszprofiler.onc           
      óð  — |                      ¦   «         D ]à\  }}t          |t          ¦  «        ri|D ]e}|| j        v r)t	          j        |›d| j        |         ›d|›d�¦  «         Œ4|| j        v r(t	          j        |›d| j        |         ›d|›d�¦  «         ŒfŒƒ|| j        v r&t	          j        |›d| j        |         ›d�¦  «         Œ²|| j        v r%t	          j        |›d| j        |         ›d�¦  «         ŒádS )ú=Process config and warn on each obsolete or deprecated entry.z is obsolete. Use ú instead.
section: [rF   z is deprecated. Use z	 instead.N)r&   r'   ÚdictÚobsoleter   r.   Ú
deprecated)r   r)   r=   rR   Úks        r   Ú_compatzChecker._compatÁ   ss  € à#Ÿ\š\™^œ^ð 	Ið 	I‰MˆG�TÝ˜$¥Ñ%Ô%ð IØð Hð H�AØ˜DœMÐ)Ð)Ý œà'( q q¨$¬-¸Ô*:Ð*:Ð*:¸G¸G¸Gð'Eñ Fô Fð Fð Fð ˜dœoÐ-Ð-Ý œà'( q q¨$¬/¸!Ô*<Ð*<Ð*<¸g¸g¸gð'Gñ Hô Hð HøðHð ˜dœmÐ+Ð+Ý”MØ%, W W¨d¬m¸GÔ.DÐ.DÐ.Dð#Fñ Gô Gð Gð Gà ¤Ð/Ð/Ý”MØ%, W W¨d¬o¸gÔ.FÐ.FÐ.Fð#Hñ Iô Ið Iøð!	Ið 	Ir
   c                 ó   — |                       t          j        ¦  «         t          j        j                             ¦   «         D ]:\  }}t          |t          j        ¦  «        sŒ |                       |j        ¦  «         Œ;dS )r`   N)rf   r#   r)   r$   r%   r&   r'   r(   ©r   r/   r0   s      r   Úcheck_compatibilityzChecker.check_compatibilityÖ   ss   € à�Š•X”_Ñ%Ô%Ð%Ý”}Ô)×/Ò/Ñ1Ô1ð 	%ð 	%‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØ�LŠL˜œÑ$Ô$Ð$Ð$ð	%ð 	%r
   c           
      óˆ  — dg}|                      |j        ¦  «         |                      |j        ¦  «         |                      |j        j        ¦  «         |                      t          j        j        ¦  «         || j        z  }|j                             ¦   «         D �]"\  }}|                     d¦  «        }|�rt          |t          ¦  «        rï|D ]ì}|                     d¦  «        }t          |¦  «        dk    rÂ|d         |vre|d         dk    r2|d         |v r(d|›dd                     |dd …         ¦  «        ›d	|›d
�}nd|›d|d         ›d|›d
�}t          j        |¦  «         Œ™|d         dk    rG|d         t!          t          j        ¦  «        vr&d|›d|d         ›d|›d
�}t          j        |¦  «         Œí�Œ$d S )NÚwsgir!   ú.rJ   r   r#   zThe config entry z is invalid; try ra   rF   z is invalid, because the z( config namespace is unknown.
section: [Útoolsz may be invalid, because the z tool was not found.
section: [)ÚextendÚ	toolboxesÚ
namespacesÚrequest_classr#   r)   Úextra_config_namespacesr&   r   r'   rb   r+   r-   r;   r   r.   r   rm   )	r   r0   Únsr=   rR   Úis_path_sectionre   Úatomsr<   s	            r   Ú	_known_nszChecker._known_nsá   sô  € ØˆXˆØ
�	Š	�#”-Ñ Ô Ð Ø
�	Š	�#”.Ñ!Ô!Ð!Ø
�	Š	�#Ô#Ô.Ñ/Ô/Ð/Ø
�	Š	•(”/Ô,Ñ-Ô-Ð-Ø
ˆdÔ*Ñ*ˆà œZ×-Ò-Ñ/Ô/ð 	3ñ 	3‰MˆG�TØ%×0Ò0°Ñ5Ô5ˆOØñ 3¥:¨dµDÑ#9Ô#9ð 3Øð 3ð 3�AØŸGšG C™LœL�EÝ˜5‘z”z A’~�~Ø  œ8¨2Ð-Ð-ð  % Qœx¨:Ò5Ð5¸%À¼(Àb¸.¸.¸.ð () q q¨#¯(ª(°5¸¸¸´9Ñ*=Ô*=Ð*=Ð*=¸w¸w¸wð%Hð !$ øð 89°q°q¸%À¼(¸(¸(ÀGÀGÀGð%Mð !$õ
 %œM¨#Ñ.Ô.Ð.Ð.Ø" 1œX¨Ò0Ð0Ø$ Qœx­sµ8´>Ñ/BÔ/BÐBÐBÐBð 89°q°q¸%À¼(¸(¸(ÀGÀGÀGð%Mð !$õ !)¤¨cÑ 2Ô 2Ð 2øùð7	3ð 	3r
   c                 ó¸   — t           j        j                             ¦   «         D ]5\  }}t	          |t           j        ¦  «        sŒ |                      |¦  «         Œ6dS )z9Process config and warn on each unknown config namespace.N)r#   r$   r%   r&   r'   r(   rv   rh   s      r   Úcheck_config_namespaceszChecker.check_config_namespaces  s]   € å”}Ô)×/Ò/Ñ1Ô1ð 	 ð 	 ‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØ�NŠN˜3ÑÔÐÐð	 ð 	 r
   c                 óR  ‡ ‡— d„ t          t          ¦  «                             ¦   «         D ¦   «         Šˆˆ fd„} |t          j        d¦  «          |t          j        d¦  «          |t          j        d¦  «          |t          j        d¦  «          |t          j        d¦  «         d S )Nc                 óX   — g | ]'}t          |¦  «        t          t          ¦  «        u ¯%|‘Œ(S r   )ÚtypeÚstr)Ú.0Úxs     r   ú
<listcomp>z1Checker._populate_known_types.<locals>.<listcomp>  s8   € ð &ð &ð &�1Ý�Q‘”�4¥™9œ9Ð$Ð$ð Ø$Ð$Ð$r
   c                 óž   •— t          | ¦  «        D ];}|dk    rŒ	t          t          | |d ¦  «        ¦  «        }|‰v r|‰j        |dz   |z   <   Œ<d S )NÚbody_paramsrl   )r   r{   r   Úknown_config_types)ÚobjÚ	namespacer   ÚvtypeÚbr   s       €€r   Útraversez/Checker._populate_known_types.<locals>.traverse  sm   ø€ Ý˜C™œð Lð L�à˜=Ò(Ð(ØÝ�W S¨$°Ñ5Ô5Ñ6Ô6�Ø˜A�:�:ØFK�DÔ+¨I¸©O¸dÑ,BÑCøðLð Lr
   rL   ÚresponseÚserverÚengineÚlog)	ÚvarsÚbuiltinsÚvaluesr#   rL   rˆ   r‰   rŠ   r‹   )r   r‡   r†   s   ` @r   r   zChecker._populate_known_types  sÅ   øø€ ð&ð &��X™œ×-Ò-Ñ/Ô/ð &ñ &ô &ˆð	Lð 	Lð 	Lð 	Lð 	Lð 	Lð 	ˆ•Ô! 9Ñ-Ô-Ð-Øˆ•Ô" JÑ/Ô/Ð/Øˆ•” (Ñ+Ô+Ð+Øˆ•” (Ñ+Ô+Ð+Øˆ•”˜uÑ%Ô%Ð%Ð%Ð%r
   c           	      óV  — d}|                      ¦   «         D ]‘\  }}t          |t          ¦  «        s||i}|                      ¦   «         D ]^\  }}|�W| j                             |d ¦  «        }t          |¦  «        }|r+||k    r%t          j        ||||j        |j        fz  ¦  «         Œ_Œ’d S )Nz[The config entry %r in section %r is of type %r, which does not match the expected type %r.)	r&   r'   rb   r‚   rN   r{   r   r.   Ú__name__)	r   r)   r<   r=   rR   re   ÚvÚexpected_typer…   s	            r   Ú_known_typeszChecker._known_types#  sá   € ð<ˆð $Ÿ\š\™^œ^ð 		Fð 		F‰MˆG�TÝ˜d¥DÑ)Ô)ð 'Ø ��ØŸ
š
™œð Fð F‘��1Ø�=Ø$(Ô$;×$?Ò$?ÀÀ4Ñ$HÔ$H�MÝ  ™GœG�EØ$ð F¨°-Ò)?Ð)?Ý œ c¨Q°¸¼Ø-:Ô-Cð-Eñ 'Eñ Fô Fð FøðFð		Fð 		Fr
   c                 ó   — |                       t          j        ¦  «         t          j        j                             ¦   «         D ]:\  }}t          |t          j        ¦  «        sŒ |                       |j        ¦  «         Œ;dS )zAAssert that config values are of the same type as default values.N)r“   r#   r)   r$   r%   r&   r'   r(   rh   s      r   Úcheck_config_typeszChecker.check_config_types2  sw   € à×Ò�(œ/Ñ*Ô*Ð*Ý”}Ô)×/Ò/Ñ1Ô1ð 	*ð 	*‰GˆB�Ý˜c¥8Ô#7Ñ8Ô8ð ØØ×Ò˜cœjÑ)Ô)Ð)Ð)ð	*ð 	*r
   c                 óŽ   — t           j                             ¦   «         D ]%\  }}|dk    r|dk    rt          j        d¦  «         Œ&dS )zCWarn if any socket_host is 'localhost'.

        See #711.
        zserver.socket_hostÚ	localhostz»The use of 'localhost' as a socket host can cause problems on newer systems, since 'localhost' can map to either an IPv4 or an IPv6 address. You should use '127.0.0.1' or '[::1]' instead.N)r#   r)   r&   r   r.   )r   re   r‘   s      r   Úcheck_localhostzChecker.check_localhost;  s_   € õ
 ”O×)Ò)Ñ+Ô+ð 	5ð 	5‰DˆAˆqØÐ(Ò(Ð(¨Q°+Ò-=Ð-=Ý”ð 4ñ 5ô 5ð 5øð	5ð 	5r
   )N)r�   Ú
__module__Ú__qualname__Ú__doc__r   r	   r   r   rC   r4   rA   rD   rH   rV   rc   rd   rf   ri   rr   rv   rx   r‚   r   r“   r•   r˜   r   r
   r   r   r   	   s|  € € € € € ðð ð 
€BØOð%ð %ð %ð:ð :ð :ð5ð 5ð 5ð 5ð
 %*Ð!ðOð Oð Oð$4ð 4ð 4ð.ð ð ð Kð Kð Kð3Cð 3Cð 3Cðn (HØ,Ø"Ø$Ø"Ø5Ø%Ø4Ø.ð9ðð €Hð €JðIð Ið Ið*%ð %ð %ð !Ðð#3ð #3ð #3ðJ ð  ð  ð Ðð&ð &ð &ð&Fð Fð Fð*ð *ð *ð5ð 5ð 5ð 5ð 5r
   r   )r›   r9   r   r�   r#   Úobjectr   r   r
   r   ú<module>r�      sm   ðØ 2Ð 2Ø 	€	€	€	Ø €€€Ø €€€à €€€ð}5ð }5ð }5ð }5ð }5ˆfñ }5ô }5ð }5ð }5ð }5r
   