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