-
Notifications
You must be signed in to change notification settings - Fork 529
/
Copy pathcsv2cve.py
45 lines (36 loc) · 1.25 KB
/
csv2cve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations
import logging
import os
import sys
from cve_bin_tool import cli
from cve_bin_tool.error_handler import ErrorHandler, InsufficientArgs, excepthook
from cve_bin_tool.log import LOGGER
sys.excepthook = excepthook
def main(argv: list[str] | None = None):
"""Used to scan a .csv file that lists the dependencies."""
if sys.version_info < (3, 8):
raise OSError(
"Python no longer provides security updates for version 3.8 as of October 2024. Please upgrade to Python 3.9+ to use CVE Binary Tool."
)
logger: logging.Logger = LOGGER.getChild("CSV2CVE")
argv = argv or sys.argv
if len(argv) < 2:
with ErrorHandler(logger=logger):
raise InsufficientArgs("csv file required")
flag: bool = False
for idx, arg in enumerate(argv):
if arg.endswith(".csv"):
argv[idx] = f"-i={arg}"
flag = True
if flag:
return cli.main(argv)
else:
with ErrorHandler(logger=logger):
raise InsufficientArgs("csv file required")
if __name__ == "__main__":
if os.getenv("NO_EXIT_CVE_NUM"):
main()
else:
sys.exit(main())