1 |
commit: 98f8a4a8f5c38dfb3c797ad8d66f8cac1822805d |
2 |
Author: Aaron Bauman <bman <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Aug 14 18:05:00 2019 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 19 01:03:15 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=98f8a4a8 |
7 |
|
8 |
portage/glsa.py: only check for revision based on GLSA DTD |
9 |
|
10 |
* All GLSA's have been converted to use the revision attribute |
11 |
* If there is no count attribute then raise a GlsaFormatException |
12 |
* Ensure the attribute is an integer |
13 |
|
14 |
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org> |
15 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
16 |
|
17 |
lib/portage/glsa.py | 15 +++++---------- |
18 |
lib/portage/tests/glsa/test_security_set.py | 2 +- |
19 |
2 files changed, 6 insertions(+), 11 deletions(-) |
20 |
|
21 |
diff --git a/lib/portage/glsa.py b/lib/portage/glsa.py |
22 |
index ccf93439d..3fd877b22 100644 |
23 |
--- a/lib/portage/glsa.py |
24 |
+++ b/lib/portage/glsa.py |
25 |
@@ -528,25 +528,20 @@ class Glsa: |
26 |
self.synopsis = getText(myroot.getElementsByTagName("synopsis")[0], format="strip") |
27 |
self.announced = format_date(getText(myroot.getElementsByTagName("announced")[0], format="strip")) |
28 |
|
29 |
- # Support both formats of revised: |
30 |
- # <revised>December 30, 2007: 02</revised> |
31 |
+ # Support only format defined in GLSA DTD |
32 |
# <revised count="2">2007-12-30</revised> |
33 |
revisedEl = myroot.getElementsByTagName("revised")[0] |
34 |
self.revised = getText(revisedEl, format="strip") |
35 |
count = revisedEl.getAttribute("count") |
36 |
if not count: |
37 |
- if self.revised.find(":") >= 0: |
38 |
- (self.revised, count) = self.revised.split(":") |
39 |
- else: |
40 |
- count = 1 |
41 |
- |
42 |
- self.revised = format_date(self.revised) |
43 |
+ raise GlsaFormatException("Count attribute is missing or blank in GLSA: " + myroot.getAttribute("id")) |
44 |
|
45 |
try: |
46 |
self.count = int(count) |
47 |
except ValueError: |
48 |
- # TODO should this raise a GlsaFormatException? |
49 |
- self.count = 1 |
50 |
+ raise GlsaFormatException("Revision attribute in GLSA: " + myroot.getAttribute("id") + " is not an integer") |
51 |
+ |
52 |
+ self.revised = format_date(self.revised) |
53 |
|
54 |
# now the optional and 0-n toplevel, #PCDATA tags and references |
55 |
try: |
56 |
|
57 |
diff --git a/lib/portage/tests/glsa/test_security_set.py b/lib/portage/tests/glsa/test_security_set.py |
58 |
index e73deaba9..a602f83d4 100644 |
59 |
--- a/lib/portage/tests/glsa/test_security_set.py |
60 |
+++ b/lib/portage/tests/glsa/test_security_set.py |
61 |
@@ -24,7 +24,7 @@ class SecuritySetTestCase(TestCase): |
62 |
</synopsis> |
63 |
<product type="ebuild">%(pkgname)s</product> |
64 |
<announced>January 18, 2013</announced> |
65 |
- <revised>January 18, 2013: 1</revised> |
66 |
+ <revised count="1">January 18, 2013</revised> |
67 |
<bug>55555</bug> |
68 |
<access>remote</access> |
69 |
<affected> |