HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/__pycache__/_cpchecker.cpython-310.pyc
o

�N�g�8�@s8dZddlZddlZddlZddlZGdd�de�ZdS)z,Checker for CherryPy sites and mounted apps.�Nc@s�eZdZdZdZ	dd�Zdd�Zd.dd	�Zd
Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
ddddddddddd�
ZiZdd�Zd d!�ZgZd"d#�Zd$d%�ZiZd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/�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.
    TcCs|��dS)zInitialize Checker instance.N)�_populate_known_types)�self�r�G/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/_cpchecker.py�__init__szChecker.__init__cCsd|jr0tj}|jt_z!t|�D]}|�d�r%t||�}|r%t|d�r%|�qW|t_dS|t_wdS)zRun all check_* methods.Zcheck_�__call__N)�on�warnings�
formatwarning�dir�
startswith�getattr�hasattr)rZoldformatwarning�name�methodrrrrs

���zChecker.__call__NcCsd|S)zFormat a warning.zCherryPy Checker:
%s

r)r�message�category�filename�lineno�linerrrr,szChecker.formatwarningFcCs�tjj��D]?\}}t|tj�sq|jsq|dkrq|�d��d�}|j�	�D]}|�d��d�}|dt
|��|krDt�d||f�q'qdS)z;Check for App config with sections that repeat script_name.��/NzTThe application mounted at %r has config entries that start with its script name: %r)
�cherrypy�tree�apps�items�
isinstance�Application�config�strip�split�keys�lenr
�warn)r�sn�appZsn_atoms�keyZ	key_atomsrrr�4check_app_config_entries_dont_start_with_script_name3s*������z<Checker.check_app_config_entries_dont_start_with_script_namec	
Cs�tjj��D]L\}}t|tj�sqg}|j��D]&\}}|�d�r>|��D]\}}dD]}|�|�r<|�d|||f�q+q%q|rR|�	dd|�t
�tj
�|��qdS)z<Check for mounted Applications that have site-scoped config.r)zengine.zserver.ztree.zchecker.z[%s] %s = %srz�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)rrrrrrrr
�append�insertr
r$�os�linesep�join)	rr%r&�msg�section�entriesr'�value�nrrr�'check_site_config_entries_in_app_configEs0

