From ecbbab3e6af9d16c94d559db65ad326568b3ad12 Mon Sep 17 00:00:00 2001 From: Bastian Blank Date: Wed, 23 Mar 2016 10:51:02 +0100 Subject: Add support for CUSTOMER bugs and CVE extends --- lib/python/bugs.py | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/python/bugs.py b/lib/python/bugs.py index 278e2ab79e..5ec843b621 100644 --- a/lib/python/bugs.py +++ b/lib/python/bugs.py @@ -300,6 +300,28 @@ class Bug(BugBase): nts.append(notes[key]) self.notes = nts +class BugExtend(Bug): + def writeDB(self, cursor): + """Writes the record to an SQLite3 database.""" + + for (typ, c) in self.comments: + cursor.execute("""INSERT INTO bugs_notes + (bug_name, typ, comment) VALUES (?, ?, ?)""", + (self.name, typ, c)) + + for n in self.notes: + n.writeDB(cursor, self.name) + + import apsw + for x in self.xref: + try: + cursor.execute("""INSERT INTO bugs_xref + (source, target) VALUES (?, ?)""", + (self.name, x)) + except apsw.ConstraintError: + raise ValueError, \ + "cross reference to %s appears multiple times" % x + class BugFromDB(Bug): def __init__(self, cursor, name): assert type(name) in types.StringTypes @@ -441,6 +463,9 @@ class FileBase(debian_support.PackageFile): debian_support.PackageFile.__init__(self, name, fileObj) self.removed_packages = {} + def isExtend(self, name): + return False + def isUniqueName(self, name): """Returns True if the name is a real, unique name.""" return True @@ -729,7 +754,11 @@ class FileBase(debian_support.PackageFile): if first_bug: break record_name = temp_bug_name(first_bug, description) - yield self.finishBug(Bug(self.file.name, first_lineno, date, + if self.isExtend(record_name): + cls = BugExtend + else: + cls = Bug + yield self.finishBug(cls(self.file.name, first_lineno, date, record_name, description, comments, notes=pkg_notes, xref=xref)) @@ -774,6 +803,12 @@ class CVEFile(FileBase): bug.mergeNotes() return bug +class CVECUSTOMERFile(CVEFile): + re_cve = re.compile(r'^(CVE-\d{4}-(?:\d{4,}|XXXX)|TEMP-\d+-\S+)\s+(.*?)\s*$') + + def isExtend(self, name): + return True + class DSAFile(FileBase): """A DSA file. -- cgit v1.2.3