
    >/i)!                         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SK	J
r
  \R                  " \5      r\R                  SS j5       rg)	a  
==============
HTML formatter
==============

This formatter outputs the issues as HTML.

:Example:

.. code-block:: html

    <!DOCTYPE html>
    <html>
    <head>

    <meta charset="UTF-8">

    <title>
        Bandit Report
    </title>

    <style>

    html * {
        font-family: "Arial", sans-serif;
    }

    pre {
        font-family: "Monaco", monospace;
    }

    .bordered-box {
        border: 1px solid black;
        padding-top:.5em;
        padding-bottom:.5em;
        padding-left:1em;
    }

    .metrics-box {
        font-size: 1.1em;
        line-height: 130%;
    }

    .metrics-title {
        font-size: 1.5em;
        font-weight: 500;
        margin-bottom: .25em;
    }

    .issue-description {
        font-size: 1.3em;
        font-weight: 500;
    }

    .candidate-issues {
        margin-left: 2em;
        border-left: solid 1px; LightGray;
        padding-left: 5%;
        margin-top: .2em;
        margin-bottom: .2em;
    }

    .issue-block {
        border: 1px solid LightGray;
        padding-left: .5em;
        padding-top: .5em;
        padding-bottom: .5em;
        margin-bottom: .5em;
    }

    .issue-sev-high {
        background-color: Pink;
    }

    .issue-sev-medium {
        background-color: NavajoWhite;
    }

    .issue-sev-low {
        background-color: LightCyan;
    }

    </style>
    </head>

    <body>

    <div id="metrics">
        <div class="metrics-box bordered-box">
            <div class="metrics-title">
                Metrics:<br>
            </div>
            Total lines of code: <span id="loc">9</span><br>
            Total lines skipped (#nosec): <span id="nosec">0</span>
        </div>
    </div>




    <br>
    <div id="results">

    <div id="issue-0">
    <div class="issue-block issue-sev-medium">
        <b>yaml_load: </b> Use of unsafe yaml load. Allows
        instantiation of arbitrary objects. Consider yaml.safe_load().<br>
        <b>Test ID:</b> B506<br>
        <b>Severity: </b>MEDIUM<br>
        <b>Confidence: </b>HIGH<br>
        <b>CWE: </b>CWE-20 (https://cwe.mitre.org/data/definitions/20.html)<br>
        <b>File: </b><a href="examples/yaml_load.py"
        target="_blank">examples/yaml_load.py</a> <br>
        <b>More info: </b><a href="https://bandit.readthedocs.io/en/latest/
        plugins/yaml_load.html" target="_blank">
        https://bandit.readthedocs.io/en/latest/plugins/yaml_load.html</a>
        <br>

    <div class="code">
    <pre>
    5       ystr = yaml.dump({'a' : 1, 'b' : 2, 'c' : 3})
    6       y = yaml.load(ystr)
    7       yaml.dump(y)
    </pre>
    </div>


    </div>
    </div>

    </div>

    </body>
    </html>

.. versionadded:: 0.14.0

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

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

    N)escape)
