[Secure-testing-commits] r14769 - in lib/python: sectracker sectracker_test
Florian Weimer
fw at alioth.debian.org
Sun May 30 19:14:02 UTC 2010
Author: fw
Date: 2010-05-30 19:14:00 +0000 (Sun, 30 May 2010)
New Revision: 14769
Modified:
lib/python/sectracker/analyzers.py
lib/python/sectracker_test/test_analyzers.py
Log:
sectracker.analyzers.bestversion(): new subroutine
Modified: lib/python/sectracker/analyzers.py
===================================================================
--- lib/python/sectracker/analyzers.py 2010-05-30 17:56:06 UTC (rev 14768)
+++ lib/python/sectracker/analyzers.py 2010-05-30 19:14:00 UTC (rev 14769)
@@ -225,3 +225,27 @@
result.append(Vulnerability(bug.header.name, pname,
unstable_fixed, other_versions))
return result
+
+def bestversion(config, codename, pkg, requested_members=None):
+ """Returns the source package with the highest version among the
+ requested sub-repository members."""
+ members = config.distributions[codename]["members"]
+ if requested_members is None:
+ names = members.values()
+ else:
+ names = [v for k, v in members.items() if k in requested_members]
+ fm = config.filemap()
+ bestver = None
+ bestpkg = None
+ for name, mems in members.items():
+ if requested_members is None or name in requested_members:
+ for mem in mems:
+ for comp in fm[mem].values():
+ if pkg in comp:
+ curpkg = comp[pkg]
+ curver = curpkg.version
+ if bestver is None or vercmp(curver, bestver) > 0:
+ bestver = curver
+ bestpkg = curpkg
+ return bestpkg
+
Modified: lib/python/sectracker_test/test_analyzers.py
===================================================================
--- lib/python/sectracker_test/test_analyzers.py 2010-05-30 17:56:06 UTC (rev 14768)
+++ lib/python/sectracker_test/test_analyzers.py 2010-05-30 19:14:00 UTC (rev 14769)
@@ -55,6 +55,10 @@
for v in vdb:
print v
+assert bestversion(c, "sid", "bash").name == "bash"
+assert bestversion(c, "sid", "bash", ("unsupported", "supported")).name \
+ == "bash"
+
for err in diag.messages():
print "%s:%d: %s: %s" % (err.file, err.line, err.level, err.message)
assert not diag.messages()
More information about the Secure-testing-commits
mailing list