openscap_report.scap_results_parser.data_structures.remediation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 93.75%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 44
ccs 15
cts 16
cp 0.9375
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Remediation.get_type() 0 11 1
A Remediation.as_dict() 0 2 1
1
# Copyright 2022, Red Hat, Inc.
2
# SPDX-License-Identifier: LGPL-2.1-or-later
3
4 1
from openscap_report.dataclasses import asdict, dataclass
5
6 1
REMEDIATION_JSON_KEYS = [
7
    "remediation_id",
8
    "system",
9
    "complexity",
10
    "disruption",
11
    "strategy",
12
    "fix",
13
]
14
15 1
HIDDEN_REMEDIATION_TYPES = [
16
    "urn:redhat:anaconda:pre",
17
    "urn:xccdf:fix:script:kickstart",
18
]
19
20
21 1
@dataclass
22 1
class Remediation:
23 1
    remediation_id: str
24 1
    system: str = ""
25 1
    complexity: str = ""
26 1
    disruption: str = ""
27 1
    strategy: str = ""
28 1
    fix: str = ""
29
30 1
    def as_dict(self):
31
        return asdict(self)
32
33 1
    def get_type(self):
34 1
        script_types = {
35
            "urn:xccdf:fix:script:sh": "Shell script",
36
            "urn:xccdf:fix:script:ansible": "Ansible snippet",
37
            "urn:xccdf:fix:script:puppet": "Puppet snippet",
38
            "urn:redhat:anaconda:pre": "Anaconda snippet",
39
            "urn:xccdf:fix:script:kubernetes": "Kubernetes snippet",
40
            "urn:redhat:osbuild:blueprint": "OSBuild Blueprint snippet",
41
            "urn:xccdf:fix:script:kickstart": "Kickstart snippet",
42
        }
43
        return script_types.get(self.system, "script")
44