ó
Xé?_c           @   sZ   d  d l  Z  d  d l Z d  d l Z d  d l m Z m Z m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t	   iteritemst   copykeyst   builtinst   Checkerc           B   s  e  Z d  Z e Z d „  Z d „  Z d# d „ Z e	 Z
 d „  Z d „  Z d „  Z d „  Z d „  Z i
 d	 d
 6d d 6d# d 6d d 6d# d 6d d 6d d 6d d 6d d 6d d 6Z i  Z d „  Z d „  Z g  Z d „  Z d „  Z i  Z d „  Z d  „  Z d! „  Z d" „  Z RS($   sÕ  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.
    c         C   s   |  j  ƒ  d  S(   N(   t   _populate_known_types(   t   self(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   __init__   s    c         C   s   |  j  r‰ t j } |  j t _ z[ xT t |  ƒ D]F } | j d ƒ r. t |  | ƒ } | rt t | d ƒ rt | ƒ  qt q. q. WWd | t _ Xn  d S(   s   Run all check_* methods.t   check_t   __call__N(   t   ont   warningst   formatwarningt   dirt
   startswitht   getattrt   hasattr(   R   t   oldformatwarningt   namet   method(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyR      s    		c         C   s   d | S(   s   Function to format a warning.s   CherryPy Checker:
%s

(    (   R   t   messaget   categoryt   filenamet   linenot   line(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyR   +   s    c         C   sÚ   xÓ t  j j j ƒ  D]¿ \ } } t | t  j ƒ s7 q n  | j sF q n  | d k rX q n  | j d ƒ j d ƒ } x_ | j j	 ƒ  D]N } | j d ƒ j d ƒ } | t
 | ƒ  | k r€ t j d | | f ƒ q€ q€ Wq Wd S(   sL   Check for Application config with sections that repeat script_name.
        t    t   /sT   The application mounted at %r has config entries that start with its script name: %rN(   t   cherrypyt   treet   appst   itemst
   isinstancet   Applicationt   configt   stript   splitt   keyst   lenR
   t   warn(   R   t   snt   appt   sn_atomst   keyt	   key_atoms(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt4   check_app_config_entries_dont_start_with_script_name2   s    	c   	   	   C   s  x t  t j j ƒ D]ì \ } } t | t j ƒ s7 q n  g  } x‰ t  | j ƒ D]x \ } } | j d ƒ rM xZ t  | ƒ D]I \ } } x: d
 D]2 } | j | ƒ rˆ | j d | | | f ƒ qˆ qˆ Wqu WqM qM W| r | j	 d d | ƒ t
 j t j j | ƒ ƒ q q Wd	 S(   s<   Check for mounted Applications that have site-scoped config.R   s   engine.s   server.s   tree.s   checker.s   [%s] %s = %si    sÓ   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(   s   engine.s   server.s   tree.s   checker.(   R    R   R   R   R   R   R    R   t   appendt   insertR
   R%   t   ost   linesept   join(	   R   R&   R'   t   msgt   sectiont   entriesR)   t   valuet   n(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt'   check_site_config_entries_in_app_configE   s     	#	c         C   sy   xr t  j j j ƒ  D]^ \ } } t | t  j ƒ s7 q n  | j s d | } |  j r` | d 7} n  t j	 | ƒ d Sq Wd S(   s3   Check for mounted Applications that have no config.s2   The Application mounted at %r has an empty config.sÄ    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    t   global_config_contained_pathsR
   R%   (   R   R&   R'   R1   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_skipped_app_config\   s    	
	c         C   s    x™ t  j j j ƒ  D]… \ } } t | t  j ƒ s7 q n  | j sF q n  xO | j j ƒ  D]> } | j d ƒ sz | j	 d ƒ rV t
 j d | | f ƒ qV qV Wq Wd S(   sX   Check for Application config with extraneous brackets in section
        names.
        t   [t   ]s¥   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(   R   R   R   R   R   R   R    R#   R   t   endswithR
   R%   (   R   R&   R'   R)   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_app_config_bracketsl   s    	c         C   sß  t  j } xÏt  j j j ƒ  D]»\ } } t | t  j ƒ s@ q n  | | _ x‹| j D]€} | j	 | d ƒ | j j
 } | d t ƒ rS d } | d ƒ } | d ƒ } | d k r¸ d } nò d }	 t j j | ƒ r'| }	 | rmd } t j j | | d ƒ }
 t j j |
 ƒ r$| d	 |
 f 7} q$qmnF | s6d
 } n7 t j j | | ƒ }	 t j j |	 ƒ smd |	 f } n  |	 rªt j j |	 ƒ rª| r™| d 7} n  | d |	 7} n  | rÓt j d | | | | f ƒ qÓqS qS Wq Wd S(   s4   Check Application config for incorrect static paths.s   /dummy.htmls   tools.staticdir.onR   s   tools.staticdir.roots   tools.staticdir.dirs   tools.staticdir.dir is not set.s8   dir is an absolute path, even though a root is provided.i   sV   
If you meant to serve the filesystem folder at %r, remove the leading slash from dir.s,   dir is a relative path and no root provided.s   %r is not an absolute path.s   
s3   %r (root + dir) is not an existing filesystem path.s!   %s
section: [%s]
root: %r
dir: %rN(   R   t   requestR   R   R   R   R   R'   R    t   get_resourcet   gett   Falset   NoneR.   t   patht   isabsR0   t   existsR
   R%   (   R   R=   R&   R'   R2   t   confR1   t   rootR   t   fulldirt   testdir(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_static_paths}   sL    					s   tools.response_headers.headerss   server.default_content_types   log.access_filet   log_access_filet   log_config_optionss   log.error_filet   log_filet   log_file_not_founds   tools.log_headers.ont   log_request_headerss
   log.screent   log_to_screens   request.show_tracebackst   show_tracebackss   request.throw_errorst   throw_errorssD   cherrypy.tree.mount(profiler.make_app(cherrypy.Application(Root())))s   profiler.onc         C   s  x| j  ƒ  D]\ } } t | t ƒ r® xã | j  ƒ  D]r \ } } | |  j k rt t j d | |  j | | f ƒ q5 | |  j k r5 t j d | |  j | | f ƒ q5 q5 Wq | |  j k rÞ t j d | |  j | f ƒ q | |  j k r t j d | |  j | f ƒ q q Wd S(   s=   Process config and warn on each obsolete or deprecated entry.s-   %r is obsolete. Use %r instead.
section: [%s]s/   %r is deprecated. Use %r instead.
section: [%s]s   %r is obsolete. Use %r instead.s!   %r is deprecated. Use %r instead.N(   R   R   t   dictt   obsoleteR
   R%   t
   deprecated(   R   R    R2   RE   t   kt   v(    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   _compatÃ   s    		"		c         C   s_   |  j  t j ƒ xH t j j j ƒ  D]4 \ } } t | t j ƒ sG q# n  |  j  | j ƒ q# Wd S(   s=   Process config and warn on each obsolete or deprecated entry.N(   RW   R   R    R   R   R   R   R   (   R   R&   R'   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_compatibilityØ   s
    c   
      C   sÍ  d g } | j  t | j ƒ ƒ | j  t | j ƒ ƒ | j  t | j j ƒ ƒ | j  t t j j ƒ ƒ | |  j 7} xR| j j ƒ  D]A\ } } | j	 d ƒ } | r„ t
 | t ƒ r„ x| j ƒ  D]ý \ } } | j d ƒ } t | ƒ d k rÁ | d | k rh| d d k rA| d | k rAd | d j | d ƒ | f }	 n d | | d | f }	 t j |	 ƒ q¾| d d	 k r¾| d t t j ƒ k r»d
 | | d | f }	 t j |	 ƒ q»q¾qÁ qÁ Wq„ q„ Wd  S(   Nt   wsgiR   t   .i   i    R   s=   The config entry %r is invalid; try %r instead.
section: [%s]sY   The config entry %r is invalid, because the %r config namespace is unknown.
section: [%s]t   toolssT   The config entry %r may be invalid, because the %r tool was not found.
section: [%s](   t   extendR   t	   toolboxest
   namespacest   request_classR   R    t   extra_config_namespacesR   R   R   RR   R"   R$   R0   R
   R%   R   R[   (
   R   R'   t   nsR2   RE   t   is_path_sectionRU   RV   t   atomsR1   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt	   _known_nsã   s0    	  c         C   sL   xE t  j j j ƒ  D]1 \ } } t | t  j ƒ s7 q n  |  j | ƒ q Wd S(   s9   Process config and warn on each unknown config namespace.N(   R   R   R   R   R   R   Rd   (   R   R&   R'   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_config_namespaces  s    c            s£   g  t  t ƒ j ƒ  D]$ } t | ƒ t t ƒ k r | ^ q ‰  ‡  ‡ f d †  } | t j d ƒ | t j d ƒ | t j d ƒ | t j	 d ƒ | t j
 d ƒ d  S(   Nc            si   xb t  |  ƒ D]T } | d k r% q n  t t |  | d  ƒ ƒ } | ˆ  k r | ˆ j | d | <q q Wd  S(   Nt   body_paramsRZ   (   R   t   typeR   RA   t   known_config_types(   t   objt	   namespaceR   t   vtype(   t   bR   (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   traverse  s    R=   t   responset   servert   enginet   log(   t   varsR   t   valuesRg   t   strR   R=   Rn   Ro   Rp   Rq   (   R   t   xRm   (    (   Rl   R   sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyR     s    $	c   	      C   s3  d } x&| j  ƒ  D]\ } } t | t ƒ r¶ xú | j  ƒ  D]t \ } } | d  k	 r; |  j j | d  ƒ } t | ƒ } | r¯ | | k r¯ t j | | | | j	 | j	 f ƒ q¯ q; q; Wq | | } } | d  k	 r |  j j | d  ƒ } t | ƒ } | r+| | k r+t j | | | | j	 | j	 f ƒ q+q q Wd  S(   Ns[   The config entry %r in section %r is of type %r, which does not match the expected type %r.(
   R   R   RR   RA   Rh   R?   Rg   R
   R%   t   __name__(	   R   R    R1   R2   RE   RU   RV   t   expected_typeRk   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   _known_types%  s"    c         C   s_   |  j  t j ƒ xH t j j j ƒ  D]4 \ } } t | t j ƒ sG q# n  |  j  | j ƒ q# Wd S(   sA   Assert that config values are of the same type as default values.N(   Rx   R   R    R   R   R   R   R   (   R   R&   R'   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_config_types;  s
    c         C   sL   xE t  j j ƒ  D]4 \ } } | d k r | d k r t j d ƒ q q Wd S(   s1   Warn if any socket_host is 'localhost'. See #711.s   server.socket_hostt	   localhosts»   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   RU   RV   (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   check_localhostD  s    N(   Rv   t
   __module__t   __doc__t   TrueR	   R   R   RA   R   R@   R7   R+   R6   R8   R<   RI   RS   RT   RW   RX   R`   Rd   Re   Rh   R   Rx   Ry   R{   (    (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyR      sB   							6
				%					(	   R.   R
   R   t   cherrypy._cpcompatR    R   R   t   objectR   (    (    (    sz   /local/mnt/workspace/CRMBuilds/Saipan.LA.2.0-00145-STD.PROD-1_20200821_083004/b/common/sectools/ext/cherrypy/_cpchecker.pyt   <module>   s   