
    >/i                     8   S r 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                  R                  S5      r
Sr\
(       a   SSKrSr\R                  " \5      rS	S
SSSS.rS rS rS r SS jrS rS r\R0                  SS j5       rg! \ a     NLf = f)a  
================
Screen formatter
================

This formatter outputs the issues as color coded text to screen.

:Example:

.. code-block:: none

    >> Issue: [B506: yaml_load] Use of unsafe yaml load. Allows
       instantiation of arbitrary objects. Consider yaml.safe_load().

       Severity: Medium   Confidence: High
       CWE: CWE-20 (https://cwe.mitre.org/data/definitions/20.html)
       More Info: https://bandit.readthedocs.io/en/latest/
       Location: examples/yaml_load.py:5
    4       ystr = yaml.dump({'a' : 1, 'b' : 2, 'c' : 3})
    5       y = yaml.load(ystr)
    6       yaml.dump(y)

.. versionadded:: 0.9.0

.. versionchanged:: 1.5.0
    New field `more_info` added to output

.. versionchanged:: 1.7.3
    New field `CWE` added to output

    N)	constants)
docs_utils)test_propertieswin32FTz[0mz[95mz[94mz[93mz[91m)DEFAULTHEADERLOWMEDIUMHIGHc                 2    [         S    X-   [         S    3$ )Nr   r   )COLOR)textargss     R/home/james-whalen/.local/lib/python3.13/site-packages/bandit/formatters/screen.pyheaderr   E   s"    Hot{mE),<+=>>    c                 X   / nUR                  [        S[        U R                  5      5      5        SnUR	                  [        U R                  U R                  5       VVs/ s H$  u  p4X#[        US   5      [        US   5      4-  PM&     snn5        UR                  [        S[        U R                  5      5      5        UR	                  U R                   Vs/ s H  nSU 3PM
     sn5        SR                  U Vs/ s H  n[        U5      PM     sn5      $ s  snnf s  snf s  snf )NzFiles in scope (%i):z+	%s (score: {SEVERITY: %i, CONFIDENCE: %i})SEVERITY
CONFIDENCEzFiles excluded (%i):	
)appendr   len
files_listextendzipscoressumexcluded_filesjoinstr)managerbitstplitemscorefnamebits          r   get_verbose_detailsr)   I   s    DKK-s73E3E/FGH
8CKK "%W%7%7!H	
!H U:./U<5H1IJJ!H	
 	KK-s73I3I/JKLKK7+A+AB+A%2eW+ABC99$/$3c#h$/00	
 C/s   !+D
D" D'c                    / nUR                  [        S5      5        [        R                   H  u  p#UR                  SUR	                  5        S35        [        R
                   HI  nUR                  SUR                  5       < SU R                  R                  S   U SU 3   < 35        MK     M     SR                  U Vs/ s H  n[        U5      PM     sn5      $ s  snf )	Nz
