Skip to content

Commit bb1d055

Browse files
authored
Print friendly Version of HTML report (#895)
1 parent 06207fc commit bb1d055

File tree

22 files changed

+52
-44
lines changed

22 files changed

+52
-44
lines changed

cve_bin_tool/async_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def __init__(self, *args, **kwargs):
8888
self._file = None
8989

9090
async def __call__(self):
91-
""" Convenience method to allow call like following:
92-
f = await FileIO("some file path", "r")()
93-
Note: We can't make async __init__
91+
"""Convenience method to allow call like following:
92+
f = await FileIO("some file path", "r")()
93+
Note: We can't make async __init__
9494
"""
9595
return await self.open()
9696

cve_bin_tool/checkers/sqlite.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ class SqliteChecker(Checker):
6868
VERSION_MAP = mapdb.get_mapping_data()
6969

7070
def guess_contains(self, lines):
71-
"""Tries to determine if a file includes sqlite
72-
"""
71+
"""Tries to determine if a file includes sqlite"""
7372
# since the version strings are super unique here, we can guess the version
7473
# at the same time
7574

cve_bin_tool/checkers/xml2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class Xml2Checker(Checker):
2424

2525
@staticmethod
2626
def guess_xml2_version(lines):
27-
"""Guesses the xml2 version from the file contents
28-
"""
27+
"""Guesses the xml2 version from the file contents"""
2928
new_guess = ""
3029
pattern1 = re.compile(r"/libxml2-([0-9]+\.[0-9]+\.[0-9]+)/")
3130
pattern2 = re.compile(r"\\libxml2-([0-9]+\.[0-9]+\.[0-9]+)\\")

cve_bin_tool/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ def main(argv=None):
335335
# Creates a Object for OutputEngine
336336
output = OutputEngine(
337337
all_cve_data=cve_scanner.all_cve_data,
338+
scanned_dir=args["directory"],
338339
filename=args["output_file"],
339340
themes_dir=args["html_theme"],
340341
products_with_cve=cve_scanner.products_with_cve,

cve_bin_tool/cve_scanner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ def get_cves(self, product_info: ProductInfo, triage_data: TriageData):
214214
self.all_cve_data[product_info]["cves"] = [CVE("UNKNOWN", "UNKNOWN")]
215215

216216
def openssl_convert(self, version: str) -> str:
217-
""" pkg_resources follows pep-440 which doesn't expect openssl style 1.1.0g version numbering
218-
So to fake it, if the last character is a letter, replace it with .number before comparing """
217+
"""pkg_resources follows pep-440 which doesn't expect openssl style 1.1.0g version numbering
218+
So to fake it, if the last character is a letter, replace it with .number before comparing"""
219219
if not version: # if version is empty return it.
220220
return version
221221

@@ -226,7 +226,7 @@ def openssl_convert(self, version: str) -> str:
226226
return version
227227

228228
def affected(self):
229-
""" Returns list of product name and version tuples identified from
229+
"""Returns list of product name and version tuples identified from
230230
scan"""
231231
return sorted(
232232
[(cve_data.product, cve_data.version) for cve_data in self.all_cve_data]

cve_bin_tool/cvedb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def refresh_cache_and_update_db(self):
237237
self.populate_db()
238238

239239
def get_cvelist_if_stale(self):
240-
""" Update if the local db is more than one day old.
240+
"""Update if the local db is more than one day old.
241241
This avoids the full slow update with every execution.
242242
"""
243243
if not os.path.isfile(self.dbpath) or (
@@ -303,7 +303,7 @@ def init_database(self):
303303
self.connection.commit()
304304

305305
def populate_db(self):
306-
""" Function that populates the database from the JSON.
306+
"""Function that populates the database from the JSON.
307307
308308
WARNING: After some inspection of the data, we are assuming that start/end ranges are kept together
309309
in single nodes. This isn't *required* by the json so may not be true everywhere. If that's the case,

cve_bin_tool/error_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def excepthook(exc_type, exc_val, exc_tb):
8484

8585

8686
class ErrorHandler:
87-
""" Error handler context manager.
87+
"""Error handler context manager.
8888
8989
Supports Different modes like ignore error, print full trace, truncated trace and no trace.
9090
Log messages if logger specified.

cve_bin_tool/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
async def aio_is_binary(filename):
12-
""" Read the magic bytes from a file and determine if it is an executable
12+
"""Read the magic bytes from a file and determine if it is an executable
1313
binary."""
1414
signature = await read_signature(filename)
1515
for name, method in inspect.getmembers(

cve_bin_tool/output_engine/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class OutputEngine:
4343
def __init__(
4444
self,
4545
all_cve_data: Dict[ProductInfo, CVEData],
46+
scanned_dir: str,
4647
filename: str,
4748
themes_dir: str,
4849
logger: Logger = None,
@@ -52,14 +53,15 @@ def __init__(
5253
):
5354
self.logger = logger or LOGGER.getChild(self.__class__.__name__)
5455
self.all_cve_data = all_cve_data
56+
self.scanned_dir = scanned_dir
5557
self.filename = os.path.abspath(filename) if filename else ""
5658
self.products_with_cve = products_with_cve
5759
self.products_without_cve = products_without_cve
5860
self.total_files = total_files
5961
self.themes_dir = themes_dir
6062

6163
def output_cves(self, outfile, output_type="console"):
62-
""" Output a list of CVEs
64+
"""Output a list of CVEs
6365
format self.checkers[checker_name][version] = dict{id: severity}
6466
to other formats like CSV or JSON
6567
"""
@@ -70,6 +72,7 @@ def output_cves(self, outfile, output_type="console"):
7072
elif output_type == "html":
7173
output_html(
7274
self.all_cve_data,
75+
self.scanned_dir,
7376
self.filename,
7477
self.themes_dir,
7578
self.total_files,

cve_bin_tool/output_engine/html.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def render_cves(
4646

4747
def output_html(
4848
all_cve_data: Dict[ProductInfo, CVEData],
49+
scanned_dir: str,
4950
filename: str,
5051
theme_dir: str,
5152
total_files: int,
@@ -54,8 +55,7 @@ def output_html(
5455
logger: LOGGER,
5556
outfile,
5657
):
57-
"""Returns a HTML report for CVE's
58-
"""
58+
"""Returns a HTML report for CVE's"""
5959

6060
# Step 1: Load all the templates
6161

@@ -240,9 +240,11 @@ def output_html(
240240
base.render(
241241
date=datetime.now().strftime("%d %b %Y"),
242242
dashboard=dashboard,
243+
scanned_dir=scanned_dir,
243244
all_paths=all_paths,
244245
print_mode=html_print_mode(
245246
all_cve_data,
247+
scanned_dir,
246248
products_with_cve,
247249
products_without_cve,
248250
total_files,

0 commit comments

Comments
 (0)