=== 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