[PATCH 12 of 54] Add some missing elements in the CVRF generation

Wald Commits scm-commit at wald.intevation.org
Wed Jan 7 10:56:29 CET 2015


# HG changeset patch
# User Benoît Allard <benoit.allard at greenbone.net>
# Date 1412765205 -7200
# Node ID 91d2a97f8bb4448fa928cdbcb3b54b7c2766cb54
# Parent  7998a57c9b48da4337f97d6e93c304e3513740a6
Add some missing elements in the CVRF generation

diff -r 7998a57c9b48 -r 91d2a97f8bb4 farolluz/templates/cvrf.j2
--- a/farolluz/templates/cvrf.j2	Wed Oct 08 12:45:19 2014 +0200
+++ b/farolluz/templates/cvrf.j2	Wed Oct 08 12:46:45 2014 +0200
@@ -25,7 +25,7 @@
 
 <?xml version="1.0" encoding="utf-8"?>
 
-{#- Some macros for producttree generation #}
+{#- A macro for producttree generation #}
 {%- macro FullProductNames(producttree, parent) %}
   {%- for product in producttree._products %}
     {%- if product._parent is sameas parent %}
@@ -36,11 +36,37 @@
   {%- endfor %}
 {%- endmacro %}
 
+{#- Some macros about more generic types #}
 {%- macro Note(note) -%}
   <Note{{ {'Type': note._type, 'Ordinal': note._ordinal, 'Title': note._title, 'Audience': note._audience} | xmlattr }}>
     {{- note._note | escape -}}
   </Note>
-{%- endmacro %}
+{%- endmacro -%}
+
+{%- macro Reference(reference) -%}
+  <Reference{{ {'Type': reference._type} | xmlattr }}>
+    <URL>{{ reference._url }}</URL>
+    <Description>{{ reference._description }}</Description>
+  </Reference>
+{%- endmacro -%}
+
+{%- macro Acknowledgment(acknowledgment) -%}
+  <Acknowledgment>
+    {%- for name in acknowledgment._names %}
+    <Name>{{ name }}</Name>
+    {%- endfor %}
+    {%- for organization in acknowledgment._organizations %}
+    <Organization>{{ organization }}</Organization>
+    {%- endfor %}
+    {%- if acknowledgment._description %}
+    <Description>{{ acknowledgment._description }}</Description>
+    {%- endif %}
+    {%- if acknowledgment._url %}
+    <URL>{{ acknowledgment._url }}</URL>
+    {%- endif %}
+  </Acknowledgment>
+{%- endmacro -%}
+
 <cvrfdoc xmlns="http://www.icasi.org/CVRF/schema/cvrf/1.1">
   <DocumentTitle>{{ cvrf._title }}</DocumentTitle>
   <DocumentType>{{ cvrf._type }}</DocumentType>
@@ -107,30 +133,14 @@
   {%- if cvrf._references %}
   <DocumentReferences>
     {%- for reference in cvrf._references %}
-    <Reference{{ {'Type': reference._type} | xmlattr }}>
-      <URL>{{ reference._url }}</URL>
-      <Description>{{ reference._description }}</Description>
-    </Reference>
+    {{ Reference(reference) }}
     {%- endfor %}
   </DocumentReferences>
   {%- endif %}
   {%- if cvrf._acknowledgments %}
   <Acknowledgments>
     {%- for acknowledgment in cvrf._acknowledgments %}
-    <Acknowledgment>
-      {%- for name in acknowledgment._names %}
-      <Name>{{ name }}</Name>
-      {%- endfor %}
-      {%- for organization in acknowledgment._organizations %}
-      <Organization>{{ organization }}</Organization>
-      {%- endfor %}
-      {%- if acknowledgment._description %}
-      <Description>{{ acknowledgment._description }}</Description>
-      {%- endif %}
-      {%- if acknowledgment._url %}
-      <URL>{{ acknowledgment._url }}</URL>
-      {%- endif %}
-    </Acknowledgment>
+    {{ Acknowledgment(acknowledgment) }}
     {%- endfor %}
   </Acknowledgments>
   {%- endif %}
@@ -215,6 +225,21 @@
       {%- endfor %}
     </ProductStatuses>
     {%- endif %}
+    {%- if vulnerability._threats %}
+    <Threats>
+      {%- for threat in vulnerability._threats %}
+      <Threat Type="{{ threat._type }}"{{ ' Date="%s"' % threat._date.isoformat() if threat._date }}>
+        <Description>{{ threat._description }}</Description>
+        {%- for productid in threat._productids %}
+        <ProductID>{{ productid }}</ProductID>
+        {%- endfor %}
+        {%- for groupid in threat._groupids %}
+        <GroupID>{{ groupid }}</GroupID>
+        {%- endfor %}
+      </Threat>
+      {%- endfor %}
+    </Threats>
+    {%- endif %}
     {%- if vulnerability._cvsss %}
     <CVSSScoreSets>
       {%- for cvss in vulnerability._cvsss %}
@@ -230,7 +255,7 @@
         <Vector>{{ cvss._vector }}</Vector>
         {%- endif %}
         {%- for productid in cvss._productids %}
-        <ProductID>{{productid}}</ProductID>
+        <ProductID>{{ productid }}</ProductID>
         {%- endfor %}
       </ScoreSet>
       {%- endfor %}
@@ -257,6 +282,20 @@
       {%- endfor %}
     </Remediations>
     {%- endif %}
+    {%- if vulnerability._references %}
+    <References>
+      {%- for reference in vulnerability._references %}
+      {{ Reference(reference) }}
+      {%- endfor %}
+    </References>
+    {%- endif %}
+    {%- if vulnerability._acknowledgments %}
+    <Acknowledgments>
+      {%- for acknowledgment in vulnerability._acknowledgments %}
+      {{ Acknowledgment(acknowledgment) }}
+      {%- endfor %}
+    </Acknowledgments>
+    {%- endif %}
   </Vulnerability>
   {%- endfor %}
 </cvrfdoc>


More information about the Farol-commits mailing list