| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | # Copyright 2022, Red Hat, Inc. |
||
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
||
| 3 | |||
| 4 | 1 | from ..data_structures import Report |
|
| 5 | 1 | from ..namespaces import NAMESPACES |
|
| 6 | 1 | from .profile_info_parser import ProfileInfoParser |
|
| 7 | 1 | from .scan_result_parser import ScanResultParser |
|
| 8 | |||
| 9 | |||
| 10 | 1 | class ReportParser: |
|
| 11 | 1 | def __init__(self, root, test_results_el, benchmark_el): |
|
| 12 | 1 | self.root = root |
|
| 13 | 1 | self.test_results_el = test_results_el |
|
| 14 | 1 | self.benchmark_el = benchmark_el |
|
| 15 | 1 | self.profiles_info_elements = { |
|
| 16 | profile.get("id"): profile |
||
| 17 | for profile in self.root.findall('.//xccdf:Profile', NAMESPACES) |
||
| 18 | } |
||
| 19 | |||
| 20 | 1 | def get_report(self): |
|
| 21 | 1 | scan_result_parser = ScanResultParser(self.test_results_el, self.root) |
|
| 22 | 1 | scan_result = scan_result_parser.get_test_result() |
|
| 23 | 1 | profile_info_parser = ProfileInfoParser( |
|
| 24 | self.profiles_info_elements, scan_result.cpe_platforms, self.benchmark_el |
||
| 25 | ) |
||
| 26 | 1 | profile_info = profile_info_parser.get_profile_info(scan_result.profile_id) |
|
| 27 | return Report(scan_result=scan_result, profile_info=profile_info) |
||
| 28 |