
    Vh                     @    d dl Z d dlmZ d dlmZ d dlmZ i Zd Zd Z	y)    N)wraps)iscoroutinefunction)HttpRequestc                  `     t               dk(  rt         d         rt        d       fd}|S )a  
    Indicate which variables used in the decorated function are sensitive so
    that those variables can later be treated in a special way, for example
    by hiding them when logging unhandled exceptions.

    Accept two forms:

    * with specified variable names:

        @sensitive_variables('user', 'password', 'credit_card')
        def my_function(user):
            password = user.pass_word
            credit_card = user.credit_card_number
            ...

    * without any specified variable names, in which case consider all
      variables are sensitive:

        @sensitive_variables()
        def my_function()
            ...
       r   zzsensitive_variables() must be called to use it as a decorator, e.g., use @sensitive_variables(), not @sensitive_variables.c                     t               r  }t        |dd       |j                  }t        |dd       	 t        j                  |      }|j
                  j                  }t        | d|       }rt        |<   S dt        |<   S t                fd       S # t        $ r t         j                   d      w xY w)N__wrapped__:z cannot safely be wrapped by @sensitive_variables, make it either non-async or defined in a Python file (not a builtin or from a native extension).__ALL__c                  6    r_         nd_          | i |S )Nr   )sensitive_variables)	func_argsfunc_kwargsfuncsensitive_variables_wrapper	variabless     M/home/dcms/DCMS/lib/python3.12/site-packages/django/views/decorators/debug.pyr   zKsensitive_variables.<locals>.decorator.<locals>.sensitive_variables_wrapperE   s(    FO/CFO/CY6+66    )r   getattrr	   inspectgetfile__code__co_firstlinenohash	TypeError
ValueError__name__*coroutine_functions_to_sensitive_variablesr   )r   wrapped_func	file_pathfirst_line_numberkeyr   r   s   `    @r   	decoratorz&sensitive_variables.<locals>.decorator(   s    t$*.'L,t<H+77 ,t<H?#OOL9	 %1$9$9$H$H!i[*;)<=>BK:3? +* CL:3? +* 4[7 7 +*7   }}o &N N s   B% %"Clencallabler   )r   r#   s   ` r   r   r      s=    . 9~x	!5J
 	

%+N r   c                  `     t               dk(  rt         d         rt        d       fd}|S )a  
    Indicate which POST parameters used in the decorated view are sensitive,
    so that those parameters can later be treated in a special way, for example
    by hiding them when logging unhandled exceptions.

    Accept two forms:

    * with specified parameters:

        @sensitive_post_parameters('password', 'credit_card')
        def my_view(request):
            pw = request.POST['password']
            cc = request.POST['credit_card']
            ...

    * without any specified parameters, in which case consider all
      variables are sensitive:

        @sensitive_post_parameters()
        def my_view(request)
            ...
    r   r   zsensitive_post_parameters() must be called to use it as a decorator, e.g., use @sensitive_post_parameters(), not @sensitive_post_parameters.c                 t     t               rt                fd       }|S t                fd       }|S )Nc                    K   t        | t              st        d      r| _        nd| _         | g|i | d {   S 7 wNzsensitive_post_parameters didn't receive an HttpRequest object. If you are decorating a classmethod, make sure to use @method_decorator.r   
isinstancer   r   sensitive_post_parametersrequestargskwargs
parametersviews      r   !sensitive_post_parameters_wrapperzWsensitive_post_parameters.<locals>.decorator.<locals>.sensitive_post_parameters_wrappers   sS     !';7#- 
 8BG58AG5!';D;F;;;;s   <AA Ac                 t    t        | t              st        d      r| _        nd| _         | g|i |S r*   r+   r.   s      r   r4   zWsensitive_post_parameters.<locals>.decorator.<locals>.sensitive_post_parameters_wrapper   sI    !';7#- 
 8BG58AG5G5d5f55r   )r   r   )r3   r4   r2   s   ` r   r#   z,sensitive_post_parameters.<locals>.decoratorp   sI    t$4[< <: 10 4[6 6 10r   r$   )r2   r#   s   ` r   r-   r-   R   s<    . :!A 7*
 	
!1F r   )
r   	functoolsr   asgiref.syncr   django.httpr   r   r   r-    r   r   <module>r:      s$      , #-/ *DNAr   