
    >/i                         S r SSKrSSKrSSKJr  SSKJr  \R                  " S5      \R                  " S5      S 5       5       r	g)aN	  
==========================================
B701: Test for not auto escaping in jinja2
==========================================

Jinja2 is a Python HTML templating system. It is typically used to build web
applications, though appears in other places well, notably the Ansible
automation system. When configuring the Jinja2 environment, the option to use
autoescaping on input can be specified. When autoescaping is enabled, Jinja2
will filter input strings to escape any HTML content submitted via template
variables. Without escaping HTML input the application becomes vulnerable to
Cross Site Scripting (XSS) attacks.

Unfortunately, autoescaping is False by default. Thus this plugin test will
warn on omission of an autoescape setting, as well as an explicit setting of
false. A HIGH severity warning is generated in either of these scenarios.

:Example:

.. code-block:: none

    >> Issue: Using jinja2 templates with autoescape=False is dangerous and can
    lead to XSS. Use autoescape=True to mitigate XSS vulnerabilities.
       Severity: High   Confidence: High
       CWE: CWE-94 (https://cwe.mitre.org/data/definitions/94.html)
       Location: ./examples/jinja2_templating.py:11
    10  templateEnv = jinja2.Environment(autoescape=False,
        loader=templateLoader)
    11  Environment(loader=templateLoader,
    12              load=templateLoader,
    13              autoescape=False)
    14

    >> Issue: By default, jinja2 sets autoescape to False. Consider using
    autoescape=True or use the select_autoescape function to mitigate XSS
    vulnerabilities.
       Severity: High   Confidence: High
       CWE: CWE-94 (https://cwe.mitre.org/data/definitions/94.html)
       Location: ./examples/jinja2_templating.py:15
    14
    15  Environment(loader=templateLoader,
    16              load=templateLoader)
    17
    18  Environment(autoescape=select_autoescape(['html', 'htm', 'xml']),
    19              loader=templateLoader)


.. seealso::

 - `OWASP XSS <https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)>`__
 - https://realpython.com/primer-on-jinja-templating/
 - https://jinja.palletsprojects.com/en/2.11.x/api/#autoescaping
 - https://security.openstack.org/guidelines/dg_cross-site-scripting-xss.html
 - https://cwe.mitre.org/data/definitions/94.html

.. versionadded:: 0.10.0

.. versionchanged:: 1.7.3
    CWE information added

    N)issue)test_propertiesCallB701c                    [        U R                  [        5      (       Ga<  U R                  R                  S5      nUS   nSU;   Ga  US:X  Ga  [        R
                  " U R                  5       GH  n[        U[        R                  5      (       d  M%  [        USS 5      S:X  a  [        UR                  SS 5      S:X  d  [        UR                  S	S 5      S
L aM  [        R                  " [        R                  [        R                  [        R                  R                  SS9s  $ [        USS 5      S:X  d  M  [        US	S 5      n[        USS 5      S:X  d  [        US	S 5      SL a    g [        U[        R                   5      (       a8  [        UR"                  SS 5      S:X  d  [        UR"                  SS 5      S:X  a    g [        R                  " [        R                  [        R$                  [        R                  R                  SS9s  $    [        R                  " [        R                  [        R                  [        R                  R                  SS9$ g g g )N.jinja2Environmentarg
autoescapeidFalsevalueFzUsing jinja2 templates with autoescape=False is dangerous and can lead to XSS. Use autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities.)severity
confidencecwetextTrueTattrselect_autoescapezUsing jinja2 templates with autoescape=False is dangerous and can lead to XSS. Ensure autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities.zBy default, jinja2 sets autoescape to False. Consider using autoescape=True or use the select_autoescape function to mitigate XSS vulnerabilities.)
isinstancecall_function_name_qualstrsplitastwalknodekeywordgetattrr   banditIssueHIGHr   CweCODE_INJECTIONr   funcMEDIUM)contextqualname_listr&   r   r   s        Y/home/james-whalen/.local/lib/python3.13/site-packages/bandit/plugins/jinja2_templates.pyjinja2_autoescape_falser+   I   s    '1137777==cBR }$)>.dCKK00tUD1\A

D$77B"4::w=F%||%+[['-{{ %		 8 8"/		  	 tUD1\A 'gt <#E46&@&ugt<D"'sxx88#EJJ=23&uzz4>2 3 ##)<<)/+1==$)II$<$<&7		$ 	E /\ <<!;;II,,<	 _ *?$ 8    )
__doc__r   r!   bandit.corer   r   testcheckstest_idr+    r,   r*   <module>r3      sG   
<z    / Vf;  ;r,   