Ubuntu Pastebin

Paste from ubuntu at Sun, 1 Oct 2017 04:06:45 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
=== modified file 'lib/lp/bugs/interfaces/cve.py'
--- lib/lp/bugs/interfaces/cve.py	2015-10-15 14:09:50 +0000
+++ lib/lp/bugs/interfaces/cve.py	2017-10-01 03:50:29 +0000
@@ -139,7 +139,11 @@
     title = Attribute('Title')
 
     def __getitem__(key):
-        """Get a Cve by sequence number."""
+        """Get a Cve by sequence number.
+
+        It will create any CVE's that it sees which are already not in the
+        database.
+        """
 
     def __iter__():
         """Iterate through all the Cve records."""
@@ -166,9 +170,8 @@
         """Find one or more Cve's by analysing the given text.
 
         This will look for references to CVE or CAN numbers, and return the
-        CVE references. It will create any CVE's that it sees which are
-        already not in the database. It returns the list of all the CVE's it
-        found in the text.
+        CVE references. It returns the list of all the CVE's it found in the
+        text.
         """
 
     def inMessage(msg):

=== modified file 'lib/lp/bugs/model/cve.py'
--- lib/lp/bugs/model/cve.py	2017-05-31 17:31:58 +0000
+++ lib/lp/bugs/model/cve.py	2017-10-01 03:50:29 +0000
@@ -118,11 +118,19 @@
         """See ICveSet."""
         if sequence[:4] in ['CVE-', 'CAN-']:
             sequence = sequence[4:]
-        if not valid_cve(sequence):
-            return None
-        try:
-            return Cve.bySequence(sequence)
-        except SQLObjectNotFound:
+        if valid_cve(sequence):
+            try:
+                return Cve.bySequence(sequence)
+            # if the CVE is not in the db, since it's valid, put it there
+            except SQLObjectNotFound:
+                cve = Cve(sequence=sequence, status=CveStatus.DEPRECATED,
+                    description="This CVE was automatically created from "
+                    "a reference found in an email or other text. If you "
+                    "are reading this, then this CVE entry is probably "
+                    "erroneous, since this text should be replaced by "
+                    "the official CVE description automatically.")
+                return(cve)
+        else:
             return None
 
     def getAll(self):
@@ -158,16 +166,8 @@
         for match in CVEREF_PATTERN.finditer(text):
             # let's get the core CVE data
             sequence = match.group(2)
-            # see if there is already a matching CVE ref in the db, and if
-            # not, then create it
+            # make sure it's in the db
             cve = self[sequence]
-            if cve is None:
-                cve = Cve(sequence=sequence, status=CveStatus.DEPRECATED,
-                    description="This CVE was automatically created from "
-                    "a reference found in an email or other text. If you "
-                    "are reading this, then this CVE entry is probably "
-                    "erroneous, since this text should be replaced by "
-                    "the official CVE description automatically.")
             cves.add(cve)
 
         return sorted(cves, key=lambda a: a.sequence)
Download as text