
    >/iS                         S SK r S SKrS SKJr  S SKJr  S r\R                  " S5      \R                  " S5      S 5       5       r	\R                  " S5      \R                  " S5      S	 5       5       r
g)
    N)issue)test_propertiesc                     0 nU  H<  n[        U[        R                  5      (       d  M$  UR                  XR                  '   M>     U$ )N)
isinstanceastkeywordvaluearg)keywordskwargsnodes      ]/home/james-whalen/.local/lib/python3.13/site-packages/bandit/plugins/django_sql_injection.pykeywords2dictr      s9    FdCKK((#zzF88  M    CallB610c                 L   SnU R                   S:X  Ga  [        U R                  R                  5      nU R                  R                  nU(       a  [        U5      S:  a  US   US'   [        U5      S:  a  US   US'   [        U5      S:  a  US   US	'   [        U5      S
:  a  US   US'   [        U5      S:  a  US
   US'   [        U5      S:  a  US   US'   SnS H  nXR;   d  M
  [        X%   [        R                  5      (       aZ  X%   R                   HF  n[        U[        R                  5      (       a!  [        UR                  [        5      (       a  MC  Sn  M     M  Sn  O   U(       d  SU;   a  [        US   [        R                  5      (       a  US   R                   HE  n[        U[        R                  5      (       a!  [        UR                  [        5      (       a  MC  Sn  O   U(       dX  US   R                   HE  n[        U[        R                  5      (       a!  [        UR                  [        5      (       a  MC  Sn  O   OSnU(       aK  [         R"                  " [         R$                  [         R$                  [&        R(                  R*                  US9$ gg)a%  **B610: Potential SQL injection on extra function**

:Example:

.. code-block:: none

    >> Issue: [B610:django_extra_used] Use of extra potential SQL attack vector.
       Severity: Medium Confidence: Medium
       CWE: CWE-89 (https://cwe.mitre.org/data/definitions/89.html)
       Location: examples/django_sql_injection_extra.py:29:0
       More Info: https://bandit.readthedocs.io/en/latest/plugins/b610_django_extra_used.html
    28  tables_str = 'django_content_type" WHERE "auth_user"."username"="admin'
    29  User.objects.all().extra(tables=[tables_str]).distinct()

.. seealso::

 - https://docs.djangoproject.com/en/dev/topics/security/#sql-injection-protection
 - https://cwe.mitre.org/data/definitions/89.html

.. versionadded:: 1.5.0

.. versionchanged:: 1.7.3
    CWE information added

z)Use of extra potential SQL attack vector.extra   r   select   where   params   tables   order_by   select_paramsF)r   r   Tseverity
confidencecwetextN)call_function_namer   r   r   argslenr   r   ListeltsConstantr	   strDictkeysvaluesbanditIssueMEDIUMr   CweSQL_INJECTION)	contextdescriptionr   r'   insecurekeyvalkvs	            r   django_extra_usedr<      s)   : >K!!W,w||445||  4yA~#'7x 4yA~"&q'w4yA~#'7x 4yA~#'7x 4yA~%)!Wz"4yA~*.q''&C}fk38844%{//&sCLL99 *399c : :'+H!  0  $H ' H.&*CHH55)..A"1cll33&qww44#' /  #H-44&q#,,77 *177C 8 8'+H! 5  <<!==II++ 	  e -r   B611c                    SnU R                  S5      (       a  U R                  S:X  a  U R                  R                  (       a  U R                  R                  S   nO$[	        U R                  R
                  5      nUS   n[        U[        R                  5      (       a  [        UR                  [        5      (       dK  [        R                  " [        R                  [        R                  [        R                  R                   US9$ ggg)a   **B611: Potential SQL injection on RawSQL function**

:Example:

.. code-block:: none

    >> Issue: [B611:django_rawsql_used] Use of RawSQL potential SQL attack vector.
       Severity: Medium Confidence: Medium
       CWE: CWE-89 (https://cwe.mitre.org/data/definitions/89.html)
       Location: examples/django_sql_injection_raw.py:11:26
       More Info: https://bandit.readthedocs.io/en/latest/plugins/b611_django_rawsql_used.html
    10        ' WHERE "username"="admin" OR 1=%s --'
    11  User.objects.annotate(val=RawSQL(raw, [0]))

.. seealso::

 - https://docs.djangoproject.com/en/dev/topics/security/#sql-injection-protection
 - https://cwe.mitre.org/data/definitions/89.html

.. versionadded:: 1.5.0

.. versionchanged:: 1.7.3
    CWE information added

z*Use of RawSQL potential SQL attack vector.zdjango.db.modelsRawSQLr   sqlr!   N)is_module_imported_liker&   r   r'   r   r   r   r   r+   r	   r,   r0   r1   r2   r   r3   r4   )r5   r6   r@   r   s       r   django_rawsql_usedrB   m   s    : ?K&&'9::%%1||  ll''*&w||'<'<=Um 3--*SYY2L2L||#]]%}}		//$	  3M 2 ;r   )r   r0   bandit.corer   r   testr   checkstest_idr<   rB    r   r   <module>rH      sw   
    / VfT  Tn Vf,  ,r   