Skip to content

Commit e32fd08

Browse files
authored
CVE testing (#863)
* Update enterprise-patching.yaml * Update filter.py * Update filter.py * cve-fix * Update requirements.txt * Update requirements.txt * Update requirements.txt * Update filter.py * Update filter.py Removed whitespace * Update filter.py Removed trailing line * Update enterprise-patching.yaml Updated workflow to run on main branch
1 parent 0b49b04 commit e32fd08

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

cve/filter.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,35 @@
22

33
try:
44
with open("installed.json") as f:
5-
installed = {pkg["name"].lower(): pkg["version"] for pkg in json.load(f)}
5+
# Only store package names for comparison, ignore versions
6+
installed = {pkg["name"].lower() for pkg in json.load(f)}
67
except (json.JSONDecodeError, FileNotFoundError):
7-
installed = {}
8+
installed = set()
89

9-
with open("requirements.txt") as f:
10+
print("Installed packages:")
11+
print("\n".join(sorted(installed)) if installed else "No installed packages found")
12+
print("\n" + "=" * 50 + "\n")
13+
14+
with open("cve/requirements.txt") as f:
1015
requirements = [
1116
line.strip() for line in f if line.strip() and not line.startswith("#")
1217
]
1318

19+
print("Requirements from requirements.txt:")
20+
print("\n".join(requirements) if requirements else "No requirements found")
21+
print("\n" + "=" * 50 + "\n")
22+
1423
filtered = []
1524
for req in requirements:
25+
# Only get package name for comparison
1626
pkg_name = req.split("==")[0].strip().lower()
1727
if pkg_name in installed:
28+
# Add the full original requirement (including version)
1829
filtered.append(req)
1930

31+
print("Filtered requirements (matching installed packages):")
32+
print("\n".join(filtered) if filtered else "No matching packages found")
33+
print("\n" + "=" * 50 + "\n")
34+
2035
with open("filtered-requirements.txt", "w") as f:
2136
f.write("\n".join(filtered))

cve/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
pymysql==1.1.1
2+
jinja2==3.1.5
3+
idna==3.7
4+
webob==1.8.8
5+
virtualenv==20.26.6

0 commit comments

Comments
 (0)