mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-22 11:59:33 +00:00
security: Add past vulnerabilities count
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil@medhas.org isort] [sunil@medhas.org Handle errors during HTTP request] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
f0e45d39c9
commit
5fe84bf395
1
debian/control
vendored
1
debian/control
vendored
@ -99,6 +99,7 @@ Depends:
|
||||
python3-gi,
|
||||
python3-paramiko,
|
||||
python3-psutil,
|
||||
python3-requests,
|
||||
python3-ruamel.yaml,
|
||||
python3-yaml,
|
||||
sudo,
|
||||
|
||||
@ -21,6 +21,7 @@ FreedomBox app for security configuration.
|
||||
import subprocess
|
||||
from collections import defaultdict
|
||||
|
||||
import requests
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
@ -121,13 +122,23 @@ def get_vulnerability_counts():
|
||||
(label, package, *_) = line.split()
|
||||
cves[label].add(package)
|
||||
|
||||
try:
|
||||
past_cves = requests.get(
|
||||
'https://security-tracker.debian.org/tracker/data/json').json()
|
||||
except Exception:
|
||||
past_cves = None
|
||||
|
||||
apps = {
|
||||
'freedombox': {
|
||||
'name': 'freedombox',
|
||||
'packages': {'freedombox'},
|
||||
'count': 0,
|
||||
'past_count': 0 if past_cves else None,
|
||||
}
|
||||
}
|
||||
if past_cves and 'freedombox' in past_cves:
|
||||
apps['freedombox']['past_count'] = len(past_cves['freedombox'])
|
||||
|
||||
for module_name, module in module_loader.loaded_modules.items():
|
||||
try:
|
||||
packages = module.managed_packages
|
||||
@ -142,8 +153,13 @@ def get_vulnerability_counts():
|
||||
'name': module_name,
|
||||
'packages': set(packages),
|
||||
'count': 0,
|
||||
'past_count': 0 if past_cves else None,
|
||||
}
|
||||
|
||||
for package in packages:
|
||||
if past_cves and package in past_cves:
|
||||
apps[module_name]['past_count'] += len(past_cves[package])
|
||||
|
||||
for cve_packages in cves.values():
|
||||
for app_ in apps.values():
|
||||
if cve_packages & app_['packages']:
|
||||
|
||||
@ -47,7 +47,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "App Name" %}</th>
|
||||
<th>{% trans "Vulnerabilities Reported" %}</th>
|
||||
<th>{% trans "Current Vulnerabilities" %}</th>
|
||||
<th>{% trans "Past Vulnerabilities" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -55,6 +56,7 @@
|
||||
<tr>
|
||||
<td>{{ app.name }}</td>
|
||||
<td>{{ app.count }}</td>
|
||||
<td>{{ app.past_count }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user