Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html absolute #465

Closed
wants to merge 10 commits into from
9 changes: 7 additions & 2 deletions bandit/formatters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
from __future__ import absolute_import

import logging
import os
import string
import sys

import six
Expand Down Expand Up @@ -180,7 +182,7 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1):
<title>
Bandit Report
</title>

$base_html
<style>

html * {
Expand Down Expand Up @@ -377,7 +379,10 @@ def report(manager, fileobj, sev_level, conf_level, lines=-1):

with fileobj:
wrapped_file = utils.wrap_file_object(fileobj)
wrapped_file.write(utils.convert_file_contents(header_block))
base_html = '<base href = "file://{}/"/>'.format(os.getcwd())
template = string.Template(header_block)
header = template.safe_substitute(base_html=base_html)
wrapped_file.write(utils.convert_file_contents(header))
wrapped_file.write(utils.convert_file_contents(report_contents))

if fileobj.name != sys.stdout.name:
Expand Down