Ubuntu Pastebin

Paste from ubuntu at Sat, 18 Nov 2017 22:46:17 +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
=== 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-11-18 22:35:12 +0000
@@ -20,6 +20,11 @@
     export_as_webservice_collection,
     export_as_webservice_entry,
     exported,
+    call_with,
+    REQUEST_USER,
+    operation_parameters,
+    operation_for_version,
+    export_factory_operation,
     )
 from lazr.restful.fields import (
     CollectionField,
@@ -191,3 +196,10 @@
 
     def getBugCveCount():
         """Return the number of CVE bug links there is in Launchpad."""
+
+    @call_with(user=REQUEST_USER)
+    @operation_parameters(cve=Reference(ICve, title=_('CVE'), required=True))
+    @export_factory_operation(ICve, [])
+    @operation_for_version("devel")
+    def add(cve, user, check_permissions=True):
+        """Add a new CVE placeholder to the database."""

=== 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-11-18 20:30:31 +0000
@@ -162,12 +162,7 @@
             # not, then create it
             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.")
+                cve = self.addCVEToDatabase(sequence)
             cves.add(cve)
 
         return sorted(cves, key=lambda a: a.sequence)
@@ -219,3 +214,13 @@
         """See ICveSet."""
         return IStore(XRef).find(
             XRef, XRef.from_type == u'bug', XRef.to_type == u'cve').count()
+
+    def addCVEToDatabase(self, sequence):
+        """See ICveSet."""
+        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
Download as text