[Git][security-tracker-team/security-tracker][master] 2 commits: debsecan: speed up computation
Emilio Pozuelo Monfort (@pochu)
pochu at debian.org
Mon Nov 23 22:55:28 GMT 2026
Emilio Pozuelo Monfort pushed to branch master at Debian Security Tracker / security-tracker
Commits:
ac320ec1 by Helmut Grohne at 2026-11-23T16:54:38+01:00
debsecan: speed up computation
If one profiles an incremental bin/update-db, a lot of time is spent in
the query being removed here. It accounts for 75% of samples and the
whole debsecan computation accounts for more than 90%. A key problem
here is that the query at hand is multiple times per CVE. For packages
like linux, it can return 6000 versions (many of which are equal). So we
are effectively having an O(n^2) per source-package where n is the CVE
count and linux is having a large n.
To avoid this, we may sweep the package_notes table once and collect a
set of available versions once. This is not without cost. Python now
holds a table of all versions known for each source package and release.
Presently, this table appears to weigh about 1MB, but using it results
in a 10x speedup.
This is not a permanent win. As more security updates are released, this
table grows. Let's hope that RAM grows faster than vulnerabilities.
- - - - -
92e3d341 by Emilio Pozuelo Monfort at 2026-11-23T22:55:23+00:00
Merge branch 'helmutg/speedup-debsecan' into 'master'
debsecan: speed up computation
See merge request security-tracker-team/security-tracker!350
- - - - -
1 changed file:
- lib/python/security_db.py
Changes:
=====================================
lib/python/security_db.py
=====================================
@@ -1707,6 +1707,14 @@ class DB:
vuln_list = []
source_packages = set()
def fill_vuln_list(source_packages=source_packages):
+ # Precompute other_versions to speed things up.
+ all_other_versions = {}
+ for package, release, version in c.execute(
+ """SELECT DISTINCT package, release, fixed_version
+ FROM package_notes WHERE fixed_version is not NULL;"""):
+ all_other_versions.setdefault(
+ (package, release), set()).add(version)
+
for (bug, package) in list(c.execute(
"""SELECT DISTINCT bug_name, package
FROM package_notes
@@ -1769,16 +1777,11 @@ class DB:
# Collect newer versions in the same release
# (which are supposed to fix the same bug).
-
v_ref = debian_support.Version(version)
- for (v,) in c.execute("""SELECT fixed_version
- FROM package_notes
- WHERE package = ? AND release = ?""",
- (package, release)):
- if v is None:
- continue
- if debian_support.Version(v) >= v_ref:
- other_versions.add(v)
+ other_versions.update(
+ v for v in all_other_versions.get(
+ (package, release), set())
+ if debian_support.Version(v) >= v_ref)
# The second part of this SELECT statement
# covers binary-only NMUs.
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/compare/517e749180548d5c254824711996a1fbf30d63a7...92e3d3413aa502d6d0f035f4419e8c3564d48d11
--
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/compare/517e749180548d5c254824711996a1fbf30d63a7...92e3d3413aa502d6d0f035f4419e8c3564d48d11
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-security-tracker-commits/attachments/20261123/a0f9208a/attachment-0001.htm>
More information about the debian-security-tracker-commits
mailing list