openscap_report.scap_results_parser.parsers.report_parser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 28
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ReportParser.__init__() 0 7 1
A ReportParser.get_report() 0 8 1
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