Run metrics:z	Total issues (by z):z		z: _totals.r   )r   r   r   CRITERIAlowerRANKING
capitalizemetricsdatar    r!   )r"   r#   criteria_rankr(   s         r   get_metricsr6   X   s    DKK'() )))(..*:);2>?%%DKK OO%OO((3xj$4HI & * 99$/$3c#h$/00/s   C!c                    / nUR                  U< [        U R                     < SU R                  < SU R                  < SU R
                  < 35        UR                  U< SU R                  R                  5       < SU R                  R                  5       < 35        UR                  U S[        U R                  5       35        UR                  U S[        R                  " U R                  5       35        UR                  U< SU R                  < SU(       a  U R                  OS	< SU(       a  U R                  OS	< [        S
   < 35        U(       aC  UR                  U R!                  US5      R#                  S5       Vs/ s H  oaU-   PM	     sn5        SR%                  U Vs/ s H  owPM     sn5      $ s  snf s  snf )Nz>> Issue: [:z] z   Severity: z   Confidence: z   CWE: z   More Info: z   Location:  r   Tr   )r   r   severitytest_idtestr   r0   
confidencer!   cwer   get_urlr'   lineno
col_offsetr   get_codesplitr    )issueindentshow_lineno	show_codelinesr#   liner(   s           r   _output_issue_strrJ   h   sn    DKK %..!MMJJJJ	
	 	KK NN%%''')		
 	KK6((3uyy>"234KK6(.););EMM)J(KLMKK KK'ELLR/ +E3)	
	 ',~~eT'B'H'H'NO'Ntd]'NO	
 99T*TccT*++ P +s   G1Gc           
          / nU R                  X5      n[        U[        5      (       + nSn[        U5      (       d  gU H  nU(       a  [        XX   5      S:X  a  UR	                  [        USUS95        OaUR	                  [        USSSS95        UR	                  S5        XX    H-  n	UR	                  [        XUS95        UR	                  S	5        M/     UR	                  S
5        M     S	R                  U V
s/ s H  oPM     sn
5      $ s  sn
f )Nz
          z	No issues identified.   r9   )rH   F)rF   rG   z
-- Candidate Issues --r   z2--------------------------------------------------)get_issue_list
isinstancelistr   r   rJ   r    )r"   	sev_level
conf_levelrH   r#   issuesbaselinecandidate_indentrD   	candidater(   s              r   get_resultsrV      s    D##I:Ffd++Hv;;(3v}-2KK)%5AB KK!25E KK23#]	%iO D!	 +
 	H' * 99T*TccT*++*s   9Dc                 b    [        SR                  U  Vs/ s H  oPM     sn5      5        g s  snf )Nr   )printr    )r#   r(   s     r   do_printrY      s%    	$))D)DSSD)
*+)s   ,c                    [         (       a   [        (       a  [        R                  " 5         / nU R                  (       a  U R                  X#5      (       Ga  UR                  [        S[        R                  R                  [        R                  R                  5      5      5        U R                  (       a  UR                  [        U 5      5        UR                  [        S5      5        UR                  [        XX45      5        UR                  [        S5      5        UR                  SU R                  R                   S   S   -  5        UR                  SU R                  R                   S   S   -  5        UR                  [#        U 5      5        U R%                  5       nUR                  [        S	['        U5      5      5        UR)                  U Vs/ s H  nS
U-  PM
     sn5        [+        U5        UR,                  [.        R0                  R,                  :w  a   [2        R5                  SUR,                  5        [         (       a"  [        (       a  [        R6                  " 5         gggs  snf )ah  Prints discovered issues formatted for screen reading

This makes use of VT100 terminal codes for colored text.

:param manager: the bandit manager object
:param fileobj: The output file object, which may be sys.stdout
:param sev_level: Filtering severity level
:param conf_level: Filtering confidence level
:param lines: Number of lines to report, -1 for all
zRun started:%sz
Test results:z
Code scanned:z	Total lines of code: %ir+   locz!	Total lines skipped (#nosec): %inoseczFiles skipped (%i):z	%s (%s)zFScreen formatter output was not written to file: %s, consider '-f txt'N)IS_WIN_PLATFORMCOLORAMAcoloramainitquietresults_countr   r   datetimenowtimezoneutcverboser)   rV   r1   r2   r6   get_skippedr   r   rY   namesysstdoutLOGinfodeinit)r"   fileobjrP   rQ   rH   r#   skippedskips           r   reportrr      s    88D==G11)HH ("3"3"7"78I8I8M8M"N	
 ??KK+G45F,-.KJFGF,-.'##I.u57	

 	0##I.w79	

 	K()%%'F0#g,?@G<GD[4'G<=||szz& LL	
 88 $ =s   I0)TT)rs   )__doc__rc   loggingrj   bandit.corer   r   r   platform
startswithr]   r^   r_   ImportError	getLogger__name__rl   r   r   r)   r6   rJ   rV   rY   accepts_baselinerr    r   r   <module>r~      s   >   
 ! " ',,))'2
   ! 	?11" <>-,`,B,
 !!5 "5W  s   B BB