
    >/i	                         S r SSKJ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g)
uL  
=====================================================
B613: TrojanSource - Bidirectional control characters
=====================================================

This plugin checks for the presence of unicode bidirectional control characters
in Python source files. Those characters can be embedded in comments and strings
to reorder source code characters in a way that changes its logic.

:Example:

.. code-block:: none

    >> Issue: [B613:trojansource] A Python source file contains bidirectional control characters ('\u202e').
       Severity: High   Confidence: Medium
       CWE: CWE-838 (https://cwe.mitre.org/data/definitions/838.html)
       More Info: https://bandit.readthedocs.io/en/1.7.5/plugins/b113_trojansource.html
       Location: examples/trojansource.py:4:25
     3          access_level = "user"
     4      if access_level != 'none‮⁦': # Check if admin ⁩⁦' and access_level != 'user
     5          print("You are an admin.\n")

.. seealso::

 - https://trojansource.codes/
 - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574

.. versionadded:: 1.7.10

    )detect_encodingN)issue)test_properties)
u   ‪u   ‫u   ‬u   ‭u   ‮u   ⁦u   ⁧u   ⁨u   ⁩u   ‏B613Filec                 d   [        U R                  S5       n[        UR                  5      u  p#S S S 5        [        U R                  WS9 n[	        UR                  5       SS9 H  u  pE[         H  n UR                  U5      S-   nSU-  n[        R                  " [        R                  [        R                  [        R                  R                  UUUS9n	U/U	l        U	s  s  sS S S 5        $    M     S S S 5        g ! , (       d  f       N= f! [         a     M  f = f! , (       d  f       g = f)Nrb)encoding   )startzDA Python source file contains bidirectional control characters (%r).)severity
confidencecwetextlineno
col_offset)openfilenamer   readline	enumerate	readlinesBIDI_CHARACTERSindex
ValueErrorbanditIssueHIGHMEDIUMr   Cwe)INAPPROPRIATE_ENCODING_FOR_OUTPUT_CONTEXT	linerange)
contextsrc_filer
   _r   linecharr   r   b_issues
             U/home/james-whalen/.local/lib/python3.13/site-packages/bandit/plugins/trojansource.pytrojansourcer)   6   s    
g	%%h&7&78 
&	g	2h%h&8&8&:!DLF'!%D!1A!5J0267  !,,#[[%}}		KK!) &,H!) 
3	2' E 
3	2 
&	% "  
3	2sB   C?'D!3DAD!0D!?
D
D	D!D	D!!
D/)__doc__tokenizer   r   bandit.corer   r   testr   test_idchecksr)        r(   <module>r2      sM   < %   / fV  r1   