forked from intel/cve-bin-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
134 lines (123 loc) · 4.16 KB
/
setup.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Copyright (C) 2021 Intel Corporation
# SPDX-License-Identifier: GPL-3.0-or-later
import ast
import os
import pathlib
import re
from setuptools import find_packages, setup
PACKAGE_ROOT_PATH = pathlib.Path(__file__).parent.resolve()
with open("README.md", encoding="utf-8") as f:
readme = f.read()
with open("requirements.txt", encoding="utf-8") as f:
requirements = f.read().split("\n")
with open(os.path.join("cve_bin_tool", "version.py")) as f:
for line in f:
if line.startswith("VERSION"):
VERSION = ast.literal_eval(line.strip().split("=")[-1].strip())
break
def enumerate_entry_points_parsers():
"""Reads the files in cve_bin_tool/parsers/to auto determine list"""
parsers = {}
for path in PACKAGE_ROOT_PATH.joinpath(
"cve_bin_tool",
"parsers",
).glob("*.py"):
if "__init__" == path.stem:
continue
contents = path.read_text()
for re_match in re.finditer(r"^class (\w+)", contents, re.MULTILINE):
parser_cls_name = re_match[1]
parsers[".".join([path.stem, parser_cls_name])] = ":".join(
[
str(path.relative_to(PACKAGE_ROOT_PATH).with_suffix("")).replace(
os.path.sep, "."
),
parser_cls_name,
],
)
return parsers
setup_kwargs = dict(
name="cve-bin-tool",
version=VERSION,
description="CVE Binary Checker Tool",
long_description=readme,
long_description_content_type="text/markdown",
author="Terri Oda",
author_email="[email protected]",
maintainer="Terri Oda",
maintainer_email="[email protected]",
url="https://github.com/intel/cve-bin-tool",
license="GPL-3.0-or-later",
keywords=["security", "tools", "CVE"],
python_requires=">=3.8",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License (GPL)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
install_requires=requirements,
extras_require={
"PDF": ["reportlab"],
},
packages=find_packages(
exclude=["locales", "presentation"],
),
package_data={
"cve_bin_tool.output_engine": [
"html_reports/templates/*.html",
"html_reports/css/*.css",
"html_reports/js/*.js",
"print_mode/templates/*.html",
],
"cve_bin_tool": [
"schemas/*.xsd",
],
"sbom": ["*.spdx", "*.json"],
},
entry_points={
"console_scripts": [
"cve-bin-tool = cve_bin_tool.cli:main",
"csv2cve = cve_bin_tool.csv2cve:main",
],
"cve_bin_tool.checker": [
"{} = cve_bin_tool.checkers.{}:{}".format(
filename.replace(".py", ""),
filename.replace(".py", ""),
"".join(
(filename.replace(".py", "") + " checker")
.replace("_", " ")
.title()
.split()
),
)
for filename in os.listdir(
os.path.join(
os.path.abspath(os.path.dirname(__file__)),
"cve_bin_tool",
"checkers",
)
)
if filename.endswith(".py") and "__init__" not in filename
],
"cve_bin_tool.parsers": [
"{} = {}".format(
parser_entry_point_name,
entry_point_path,
)
for (
parser_entry_point_name,
entry_point_path,
) in enumerate_entry_points_parsers().items()
],
},
)
if __name__ == "__main__":
setup(**setup_kwargs)