
    >/iZ                         S SK r S SKrS SKrS SKJr  S SKJr  Sr\R                  " SR                  \5      \R                  5      rS r\R                  " S5      \R                  " S5      S	 5       5       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_propertiesz-(pas+wo?r?d|pass(phrase)?|pwd|token|secrete?)z(^{0}$|_{0}_|^{0}_|_{0}$)c                     [         R                  " [         R                  [         R                  [        R
                  R                  SU  S3S9$ )NzPossible hardcoded password: '')severity
confidencecwetext)banditIssueLOWMEDIUMr   CweHARD_CODED_PASSWORD)values    c/home/james-whalen/.local/lib/python3.13/site-packages/bandit/plugins/general_hardcoded_password.py_reportr      s:    <<==II))-eWA6	     StrB105c                 	   U R                   n[        UR                  [        R                  5      (       a  UR                  R
                   H  n[        U[        R                  5      (       a;  [        R                  UR                  5      (       a  [        UR                  5      s  $ [        U[        R                  5      (       d  M~  [        R                  UR                  5      (       d  M  [        UR                  5      s  $    g[        UR                  [        R                  5      (       a  [        R                  UR                  5      (       a  UR                  R                  n[        U[        R                  5      (       as  [        UR                  [        R                  5      (       aI  [        UR                  R                  [         5      (       a  [        UR                  R                  5      $ ggg[        UR                  [        R"                  5      (       a  [        R                  UR                  5      (       a  UR                  R                  R                  n[        U[        R                  5      (       as  [        UR                  [        R                  5      (       aI  [        UR                  R                  [         5      (       a  [        UR                  R                  5      $ ggg[        UR                  [        R$                  5      (       Ga  UR                  n[        UR&                  [        R                  5      (       a  [        R                  UR&                  R                  5      (       a|  [        UR(                  S   [        R                  5      (       aO  [        UR(                  S   R                  [         5      (       a"  [        UR(                  S   R                  5      $ ggg[        UR&                  [        R                  5      (       a  [        R                  UR&                  R                  5      (       a|  [        UR(                  S   [        R                  5      (       aO  [        UR(                  S   R                  [         5      (       a"  [        UR(                  S   R                  5      $ ggggg)a  **B105: Test for use of hard-coded password strings**

The use of hard-coded passwords increases the possibility of password
guessing tremendously. This plugin test looks for all string literals and
checks the following conditions:

- assigned to a variable that looks like a password
- assigned to a dict key that looks like a password
- assigned to a class attribute that looks like a password
- used in a comparison with a variable that looks like a password

Variables are considered to look like a password if they have match any one
of:

- "password"
- "pass"
- "passwd"
- "pwd"
- "secret"
- "token"
- "secrete"

Note: this can be noisy and may generate false positives.

**Config Options:**

None

:Example:

.. code-block:: none

    >> Issue: Possible hardcoded password '(root)'
       Severity: Low   Confidence: Low
       CWE: CWE-259 (https://cwe.mitre.org/data/definitions/259.html)
       Location: ./examples/hardcoded-passwords.py:5
    4 def someFunction2(password):
    5     if password == "root":
    6         print("OK, logged in")

.. seealso::

    - https://www.owasp.org/index.php/Use_of_hard-coded_password
    - https://cwe.mitre.org/data/definitions/259.html

.. versionadded:: 0.9.0

.. versionchanged:: 1.7.3
    CWE information added

r   N)node
isinstance_bandit_parentastAssigntargetsNameRE_CANDIDATESsearchidr   r   	Attributeattr	SubscriptConstantstrIndexCompareleftcomparators)contextr   targassigncomps        r   hardcoded_password_stringr/      s_   l <<D$%%szz22''//D$))m.B.B477.K.Ktzz**D#--00]5I5I		6 6 tzz** 0 
S]]
 



tzz
*
* $$33vszz**6<<666<<--s336<<--.. 4 7 + 
D''	3	38L8L

9 9
 $$33BBvszz**6<<666<<--s336<<--.. 4 7 + 
D''	5	5""dii**##DIILL11$$Q'  !1!1!!4!:!:C@@"4#3#3A#6#<#<== A 2
 		3==11##DIINN33$$Q'  !1!1!!4!:!:C@@"4#3#3A#6#<#<== A 4 2 
6r   CallB106c                 t   U R                   R                   H  n[        UR                  [        R
                  5      (       d  M.  [        UR                  R                  [        5      (       d  MY  [        R                  UR                  5      (       d  M  [        UR                  R                  5      s  $    g)ad  **B106: Test for use of hard-coded password function arguments**

The use of hard-coded passwords increases the possibility of password
guessing tremendously. This plugin test looks for all function calls being
passed a keyword argument that is a string literal. It checks that the
assigned local variable does not look like a password.

Variables are considered to look like a password if they have match any one
of:

- "password"
- "pass"
- "passwd"
- "pwd"
- "secret"
- "token"
- "secrete"

Note: this can be noisy and may generate false positives.

**Config Options:**

None

:Example:

.. code-block:: none

    >> Issue: [B106:hardcoded_password_funcarg] Possible hardcoded
    password: 'blerg'
       Severity: Low   Confidence: Medium
       CWE: CWE-259 (https://cwe.mitre.org/data/definitions/259.html)
       Location: ./examples/hardcoded-passwords.py:16
    15
    16    doLogin(password="blerg")

.. seealso::

    - https://www.owasp.org/index.php/Use_of_hard-coded_password
    - https://cwe.mitre.org/data/definitions/259.html

.. versionadded:: 0.9.0

.. versionchanged:: 1.7.3
    CWE information added

N)r   keywordsr   r   r   r%   r&   r   r    argr   )r+   kws     r   hardcoded_password_funcargr6      sk    f ll##rxx..288>>3//$$RVV,,288>>** $r   FunctionDefB107c                 4   S/[        U R                  R                  R                  5      [        U R                  R                  R                  5      -
  -  nUR	                  U R                  R                  R                  5        [        U R                  R                  R                  U5       H  u  p#[        U[        R                  [        R                  45      (       d  M6  Ub,  [        U[        R                  5      (       a  UR                  c  Mg  [        U[        R                  5      (       d  M  [        UR                  [        5      (       d  M  [        R                  UR                  5      (       d  M  [        UR                  5      s  $    g)a  **B107: Test for use of hard-coded password argument defaults**

The use of hard-coded passwords increases the possibility of password
guessing tremendously. This plugin test looks for all function definitions
that specify a default string literal for some argument. It checks that
the argument does not look like a password.

Variables are considered to look like a password if they have match any one
of:

- "password"
- "pass"
- "passwd"
- "pwd"
- "secret"
- "token"
- "secrete"

Note: this can be noisy and may generate false positives.  We do not
report on None values which can be legitimately used as a default value,
when initializing a function or class.

**Config Options:**

None

:Example:

.. code-block:: none

    >> Issue: [B107:hardcoded_password_default] Possible hardcoded
    password: 'Admin'
       Severity: Low   Confidence: Medium
       CWE: CWE-259 (https://cwe.mitre.org/data/definitions/259.html)
       Location: ./examples/hardcoded-passwords.py:1

    1    def someFunction(user, password="Admin"):
    2      print("Hi " + user)

.. seealso::

    - https://www.owasp.org/index.php/Use_of_hard-coded_password
    - https://cwe.mitre.org/data/definitions/259.html

.. versionadded:: 0.9.0

.. versionchanged:: 1.7.3
    CWE information added

N)lenr   argsdefaultsextendzipr   r   r   r4   r%   r   r&   r   r    r   )r+   defskeyvals       r   hardcoded_password_defaultrB      s   p 6GLL""#c',,*;*;*D*D&EED 	KK!!**+ ))..5cCHHcgg.//{3--#))2C3--syy#..!((11syy)) 6r   )r   rer   bandit.corer   r   testRE_WORDScompileformat
IGNORECASEr   r   checkstest_idr/   r6   rB    r   r   <module>rM      s   
  	   /:

&&x0"--
 Ufg>  g>T Vf7+  7+t ]fH*  H*r   