changeset 1:d47e1164740f

Add support for AggregateSeverity
author Benoît Allard <benoit.allard@greenbone.net>
date Wed, 24 Sep 2014 08:26:56 +0200
parents e18b61a73a68
children 5d81cea79583
files farolluz/cvrf.py farolluz/parsers/cvrf.py farolluz/templates/cvrf.j2
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/farolluz/cvrf.py	Tue Sep 23 15:19:14 2014 +0200
+++ b/farolluz/cvrf.py	Wed Sep 24 08:26:56 2014 +0200
@@ -200,6 +200,14 @@
         return self._note
 
 
+class CVRFAggregateSeverity(object):
+    def __init__(self, severity):
+        self._severity = severity
+        self._namespace = None
+
+    def setNamespace(self, namespace):
+        self._namespace = namespace
+
 class CVRFReference(object):
     TYPES = ('Self', 'External')
     def __init__(self, url, description, _type=None):
@@ -885,6 +893,7 @@
         self._tracking = None
         self._notes = []
         self._distribution = None
+        self._aggregateseverity = None
         self._references = []
         self._acknowledgments = []
         self._producttree = None
@@ -902,6 +911,9 @@
     def setDistribution(self, distribution):
         self._distribution = distribution
 
+    def setAggregateSeverity(self, aggregateseverity):
+        self._aggregateseverity = aggregateseverity
+
     def addReference(self, ref):
         self._references.append(ref)
 
--- a/farolluz/parsers/cvrf.py	Tue Sep 23 15:19:14 2014 +0200
+++ b/farolluz/parsers/cvrf.py	Wed Sep 24 08:26:56 2014 +0200
@@ -42,7 +42,7 @@
     CVRFAcknowledgment, CVRFProductBranch, CVRFFullProductName, CVRFGenerator,
     CVRFRelationship, CVRFVulnerability, CVRFVulnerabilityID, CVRFThreat,
     CVRFProductStatus, CVRFCVSSSet, CVRFReference, CVRFRemediation, CVRFGroup,
-    CVRFInvolvement, CVRFCWE, CVRFTrackingID)
+    CVRFInvolvement, CVRFCWE, CVRFTrackingID, CVRFAggregateSeverity)
 
 NAMESPACES = {
     'cvrf': "http://www.icasi.org/CVRF/schema/cvrf/1.1",
@@ -298,6 +298,11 @@
 
     # This is in a quite free format, not sure how to do something with it ...
     xmlaggsev = cvrfdoc.find(UN('cvrf', 'AggregateSeverity'))
+    if xmlaggsev is not None:
+        aggsev = CVRFAggregateSeverity(xmlaggsev.text.strip())
+        if 'Namespace' in xmlaggsev.attrib:
+            aggsev.setNamespace(xmlaggsev.attrib['Namespace'])
+        doc.setAggregateSeverity(aggsev)
 
     for xmlref in cvrfdoc.findall('/'.join([UN('cvrf', 'DocumentReferences'), UN('cvrf', 'Reference')])):
         doc.addReference(parseReference(xmlref))
--- a/farolluz/templates/cvrf.j2	Tue Sep 23 15:19:14 2014 +0200
+++ b/farolluz/templates/cvrf.j2	Wed Sep 24 08:26:56 2014 +0200
@@ -99,7 +99,11 @@
   {%- if cvrf._distribution %}
   <DocumentDistribution>{{ cvrf._distribution }}</DocumentDistribution>
   {%- endif %}
-  {#- AggregateSeverity is missing #}
+  {%- if cvrf._aggregateseverity %}
+  <AggregateSeverity{{ {'Namespace': cvrf._aggregateseverity._namespace} | xmlattr }}>
+    {{- cvrf._aggregateseverity._severity -}}
+  </AggregateSeverity>
+  {%- endif %}
   {%- if cvrf._references %}
   <DocumentReferences>
     {%- for reference in cvrf._references %}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)