
    >/io                         S SK r S SKrS SKrS SKJr  S SKJr  S SKJr  \R                  \l	        \R                  " \5      r " S S5      rg)    N)	constants)context)utilsc                   :    \ rS rSrS rS rSS jr\S 5       rSr	g)	BanditTester   c                 P    / U l         Xl        S U l        X l        X0l        X@l        g N)resultstestsetlast_resultdebugnosec_linesmetrics)selfr   r   r   r   s        L/home/james-whalen/.local/lib/python3.13/site-packages/bandit/core/tester.py__init__BanditTester.__init__   s&    
&    c                 ~   S/[        [        R                  5      -  S/[        [        R                  5      -  S.nU R                  R	                  U5      nU GH  nUR
                  n[        R                  " U5      n[        R                  " U5      n [        US5      (       a  U" XR                  5      n	OU" U5      n	U	GbI  U R                  XyS9n
[        US   [        5      (       a  US   R                  S5      U	l        O
US   U	l        US   U	l        U	R"                  c
  US	   U	l        U	R$                  / :X  a
  US
   U	l        U	R&                  S:X  a
  US   U	l        UR)                  SS5      U	l        Xil        U	R.                  S:X  a  UR0                  U	l        U
b  U
(       d2  [2        R5                  S5        U R6                  R9                  5         GM  U	R.                  U
;   a?  [2        R5                  SU	R.                   35        U R6                  R;                  5         GM  U R<                  R?                  U	5        [2        R5                  SXi5        [        R                  RA                  U	RB                  5      n[        RD                  U	RB                     nUS   U==   U-  ss'   [        R                  RA                  U	RF                  5      n[        RD                  U	RF                     nUS   U==   U-  ss'   GM  U R                  U5      n
U
(       a>  UR0                  U
;   a+  [2        RI                  SUR0                   SUS	    35        GM	  GM  GM     [2        R5                  SU5        U$ ! [J         a0  nU RM                  XhU5        U R4                  (       a  e  SnAGM^  SnAff = f)a]  Runs all tests for a certain type of check, for example

Runs all tests for a certain type of check, for example 'functions'
store results in results.

:param raw_context: Raw context dictionary
:param checktype: The type of checks to run
:return: a score based on the number and type of test results with
        extra metrics about nosec comments
r   )SEVERITY
CONFIDENCE_configN)test_resultfilenamezutf-8	file_datalineno	linerange
col_offsetend_col_offset z"skipped, nosec without test numberzskipped, nosec for test zIssue identified by %s: %sr   r   znosec encountered (z), but no failed test on line zReturning scores: %s)'lenr   RANKINGr   	get_tests__name__copy	b_contextContexthasattrr   _get_nosecs_from_contexts
isinstancebytesdecodefnamefdatar   r   r    getr!   testtest_id_test_idLOGr   r   
note_nosecnote_skipped_testr   appendindexseverityRANKING_VALUES
confidencewarning	Exceptionreport_error)r   raw_context	checktypescorestestsr2   nametemp_contextr   resultnosec_tests_to_skipsevvalcones                  r   	run_testsBanditTester.run_tests   sH    c)"3"344#I$5$5 66

 &&y1D==D99[1L''5GH4++!'<<8F!']F%*.*H*H$ +I +' ",z":EBB'3J'?'F'Fw'O'3J'?#/#<FL}},(4X(>''2-+7+D(((B.,8,F),8,<,<(!-F) #'K~~+)- +6
  3II&JK LL335$!>>-@@II":6>>:J K !LL::<$LL''/II:DI#++11&//BC#226??CC:&s+s2+#++11&2C2CDC#2263D3DEC<(-4-*.*H*H$+' , MM-@@1$-- A33?3I2JL A ,E \ 			(&1  !!$3:: s.   EN AN/CNAN
N<$N77N<Nc                    [        5       nU(       a&  U R                  R                  UR                  S5      OSn[        R
                  " U R                  U5      nUc  Uc  SnUb  UR                  U5        Ub  UR                  U5        U$ )zUse context and optional test result to get set of tests to skip.
:param context: temp context
:param test_result: optional test result
:return: set of tests to skip for the line based on contexts
N)setr   r1   r   r   	get_nosecupdate)r   r   r   rG   
base_testscontext_testss         r   r+   &BanditTester._get_nosecs_from_contexts}   s     "e    !3!3T: 	
 (8(8'B -"7"& !&&z2$&&}5""r   c                     SnX0 S3-  nUSUR                   S   UR                   S   4-  -  nU[        U5      -  nSS KnX4R                  5       -  n[        R                  U5        g )NzBandit internal error running:  zon file %s at line %i: r   r   r   )_contextstr	traceback
format_excr5   error)r2   r   r[   whatrY   s        r   r?   BanditTester.report_error   sw    0&
)Z(X&-
 
 	
 	E
$$&&		$r   )r   r   r   r   r   r   r
   )
r&   
__module____qualname____firstlineno__r   rL   r+   staticmethodr?   __static_attributes__ r   r   r   r      s'    aF#:  r   r   )r'   loggingwarningsbandit.corer   r   r(   r   warnings_formatterformatwarning	getLoggerr&   r5   r   rc   r   r   <module>rj      sC   
    ! , 11 !U Ur   