docs_utils)test_properties)utilsc                     SnSnSnSnSn	Sn
SnSnU R                  X#S	9n[        U[        5      (       + nS
R                  S U R	                  5        5       5      nU(       a  UR                  US9nOS
nS
n[        U5       GH  u  nnU(       a  [        UU   5      S:X  aK  S
n[        UR                  US5      R                  S5      R                  S5      5      nUR                  US9nOjS
nS
nUU    HN  n[        UR                  US5      R                  S5      R                  S5      5      nUU
R                  US9-  nMP     U	R                  US9n[        R                  " UR                  5      nUUR                  USUR                  R!                  5        3UR"                  UR                  UR$                  UR                  UR&                  UR(                  UR(                  R+                  5       UR,                  UUUUR.                  S9-  nGM     UR                  U R0                  R2                  S   S   U R0                  R2                  S   S   S9nUR                  UUUS9nU   [4        R6                  " U5      nUR9                  U5        UR9                  U5        SSS5        UR:                  [<        R>                  R:                  :w  a!  [@        RC                  SUR:                  5        gg! , (       d  f       NX= f)a"  Writes issues to 'fileobj' in HTML format

: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
a  
<!DOCTYPE html>
<html>
<head>

<meta charset="UTF-8">

<title>
    Bandit Report
</title>

<style>

html * {
    font-family: "Arial", sans-serif;
}

pre {
    font-family: "Monaco", monospace;
}

.bordered-box {
    border: 1px solid black;
    padding-top:.5em;
    padding-bottom:.5em;
    padding-left:1em;
}

.metrics-box {
    font-size: 1.1em;
    line-height: 130%;
}

.metrics-title {
    font-size: 1.5em;
    font-weight: 500;
    margin-bottom: .25em;
}

.issue-description {
    font-size: 1.3em;
    font-weight: 500;
}

.candidate-issues {
    margin-left: 2em;
    border-left: solid 1px; LightGray;
    padding-left: 5%;
    margin-top: .2em;
    margin-bottom: .2em;
}

.issue-block {
    border: 1px solid LightGray;
    padding-left: .5em;
    padding-top: .5em;
    padding-bottom: .5em;
    margin-bottom: .5em;
}

.issue-sev-high {
    background-color: Pink;
}

.issue-sev-medium {
    background-color: NavajoWhite;
}

.issue-sev-low {
    background-color: LightCyan;
}

</style>
</head>
z[
<body>
{metrics}
{skipped}

<br>
<div id="results">
    {results}
</div>

</body>
</html>
a  
<div id="issue-{issue_no}">
<div class="issue-block {issue_class}">
    <b>{test_name}: </b> {test_text}<br>
    <b>Test ID:</b> {test_id}<br>
    <b>Severity: </b>{severity}<br>
    <b>Confidence: </b>{confidence}<br>
    <b>CWE: </b><a href="{cwe_link}" target="_blank">CWE-{cwe.id}</a><br>
    <b>File: </b><a href="{path}" target="_blank">{path}</a><br>
    <b>Line number: </b>{line_number}<br>
    <b>More info: </b><a href="{url}" target="_blank">{url}</a><br>
{code}
{candidates}
</div>
</div>
z/
<div class="code">
<pre>
{code}
</pre>
</div>
zK
<div class="candidates">
<br>
<b>Candidates: </b>
{candidate_list}
</div>
zX
<div class="candidate">
<div class="candidate-issues">
<pre>{code}</pre>
</div>
</div>
zm
<br>
<div id="skipped">
<div class="bordered-box">
<b>Skipped files:</b><br><br>
{files_list}
</div>
</div>
a!  
<div id="metrics">
    <div class="metrics-box bordered-box">
        <div class="metrics-title">
            Metrics:<br>
        </div>
        Total lines of code: <span id="loc">{loc}</span><br>
        Total lines skipped (#nosec): <span id="nosec">{nosec}</span>
    </div>
</div>

)	sev_level
conf_level c              3   6   #    U  H  u  pU S U S3v   M     g7f)z <b>reason:</b> z<br>N ).0fnamereasons      P/home/james-whalen/.local/lib/python3.13/site-packages/bandit/formatters/html.py	<genexpr>report.<locals>.<genexpr>J  s'      2ME '!&.2s   )
files_list   T
 )code)candidate_listz
issue-sev-)issue_noissue_class	test_nametest_id	test_textseverity
confidencecwecwe_linkpathr   
candidatesurlline_number_totalslocnosec)r'   r(   )metricsskippedresultsNzHTML output written to file: %s)"get_issue_list
isinstancelistjoinget_skippedformat	enumeratelenhtml_escapeget_codestriplstripr   get_urlr   r   lowertesttextr   r    linkr   linenor)   datar   wrap_file_objectwritenamesysstdoutLOGinfo)managerfileobjr   r	   linesheader_blockreport_blockissue_block
code_blockcandidate_blockcandidate_issueskipped_blockmetrics_blockissuesbaselineskipped_strskipped_textresults_strindexissuer#   	safe_coder   candidates_str	candidatecandidate_coder$   metrics_summaryreport_contentswrapped_files                                 r   reportr_      s   JLXLK"JOOMM ##i#OFfd++H '' $002 K $++{+C K!&)u3ve}-2J#ud+11$7>>sCI $$)$4DND#E]	!,&&ud399$?FFsK" /"8"8n"8"MM	 + )//~/NJ  /{))$U^^%9%9%;$<=jjMMjj^^''		YY^^%! * 
 	
' *J $**OO  +E2oo""9-g6 + O #)){ * O 
--g6<(?+ 

 ||szz&2GLLA ' 
s   49K??
L))__doc__loggingrB   htmlr   r4   bandit.corer   r   bandit.formattersr   	getLogger__name__rD   accepts_baseliner_   r       r   <module>rj      sN   
O`  
 & " ' #! !!iB "iBri   