
    >/i                         S r SSKrSSKJr  SSKJr  S r\R                  \R                  " S5      \R                  " S5      S 5       5       5       r
g)	a_  
===================================================
B108: Test for insecure usage of tmp file/directory
===================================================

Safely creating a temporary file or directory means following a number of rules
(see the references for more details). This plugin test looks for strings
starting with (configurable) commonly used temporary paths, for example:

 - /tmp
 - /var/tmp
 - /dev/shm

**Config Options:**

This test plugin takes a similarly named config block,
`hardcoded_tmp_directory`. The config block provides a Python list, `tmp_dirs`,
that lists string fragments indicating possible temporary file paths. Any
string starting with one of these fragments will report a MEDIUM confidence
issue.

.. code-block:: yaml

    hardcoded_tmp_directory:
        tmp_dirs: ['/tmp', '/var/tmp', '/dev/shm']


:Example:

.. code-block: none

    >> Issue: Probable insecure usage of temp file/directory.
       Severity: Medium   Confidence: Medium
       CWE: CWE-377 (https://cwe.mitre.org/data/definitions/377.html)
       Location: ./examples/hardcoded-tmp.py:1
    1 f = open('/tmp/abc', 'w')
    2 f.write('def')

.. seealso::

 - https://security.openstack.org/guidelines/dg_using-temporary-files-securely.html
 - https://cwe.mitre.org/data/definitions/377.html

.. versionadded:: 0.9.0

.. versionchanged:: 1.7.3
    CWE information added

    N)issue)test_propertiesc                     U S:X  a  S/ SQ0$ g )Nhardcoded_tmp_directorytmp_dirsz/tmpz/var/tmpz/dev/shm )names    ^/home/james-whalen/.local/lib/python3.13/site-packages/bandit/plugins/general_hardcoded_tmp.py
gen_configr   ;   s    ((<== )    StrB108c                    ^  Ub  SU;   a  US   nO/ SQn[        U 4S jU 5       5      (       aK  [        R                  " [        R                  [        R                  [        R
                  R                  SS9$ g )Nr   r   c              3   Z   >#    U  H   nTR                   R                  U5      v   M"     g 7f)N)
string_val
startswith).0scontexts     r   	<genexpr>*hardcoded_tmp_directory.<locals>.<genexpr>I   s%     
>X7((++Xs   (+z/Probable insecure usage of temp file/directory.)severity
confidencecwetext)anybanditIssueMEDIUMr   CweINSECURE_TEMP_FILE)r   configr   s   `  r   r   r   @   sf     jF2*%3

>X
>>>||]]}}		,,B	
 	
 ?r   )__doc__r   bandit.corer   r   testr   takes_configcheckstest_idr   r	   r   r   <module>r*      sW   
0b   />
 Uf
   
r   