ó
    >›/ix  ã                   óÆ   • S r SSKrSSKrSSKJr  SSKJr  SSKJr  S r	\R                  " S5      \R                  " S5      \R                  " S	5      S
 5       5       5       rg)aÕ  
============================================
B704: Potential XSS on markupsafe.Markup use
============================================

``markupsafe.Markup`` does not perform any escaping, so passing dynamic
content, like f-strings, variables or interpolated strings will potentially
lead to XSS vulnerabilities, especially if that data was submitted by users.

Instead you should interpolate the resulting ``markupsafe.Markup`` object,
which will perform escaping, or use ``markupsafe.escape``.


**Config Options:**

This plugin allows you to specify additional callable that should be treated
like ``markupsafe.Markup``. By default we recognize ``flask.Markup`` as
an alias, but there are other subclasses or similar classes in the wild
that you may wish to treat the same.

Additionally there is a whitelist for callable names, whose result may
be safely passed into ``markupsafe.Markup``. This is useful for escape
functions like e.g. ``bleach.clean`` which don't themselves return
``markupsafe.Markup``, so they need to be wrapped. Take care when using
this setting, since incorrect use may introduce false negatives.

These two options can be set in a shared configuration section
`markupsafe_xss`.


.. code-block:: yaml

    markupsafe_xss:
        # Recognize additional aliases
        extend_markup_names:
            - webhelpers.html.literal
            - my_package.Markup

        # Allow the output of these functions to pass into Markup
        allowed_calls:
            - bleach.clean
            - my_package.sanitize


:Example:

.. code-block:: none

    >> Issue: [B704:markupsafe_markup_xss] Potential XSS with
       ``markupsafe.Markup`` detected. Do not use ``Markup``
       on untrusted data.
       Severity: Medium   Confidence: High
       CWE: CWE-79 (https://cwe.mitre.org/data/definitions/79.html)
       Location: ./examples/markupsafe_markup_xss.py:5:0
    4       content = "<script>alert('Hello, world!')</script>"
    5       Markup(f"unsafe {content}")
    6       flask.Markup("unsafe {}".format(content))

.. seealso::

 - https://pypi.org/project/MarkupSafe/
 - https://markupsafe.palletsprojects.com/en/stable/escaping/#markupsafe.Markup
 - https://cwe.mitre.org/data/definitions/79.html

.. versionadded:: 1.8.3

é    N)Úissue)Útest_properties)Úget_call_namec                 ó   • U S:X  a  / / S.$ g )NÚmarkupsafe_xss)Úextend_markup_namesÚallowed_calls© )Únames    Ú^/home/james-whalen/.local/lib/python3.13/site-packages/bandit/plugins/markupsafe_markup_xss.pyÚ
gen_configr   O   s    € ØÐÓà#%Øñ
ð 	
ð  ó    r   ÚCallÚB704c           
      ó<  • U R                   nUS;  a  X!R                  S/ 5      ;  a  g U R                  R                  nU(       a"  [	        US   [
        R                  5      (       a  g UR                  S/ 5      nU(       a@  [	        US   [
        R                  5      (       a  [        US   U R                  5      U;   a  g [        R                  " [        R                  [        R                  [        R                  R                   SU SU R"                   S3S9$ )	N)zmarkupsafe.Markupzflask.Markupr   r   r	   zPotential XSS with ``z`` detected. Do not use ``z`` on untrusted data.)ÚseverityÚ
confidenceÚcweÚtext)Úcall_function_name_qualÚgetÚnodeÚargsÚ
isinstanceÚastÚConstantr   r   Úimport_aliasesÚbanditÚIssueÚMEDIUMÚHIGHr   ÚCweÚXSSÚcall_function_name)ÚcontextÚconfigÚqualnamer   r	   s        r   Úmarkupsafe_markup_xssr(   W   sç   € ð
 ×.Ñ.€HØÐ<Ó<ØŸ:™:Ð&;¸RÓ@Ó@àà<‰<×Ñ€DÞ”:˜d 1™g¤s§|¡|×4Ñ4àà—J‘J˜°Ó3€MæÜt˜A‘w¤§¡×)Ñ)Ü˜$˜q™' 7×#9Ñ#9Ó:¸mÓKð ä<Š<Ü—‘Ü—;‘;ÜI‰IM‰MØ$ X Jð /Ø×/Ñ/Ð0Ð0EðGñ	ð r   )Ú__doc__r   r   Úbandit.corer   r   ÚtestÚbandit.core.utilsr   r   Útakes_configÚchecksÚtest_idr(   r
   r   r   Ú<module>r0      sd   ðñBóF ã Ý Ý /Ý +ò
ð ×ÒÐ#Ó$Ø‡‚ˆVÓØ‡‚ˆfÓñó ó ó %ñr   