��������z/Checker.check_site_config_entries_in_app_configcCsTtjj��D]!\}}t|tj�sq|js'd|}|jr|d7}t�	|�dSqdS)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)
rrrrrrr�global_config_contained_pathsr
r$)rr%r&r.rrr�check_skipped_app_config\s
��z Checker.check_skipped_app_configcCsftjj��D]*\}}t|tj�sq|jsq|j��D]}|�d�s&|�	d�r/t
�d||f�qqdS)z?Check for App config with extraneous brackets in section names.�[�]z�The application mounted at %r has config section names with extraneous brackets: %r. Config *files* need brackets; config *dicts* (e.g. passed to tree.mount) do not.N)rrrrrrrr"r
�endswithr
r$)rr%r&r'rrr�check_app_config_bracketsls�����z!Checker.check_app_config_bracketsc	Cs@tj}tjj��D]�\}}t|tj�sq	||_|jD]�}|�	|d�|jj
}|dd�r�d}|d�}|d�}|dur=d}nRd}	tj�
|�rd|}	|rcd	}tj�||d
d��}
tj�|
�rc|d|
f7}n|sid}ntj�||�}	tj�
|	�s{d
|	f}|	r�tj�|	�s�|r�|d7}|d|	7}|r�t�d||||f�qq	dS)z4Check Application config for incorrect static paths.z/dummy.htmlztools.staticdir.onFrztools.staticdir.rootztools.staticdir.dirNztools.staticdir.dir is not set.z8dir is an absolute path, even though a root is provided.�zV
If you meant to serve the filesystem folder at %r, remove the leading slash from dir.z,dir is a relative path and no root provided.z%r is not an absolute path.�
z3%r (root + dir) is not an existing filesystem path.z!%s
section: [%s]
root: %r
dir: %r)r�requestrrrrrr&rZget_resource�getr+�path�isabsr-�existsr
r$)rr<r%r&r/�confr.�rootrZfulldirZtestdirrrr�check_static_paths{s`

������
����zChecker.check_static_pathsztools.response_headers.headerszlog.access_filezlog.error_fileztools.log_headers.onz
log.screenzrequest.show_tracebackszrequest.throw_errorszDcherrypy.tree.mount(profiler.make_app(cherrypy.Application(Root()))))
zserver.default_content_typeZlog_access_fileZlog_config_optionsZlog_fileZlog_file_not_foundZlog_request_headersZ
log_to_screenZshow_tracebacksZthrow_errorszprofiler.oncCs�|��D]W\}}t|t�r8|D]'}||jvr$t�d||j||f�q||jvr6t�d||j||f�qq||jvrJt�d||j|f�q||jvr[t�d||j|f�qdS)�=Process config and warn on each obsolete or deprecated entry.z-%r is obsolete. Use %r instead.
section: [%s]z/%r is deprecated. Use %r instead.
section: [%s]z%r is obsolete. Use %r instead.z!%r is deprecated. Use %r instead.N)rr�dict�obsoleter
r$�
deprecated)rrr/rA�krrr�_compat�s.

�
���

�
���zChecker._compatcC�@|�tj�tjj��D]\}}t|tj�sq|�|j�qdS)rDN)rIrrrrrrr�rr%r&rrr�check_compatibility���zChecker.check_compatibilityc		Cs.dg}|�|j�|�|j�|�|jj�|�tjj�||j7}|j��D]m\}}|�d�}|r�t	|t
�r�|D]Z}|�d�}t|�dkr�|d|vrv|ddkrg|d|vrgd|d�
|dd��|f}n	d||d|f}t�|�q9|dd	kr�|dttj�vr�d
||d|f}t�|�q9q'dS)NZwsgir�.r:rrz=The config entry %r is invalid; try %r instead.
section: [%s]zYThe config entry %r is invalid, because the %r config namespace is unknown.
section: [%s]�toolszTThe config entry %r may be invalid, because the %r tool was not found.
section: [%s])�extendZ	toolboxesZ
namespacesZ
request_classrr�extra_config_namespacesrr
rrEr!r#r-r
r$rrO)	rr&�nsr/rAZis_path_sectionrHZatomsr.rrr�	_known_ns�s@


������
��zChecker._known_nscCs2tjj��D]\}}t|tj�sq|�|�qdS)z9Process config and warn on each unknown config namespace.N)rrrrrrrSrKrrr�check_config_namespacess
�zChecker.check_config_namespacescsddd�tt���D����fdd�}|tjd�|tjd�|tjd�|tjd�|tjd	�dS)
NcSs g|]}t|�tt�ur|�qSr)�type�str)�.0�xrrr�
<listcomp>s�z1Checker._populate_known_types.<locals>.<listcomp>csFt|�D]}|dkrqtt||d��}|�vr |�j|d|<qdS)NZbody_paramsrN)rrUr�known_config_types)�obj�	namespacer�vtype��brrr�traverses��z/Checker._populate_known_types.<locals>.traverser<�response�server�engine�log)	�vars�builtins�valuesrr<rarbrcrd)rr`rr^rrs	zChecker._populate_known_typesc		Cs�d}|��D]8\}}t|t�s||i}|��D]&\}}|dur=|j�|d�}t|�}|r=||kr=t�||||j|jf�qqdS)Nz[The config entry %r in section %r is of type %r, which does not match the expected type %r.)	rrrErZr=rUr
r$�__name__)	rrr.r/rArH�vZ
expected_typer]rrr�_known_types#s
����zChecker._known_typescCrJ)zAAssert that config values are of the same type as default values.N)rjrrrrrrrrKrrr�check_config_types2rMzChecker.check_config_typescCs2tj��D]\}}|dkr|dkrt�d�qdS)z1Warn if any socket_host is 'localhost'. See #711.zserver.socket_hostZ	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)rrrr
r$)rrHrirrr�check_localhost;s

��zChecker.check_localhost)N)rh�
__module__�__qualname__�__doc__r	rrrr4r(r3r5r9rCrFrGrIrLrQrSrTrZrrjrkrlrrrrr	sF

7�	%	r)ror+r
rfr�objectrrrrr�<module>s