
    ^hW                     V    S SK r S SKrS SKJr  S r " S S\ R
                  5      rS rg)    N)chatdbg_configc                   ^ ^ [         R                  " 5       nT R                  mTc  T R                  R	                  SS5      m[        U U4S jU 5       5      (       a  T " U0 UD6$ [        ST R                   ST S35      e)zE
Check if the function is in the module whitelist before calling it.
N__name__c              3   p   >#    U  H+  n[         R                  " UT S TR                   35      v   M-     g7f).N)re	fullmatchr   ).0allowedfuncmodule_names     R/home/james-whalen/.local/lib/python3.13/site-packages/chatdbg/pdb_util/sandbox.py	<genexpr>"_sandboxed_call.<locals>.<genexpr>   s5      &G 	WQt}}o>??&s   36zCalling function z from module z is not allowed.)r   get_module_whitelist
__module____globals__getanyImportErrorr   )r   argskwargsallowed_modulesr   s   `   @r   _sandboxed_callr      s     %99;O //K&&**:t<  &   T$V$$mK=HXY
 	
    c                       \ rS rSrSrS rSrg)SandboxTransformer   zK
Wrap all function calls in the expression with a call to _sandboxed_call.
c                     [         R                  " [         R                  " S[         R                  " 5       S9UR                  /UR
                  -   UR                  S9n[         R                  " X!5      $ )Nr   )idctx)r   r   keywords)astCallNameLoadr   r   r"   copy_location)selfnodenew_nodes      r   
visit_CallSandboxTransformer.visit_Call$   sQ    88.CHHJ?))tyy(]]

   00r    N)r   r   __qualname____firstlineno____doc__r+   __static_attributes__r-   r   r   r   r      s    1r   r   c                     [         R                  " U SS9n[        5       R                  U5      n[         R                  " U5        [        USSS9nUR                  5       n[        US'   [        XAU5      $ )z
Wrap all function calls in the expression with a call to _sandboxed_call.
This function will raise an ImportError if the function is not in the module whitelist.
eval)modez<ast>)filenamer4   r   )	r#   parser   visitfix_missing_locationscompilecopyr   r3   )
expressionglobalslocalstreecodes        r   sandbox_evalr@   -   sf    
 99Zf-D%%d+Dd#4'7DllnG!0Gv&&r   )r#   r   chatdbg.util.configr   r   NodeTransformerr   r@   r-   r   r   <module>rC      s*    
 	 .
21,, 1'r   