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] portage/glsa.py: only check for revisions based on GLSA DTD
Date: Tue, 13 Aug 2019 21:19:35
Message-Id: 20190813211929.307869-1-bman@gentoo.org
1 * All GLSA's have been converted to use the revision attribute
2 * Only check that the revision attribute is populated which defaults to 1 from
3 tooling (e.g. GLSAMaker)
4 * If there is no count attribute then raise a GlsaFormatException
5 * Remove 'try' logic as we already check if the attribute is populated
6 * We only check if the attribute is populated. Whether it is an int or not is
7 not a concern as it is only significant to security team.
8
9 Signed-off-by: Aaron Bauman <bman@g.o>
10 ---
11 lib/portage/glsa.py | 14 ++------------
12 1 file changed, 2 insertions(+), 12 deletions(-)
13
14 diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py
15 index ccf93439d..f0ce34f3f 100644
16 --- a/lib/portage/glsa.py
17 +++ b/lib/portage/glsa.py
18 @@ -528,26 +528,16 @@ class Glsa:
19 self.synopsis = getText(myroot.getElementsByTagName("synopsis")[0], format="strip")
20 self.announced = format_date(getText(myroot.getElementsByTagName("announced")[0], format="strip"))
21
22 - # Support both formats of revised:
23 - # <revised>December 30, 2007: 02</revised>
24 + # Support only format defined in GLSA DTD
25 # <revised count="2">2007-12-30</revised>
26 revisedEl = myroot.getElementsByTagName("revised")[0]
27 self.revised = getText(revisedEl, format="strip")
28 count = revisedEl.getAttribute("count")
29 if not count:
30 - if self.revised.find(":") >= 0:
31 - (self.revised, count) = self.revised.split(":")
32 - else:
33 - count = 1
34 + raise GlsaFormatException("Invalid revision attribute in GLSA: " + myroot.getAttribute("id"))
35
36 self.revised = format_date(self.revised)
37
38 - try:
39 - self.count = int(count)
40 - except ValueError:
41 - # TODO should this raise a GlsaFormatException?
42 - self.count = 1
43 -
44 # now the optional and 0-n toplevel, #PCDATA tags and references
45 try:
46 self.access = getText(myroot.getElementsByTagName("access")[0], format="strip")
47 --
48 2.22.0