From 58c1b15907c41d6a32da27c348f6172594ec939e Mon Sep 17 00:00:00 2001 From: Peter Mosmans Date: Fri, 10 Nov 2017 17:06:13 +1000 Subject: [PATCH] Add status attribute for new findings with value new Several docstring changes. --- chatops/python/gitlab-to-pentext.py | 48 ++++++++++------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/chatops/python/gitlab-to-pentext.py b/chatops/python/gitlab-to-pentext.py index b6377dd..1b8b6e1 100644 --- a/chatops/python/gitlab-to-pentext.py +++ b/chatops/python/gitlab-to-pentext.py @@ -64,76 +64,62 @@ class BaseItem(object): @property def filename(self): - """ - Filename. - """ + """Filename.""" return '{0}/{1}.xml'.format(self.__path, valid_filename(self.identifier)) def __str__(self): - """ - Return a XML version of the class - """ + """Return an XML representation of the class.""" return self.DECLARATION + self.root_open + self.element('title') + \ self.content + self.root_close def element(self, attribute): - """ - Return opening and closing attribute tags, including attribute value. - """ + """Return opening and closing attribute tags, including attribute value.""" return '<{0}>{1}\n'.format(attribute, getattr(self, attribute)) def write_file(self): - """ - Write item as XML to file. - """ + """Serialize item to file as XML.""" try: with io.open(self.filename, 'w') as xmlfile: xmlfile.write(unicode(self)) print_line('[+] Wrote {0}'.format(self.filename)) except IOError: - print_error('Could not write to %s', self.filename) + print('Could not write to %s', self.filename, file=sys.stderr) + sys.exit(-1) class Finding(BaseItem): - """ - Encapsulates finding. - """ + """Encapsulates finding.""" def __init__(self): BaseItem.__init__(self, 'finding') self.threat_level = 'Moderate' self.finding_type = 'TODO' + self.status = 'new' self.description = '

TODO

' self.technicaldescription = '

TODO

' self.impact = '

TODO

' self.recommendation = '' def __str__(self): - """ - Return a XML version of the class - """ - self.root_open = '\n'.format(self.identifier, - self.threat_level, - self.finding_type) + """Return an XML representation of the class.""" + self.root_open = '\n'.format(self.identifier, self.threat_level, + self.finding_type, self.status) self.content = self.element('description') + \ - self.element('technicaldescription') + \ - self.element('impact') + \ - self.element('recommendation') + self.element('technicaldescription') + \ + self.element('impact') + \ + self.element('recommendation') return BaseItem.__str__(self) class NonFinding(BaseItem): - """ - Encapsulates non-finding. - """ + """Encapsulates non-finding.""" def __init__(self): BaseItem.__init__(self, 'non-finding') def __str__(self): - """ - Return a XML version of the class - """ + """Return an XML representation of the class.""" self.root_open = '