File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
tests/test_data/postgresql Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,9 @@ def to_advisories(data):
9999 # in the prior code, this is the only place where cve_id was defined, and presumably
100100 # there was no error like the error we got:
101101 # UnboundLocalError: local variable 'cve_id' referenced before assignment
102- cve_id = ref_col .select ("nobr" )[0 ].text
102+
103+ # changed from nobr to .nobr due to html changes
104+ cve_id = ref_col .select (".nobr" )[0 ].text
103105 # This is for the anomaly in https://www.postgresql.org/support/security/8.1/ 's
104106 # last entry
105107 except IndexError :
@@ -142,7 +144,7 @@ def to_advisories(data):
142144
143145
144146def find_advisory_urls (page_data ):
145- soup = BeautifulSoup (page_data )
147+ soup = BeautifulSoup (page_data , features = "lxml" )
146148 return {
147149 urlparse .urljoin ("https://www.postgresql.org/" , a_tag .attrs ["href" ])
148150 for a_tag in soup .select ("h3+ p a" )
Original file line number Diff line number Diff line change @@ -324,6 +324,20 @@ def get_or_create_from_purl(self, purl: PackageURL):
324324 ``purl`` PackageURL.
325325 """
326326 purl_fields = without_empty_values (purl .to_dict (encode = True ))
327+
328+ # when there are 2 packages one with qualifiers and one without
329+ # qualifiers, having all other fields same, this raises MultipleObjectsReturned
330+ # so we are filling out the fields with empty value to avoid this
331+ for field in PackageURL ._fields :
332+ # name, type, and version are required fields
333+ if field not in purl_fields :
334+ if field == "namespace" :
335+ purl_fields [field ] = ""
336+ if field == "qualifiers" :
337+ purl_fields [field ] = {}
338+ if field == "subpath" :
339+ purl_fields [field ] = ""
340+
327341 package , _ = Package .objects .get_or_create (** purl_fields )
328342 return package
329343
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ <h2>Known security issues in all supported versions</h2>
109109
110110 < tr >
111111 < td >
112- < nobr > < a href ="/support/security/CVE-2020-10733/ "> CVE-2020-10733</ a > </ nobr > < br >
112+ < a href ="/support/security/CVE-2020-10733/ " class =" nobr " > CVE-2020-10733</ a > < br >
113113 < a href ="/about/news/postgresql-123-118-1013-9618-and-9522-released-2038/ "> Announcement</ a > < br >
114114 </ td >
115115 < td > 12, 11, 10, 9.6</ td >
@@ -122,7 +122,7 @@ <h2>Known security issues in all supported versions</h2>
122122
123123 < tr >
124124 < td >
125- < nobr > < a href ="/support/security/CVE-2020-1720/ "> CVE-2020-1720</ a > </ nobr > < br >
125+ < a href ="/support/security/CVE-2020-1720/ " class =" nobr " > CVE-2020-1720</ a > < br >
126126 < a href ="/about/news/postgresql-122-117-1012-9617-9521-and-9426-released-2011/ "> Announcement</ a > < br >
127127 </ td >
128128 < td > 12, 11, 10, 9.6</ td >
You can’t perform that action at this time.
0 commit comments