package2cve 0.2__tar.gz → 0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {package2cve-0.2 → package2cve-0.4}/PKG-INFO +2 -2
- package2cve-0.4/package2cve/Package2Cve.py +127 -0
- package2cve-0.4/package2cve/__init__.py +0 -0
- {package2cve-0.2 → package2cve-0.4}/package2cve.egg-info/PKG-INFO +2 -2
- {package2cve-0.2 → package2cve-0.4}/package2cve.egg-info/SOURCES.txt +2 -0
- package2cve-0.4/package2cve.egg-info/top_level.txt +1 -0
- {package2cve-0.2 → package2cve-0.4}/setup.py +2 -2
- package2cve-0.2/package2cve.egg-info/top_level.txt +0 -1
- {package2cve-0.2 → package2cve-0.4}/LICENSE.txt +0 -0
- {package2cve-0.2 → package2cve-0.4}/README.md +0 -0
- {package2cve-0.2 → package2cve-0.4}/package2cve.egg-info/dependency_links.txt +0 -0
- {package2cve-0.2 → package2cve-0.4}/package2cve.egg-info/requires.txt +0 -0
- {package2cve-0.2 → package2cve-0.4}/setup.cfg +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: package2cve
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4
|
|
4
4
|
Summary: Give a hostname to get package CVE or pass a package name plus version
|
|
5
5
|
Home-page: https://github.com/fernandocastrovilar/package2cve
|
|
6
|
-
Download-URL: https://github.com/fernandocastrovilar/package2cve/archive/
|
|
6
|
+
Download-URL: https://github.com/fernandocastrovilar/package2cve/archive/v_04.tar.gz
|
|
7
7
|
Author: Fernando Castro
|
|
8
8
|
Author-email: whit3bl0cker@gmail.com
|
|
9
9
|
License: MIT
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
from version_utils import rpm
|
|
4
|
+
import json
|
|
5
|
+
import paramiko
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
DEBIAN_CODENAMES = {
|
|
10
|
+
7: "wheezy",
|
|
11
|
+
8: "jessie",
|
|
12
|
+
9: "stretch",
|
|
13
|
+
10: "buster",
|
|
14
|
+
11: "bullseye",
|
|
15
|
+
12: "bookworm",
|
|
16
|
+
"unstable": "sid"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Package2Cve:
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
url = "https://security-tracker.debian.org/tracker/data/json"
|
|
24
|
+
response = requests.get(url)
|
|
25
|
+
self.data = response.json()
|
|
26
|
+
|
|
27
|
+
def _determine_cve(self, package, version, os):
|
|
28
|
+
vulnerabilities = []
|
|
29
|
+
try:
|
|
30
|
+
if package in self.data:
|
|
31
|
+
cves = self.data[package]
|
|
32
|
+
|
|
33
|
+
for cve in cves:
|
|
34
|
+
if os in cves[cve]["releases"].keys():
|
|
35
|
+
if "fixed_version" in cves[cve]["releases"][os]:
|
|
36
|
+
fixed = cves[cve]["releases"][os]["fixed_version"]
|
|
37
|
+
vulnerable = rpm.compare_versions(fixed, version) > 0
|
|
38
|
+
else:
|
|
39
|
+
fixed = False
|
|
40
|
+
vulnerable = True
|
|
41
|
+
if vulnerable:
|
|
42
|
+
latest = cves[cve]["releases"][os]["repositories"][os]
|
|
43
|
+
vulnerability = {
|
|
44
|
+
"cve": cve,
|
|
45
|
+
"fixed": fixed,
|
|
46
|
+
"latest": latest,
|
|
47
|
+
}
|
|
48
|
+
vulnerabilities.append(vulnerability)
|
|
49
|
+
return vulnerabilities
|
|
50
|
+
except Exception as error:
|
|
51
|
+
return error
|
|
52
|
+
|
|
53
|
+
def package_cve(self, os, package, version):
|
|
54
|
+
if os not in DEBIAN_CODENAMES:
|
|
55
|
+
raise Exception("Debian codename not valid")
|
|
56
|
+
vulnerabilities = self._determine_cve(package, version, os)
|
|
57
|
+
if not vulnerabilities:
|
|
58
|
+
"""
|
|
59
|
+
If no CVE, return None to continue
|
|
60
|
+
"""
|
|
61
|
+
return None
|
|
62
|
+
latest_version = vulnerabilities[0]["latest"]
|
|
63
|
+
cve_list = []
|
|
64
|
+
cve_num_flag = False
|
|
65
|
+
for vuln in vulnerabilities:
|
|
66
|
+
if not vuln["fixed"]:
|
|
67
|
+
"""
|
|
68
|
+
Only return CVEs fixed
|
|
69
|
+
"""
|
|
70
|
+
continue
|
|
71
|
+
if not vuln["cve"] or "TEMP-" in vuln["cve"]:
|
|
72
|
+
continue
|
|
73
|
+
else:
|
|
74
|
+
cve_num_flag = True
|
|
75
|
+
cve_num = vuln["cve"]
|
|
76
|
+
cves = {
|
|
77
|
+
"cve_num": f"{cve_num}"
|
|
78
|
+
}
|
|
79
|
+
cve_list.append(cves)
|
|
80
|
+
cve_str = json.dumps(cve_list)
|
|
81
|
+
if cve_num_flag is False:
|
|
82
|
+
return None
|
|
83
|
+
return latest_version, cve_str
|
|
84
|
+
|
|
85
|
+
def remote_host_packages_cve(self, hostname, user, password):
|
|
86
|
+
cmd1 = "apt list --installed"
|
|
87
|
+
cmd2 = "lsb_release -c"
|
|
88
|
+
remote_list = []
|
|
89
|
+
try:
|
|
90
|
+
client = paramiko.client.SSHClient()
|
|
91
|
+
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
92
|
+
if password:
|
|
93
|
+
client.connect(hostname, username=user, password=password, timeout=60)
|
|
94
|
+
else:
|
|
95
|
+
client.connect(hostname, username=user, timeout=60)
|
|
96
|
+
_stdin, _stdout, _stderr = client.exec_command(cmd1)
|
|
97
|
+
packages = _stdout.readlines()
|
|
98
|
+
_stdin, _stdout, _stderr = client.exec_command(cmd2)
|
|
99
|
+
os_version = _stdout.readlines()[0].split("\t")[1].strip()
|
|
100
|
+
client.close()
|
|
101
|
+
for line in packages:
|
|
102
|
+
if "Listing" in line or not line:
|
|
103
|
+
continue
|
|
104
|
+
package_data = str(line).split(" ", 3)
|
|
105
|
+
package_name = package_data[0].split("/")[0]
|
|
106
|
+
package_version = package_data[1]
|
|
107
|
+
out = self.package_cve(os_version, package_name, package_version)
|
|
108
|
+
if not out:
|
|
109
|
+
continue
|
|
110
|
+
cve_list = out[1]
|
|
111
|
+
cve_list = json.loads(cve_list)
|
|
112
|
+
latest_fixed_version = out[0]
|
|
113
|
+
package = {
|
|
114
|
+
"package_name": f"{package_name}",
|
|
115
|
+
"cve_list": {
|
|
116
|
+
"cve": f"{str(cve_list)}"
|
|
117
|
+
},
|
|
118
|
+
"current_version": f"{package_version}",
|
|
119
|
+
"latest_fixed_version": f"{latest_fixed_version}"
|
|
120
|
+
}
|
|
121
|
+
remote_list.append(package)
|
|
122
|
+
if not remote_list:
|
|
123
|
+
return "{'no vulnerabilities found'}"
|
|
124
|
+
list_str = json.dumps(remote_list)
|
|
125
|
+
return list_str
|
|
126
|
+
except Exception as error:
|
|
127
|
+
return error
|
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: package2cve
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4
|
|
4
4
|
Summary: Give a hostname to get package CVE or pass a package name plus version
|
|
5
5
|
Home-page: https://github.com/fernandocastrovilar/package2cve
|
|
6
|
-
Download-URL: https://github.com/fernandocastrovilar/package2cve/archive/
|
|
6
|
+
Download-URL: https://github.com/fernandocastrovilar/package2cve/archive/v_04.tar.gz
|
|
7
7
|
Author: Fernando Castro
|
|
8
8
|
Author-email: whit3bl0cker@gmail.com
|
|
9
9
|
License: MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
package2cve
|
|
@@ -2,13 +2,13 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name='package2cve',
|
|
5
|
-
version='0.
|
|
5
|
+
version='0.4',
|
|
6
6
|
license='MIT',
|
|
7
7
|
description='Give a hostname to get package CVE or pass a package name plus version',
|
|
8
8
|
author='Fernando Castro',
|
|
9
9
|
author_email='whit3bl0cker@gmail.com',
|
|
10
10
|
url='https://github.com/fernandocastrovilar/package2cve',
|
|
11
|
-
download_url='https://github.com/fernandocastrovilar/package2cve/archive/
|
|
11
|
+
download_url='https://github.com/fernandocastrovilar/package2cve/archive/v_04.tar.gz',
|
|
12
12
|
packages=find_packages(),
|
|
13
13
|
install_requires=[
|
|
14
14
|
'paramiko',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|