You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2015/07/31 10:49:12 UTC
svn commit: r1693543 - in /subversion/trunk/tools/dist/security: adviser.py
parser.py
Author: brane
Date: Fri Jul 31 08:49:12 2015
New Revision: 1693543
URL: http://svn.apache.org/r1693543
Log:
Minor tweaks to the tools/dist/security module.
* tools/dist/security/parser.py
(Notification.Metadata): Tweak docstring.
(Notification.Metadata.__init__): Put attributes into the private namespace.
(Notification.Metadata.tracking_id,
Notification.Metadata.title,
Notification.Metadata.culprit,
Notification.Metadata.advisory,
Notification.Metadata.patches): New accessor properties.
(__Part.text): New property; replaces __Part.get_text().
(__Part.quoted_printable): New property; replaces __Part.get_quoted_printable().
(__Part.base64): New property; replaces __Part.get_base64().
(Text): Renamed from Advisory.
(Patch.__init__): Put the base version into the private namespace.
(Patch.base_version): New accessor property.
(Patch.quoted_printable): New property; replaces __Part.get_quoted_printable().
* tools/dist/security/adviser.py
(__write_advisory): Update Notification property access.
Modified:
subversion/trunk/tools/dist/security/adviser.py
subversion/trunk/tools/dist/security/parser.py
Modified: subversion/trunk/tools/dist/security/adviser.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dist/security/adviser.py?rev=1693543&r1=1693542&r2=1693543&view=diff
==============================================================================
--- subversion/trunk/tools/dist/security/adviser.py (original)
+++ subversion/trunk/tools/dist/security/adviser.py Fri Jul 31 08:49:12 2015
@@ -33,16 +33,16 @@ def __write_advisory(metadata, fd):
by METADATA and write it to the file descriptor FD.
"""
- fd.write(metadata.advisory.get_text())
+ fd.write(metadata.advisory.text)
if not metadata.patches:
return
fd.write('\nPatches:'
'\n========\n')
for patch in metadata.patches:
- fd.write('\n Patch against ' + patch.base_version + ':\n'
+ fd.write('\n Patch for Subversion ' + patch.base_version + ':\n'
'[[[\n')
- fd.write(patch.get_text())
+ fd.write(patch.text)
fd.write(']]]\n')
def generate(notification, target_dir):
Modified: subversion/trunk/tools/dist/security/parser.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dist/security/parser.py?rev=1693543&r1=1693542&r2=1693543&view=diff
==============================================================================
--- subversion/trunk/tools/dist/security/parser.py (original)
+++ subversion/trunk/tools/dist/security/parser.py Fri Jul 31 08:49:12 2015
@@ -37,11 +37,11 @@ class Notification(object):
class Metadata(object):
"""
- The metadata for one advisory, with the following fields:
+ The metadata for one advisory, with the following properties:
tracking_id - the CVE/CAN number
title - a short description of the issue
culprit - server, client or both
- advisory - an Advisory object
+ advisory - a Text object with the text of the advisory
patches - a list of Patch objects, sorted in descending
order by the base version
"""
@@ -61,17 +61,38 @@ class Notification(object):
if not isinstance(culprit, tuple):
culprit = (culprit,)
- self.tracking_id = tracking_id
- self.title = title
- self.culprit = frozenset(culprit)
- self.advisory = Advisory(os.path.join(basedir, advisory))
- self.patches = []
+ self.__tracking_id = tracking_id
+ self.__title = title
+ self.__culprit = frozenset(culprit)
+ self.__advisory = Text(os.path.join(basedir, advisory))
+ self.__patches = []
for base_version, patchfile in patches.items():
patch = Patch(base_version, os.path.join(basedir, patchfile))
- self.patches.append(patch)
- self.patches.sort(reverse=True,
- key=lambda x: tuple(
- int(q) for q in x.base_version.split('.')))
+ self.__patches.append(patch)
+ self.__patches.sort(reverse=True,
+ key=lambda x: tuple(
+ int(q) for q in x.base_version.split('.')))
+
+ @property
+ def tracking_id(self):
+ return self.__tracking_id
+
+ @property
+ def title(self):
+ return self.__title
+
+ @property
+ def culprit(self):
+ return self.__culprit
+
+ @property
+ def advisory(self):
+ return self.__advisory
+
+ @property
+ def patches(self):
+ return tuple(self.__patches)
+
def __init__(self, rootdir, *tracking_ids):
"""
@@ -127,14 +148,16 @@ class __Part(object):
return b''.join(text)
- def get_text(self):
+ @property
+ def text(self):
"""
Return the raw contents.
"""
return self.__text.decode('UTF-8')
- def get_quoted_printable(self):
+ @property
+ def quoted_printable(self):
"""
Return contents encoded as quoted-printable.
"""
@@ -142,7 +165,9 @@ class __Part(object):
return quopri.encodestring(self.__text).decode('ascii')
BASE64_LINE_LENGTH = 64
- def get_base64(self):
+
+ @property
+ def base64(self):
"""
Return multi-line Base64-encoded contents with the lenght
of the lines limited to BASE64_LINE_LENGTH.
@@ -161,7 +186,7 @@ class __Part(object):
return b''.join(text).decode('ascii')
-class Advisory(__Part):
+class Text(__Part):
"""
In-memory container for the text of the advisory.
"""
@@ -178,7 +203,12 @@ class Patch(__Part):
def __init__(self, base_version, path):
super(Patch, self).__init__(path)
- self.base_version = base_version
+ self.__base_version = base_version
+
+ @property
+ def base_version(self):
+ return self.__base_version
- def get_quoted_printable(self):
+ @property
+ def quoted_printable(self):
raise NotImplementedError('Quoted-printable patches? Really?')