From 8eec22f95d18940104459d1093d3bdb48fe52acc Mon Sep 17 00:00:00 2001 From: Jan Rodak Date: Tue, 23 Nov 2021 13:48:04 +0100 Subject: [PATCH 1/2] Fix issue 204 --- oval_graph/arf_xml_parser/_test_info.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oval_graph/arf_xml_parser/_test_info.py b/oval_graph/arf_xml_parser/_test_info.py index eac086f9..30832103 100644 --- a/oval_graph/arf_xml_parser/_test_info.py +++ b/oval_graph/arf_xml_parser/_test_info.py @@ -23,6 +23,8 @@ def _get_oval_system_characteristics(self): @staticmethod def _get_data_by_id(data): + if data is None: + return {} return {item.attrib.get('id'): item for item in data} def _get_collected_objects_by_id(self): @@ -99,6 +101,8 @@ def _get_object_info(self, id_object): def _get_object_items(self, object_, collected_object): out = {} + if object_ is None: + return out for element in object_.iterchildren(): if element.text and element.text.strip(): out[self._get_unique_id_in_dict(element, out)] = element.text @@ -134,6 +138,8 @@ def _collected_object_is_not_none_and_contain_var_ref(element, collected_object) def _get_item(self, item_ref): item = self.system_data.get(item_ref) out = {} + if item is None: + return out for element in item.iterchildren(): if element.text and element.text.strip(): out[self._get_unique_id_in_dict(element, out)] = element.text From 33e227d9ff601a09d6bf50319f2ed18253fd234e Mon Sep 17 00:00:00 2001 From: Jan Rodak Date: Thu, 25 Nov 2021 09:34:00 +0100 Subject: [PATCH 2/2] Create unit test --- .../global_test_data/arf_no_system_data.xml | 291 ++++++++++++++++++ .../test_arf_xml_parser.py | 8 + 2 files changed, 299 insertions(+) create mode 100644 tests_oval_graph/global_test_data/arf_no_system_data.xml diff --git a/tests_oval_graph/global_test_data/arf_no_system_data.xml b/tests_oval_graph/global_test_data/arf_no_system_data.xml new file mode 100644 index 00000000..6a04678c --- /dev/null +++ b/tests_oval_graph/global_test_data/arf_no_system_data.xml @@ -0,0 +1,291 @@ + + + + + collection1 + + + asset0 + + + + + + + + + + + + + + + + + + + + + + 5.11.2 + 2021-02-01T08:07:06+01:00 + + + + + File not found + File fail + + + + + + + + + + + + + + /nonexistent/file/random/nums/0112358132134 + ^0, 1, 1, 2, 3, 5, 8, 13, 21, 34$ + 1 + + + + + + + accepted + 1.0 + + xccdf_test_profile +