-
Notifications
You must be signed in to change notification settings - Fork 4
/
document_publisher.py
33 lines (28 loc) · 1.2 KB
/
document_publisher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
""" Module containing DocumentPublisher class """
from ..common.common import SectionHandler
# pylint: disable=too-few-public-methods
class DocumentPublisher(SectionHandler):
""" Responsible for converting the DocumentPublisher section:
- /cvrf:cvrfdoc/cvrf:DocumentPublisher
"""
type_category_mapping = {
'Vendor': 'vendor',
'Coordinator': 'coordinator',
'User': 'user',
'Discoverer': 'discoverer',
'Other': 'other',
}
def __init__(self, config):
super().__init__()
self.name = config.get('publisher_name')
self.namespace = config.get('publisher_namespace')
def _process_mandatory_elements(self, root_element):
self.csaf['name'] = self.name
self.csaf['namespace'] = self.namespace
self.csaf['category'] = self.type_category_mapping[root_element.attrib['Type']]
def _process_optional_elements(self, root_element):
# optional values
if hasattr(root_element, 'ContactDetails'):
self.csaf['contact_details'] = root_element.ContactDetails.text
if hasattr(root_element, 'IssuingAuthority'):
self.csaf['issuing_authority'] = root_element.IssuingAuthority.text