Gentoo Archives: gentoo-portage-dev

From: Aaron Bauman <bman@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Aaron Bauman <bman@g.o>
Subject: [gentoo-portage-dev] [PATCH v3] portage/glsa.py: only check for revision based on GLSA DTD
Date: Wed, 14 Aug 2019 18:05:06
Message-Id: 20190814180500.793827-1-bman@gentoo.org
1 * All GLSA's have been converted to use the revision attribute
2 * If there is no count attribute then raise a GlsaFormatException
3 * Ensure the attribute is an integer
4
5 Signed-off-by: Aaron Bauman <bman@g.o>
6 ---
7 lib/portage/glsa.py | 15 +++++----------
8 1 file changed, 5 insertions(+), 10 deletions(-)
9
10 diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py
11 index ccf93439d..3fd877b22 100644
12 --- a/lib/portage/glsa.py
13 +++ b/lib/portage/glsa.py
14 @@ -528,25 +528,20 @@ class Glsa:
15 self.synopsis = getText(myroot.getElementsByTagName("synopsis")[0], format="strip")
16 self.announced = format_date(getText(myroot.getElementsByTagName("announced")[0], format="strip"))
17
18 - # Support both formats of revised:
19 - # <revised>December 30, 2007: 02</revised>
20 + # Support only format defined in GLSA DTD
21 # <revised count="2">2007-12-30</revised>
22 revisedEl = myroot.getElementsByTagName("revised")[0]
23 self.revised = getText(revisedEl, format="strip")
24 count = revisedEl.getAttribute("count")
25 if not count:
26 - if self.revised.find(":") >= 0:
27 - (self.revised, count) = self.revised.split(":")
28 - else:
29 - count = 1
30 -
31 - self.revised = format_date(self.revised)
32 + raise GlsaFormatException("Count attribute is missing or blank in GLSA: " + myroot.getAttribute("id"))
33
34 try:
35 self.count = int(count)
36 except ValueError:
37 - # TODO should this raise a GlsaFormatException?
38 - self.count = 1
39 + raise GlsaFormatException("Revision attribute in GLSA: " + myroot.getAttribute("id") + " is not an integer")
40 +
41 + self.revised = format_date(self.revised)
42
43 # now the optional and 0-n toplevel, #PCDATA tags and references
44 try:
45 --
46 2.22.1

Replies