Test Failed
Push — master ( f41b3f...0bcc33 )
by Matěj
03:22 queued 37s
created

ssg.build_stig   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 28
ccs 6
cts 18
cp 0.3333
rs 10
c 0
b 0
f 0
wmc 5

1 Function

Rating   Name   Duplication   Size   Complexity  
A map_versions_to_rule_ids() 0 18 5
1 2
from __future__ import absolute_import
2 2
from __future__ import print_function
3
4 2
import sys
5
6 2
from .xml import ElementTree as ET
7 2
from .constants import XCCDF11_NS
8
9
10 2
def map_versions_to_rule_ids(reference_file_name):
11
    try:
12
        reference_root = ET.parse(reference_file_name)
13
    except IOError:
14
        print(
15
            "INFO: DISA STIG Reference file not found for this platform: %s" %
16
            reference_file_name)
17
        sys.exit(0)
18
19
    reference_rules = reference_root.findall('.//{%s}Rule' % XCCDF11_NS)
20
21
    dictionary = {}
22
23
    for rule in reference_rules:
24
        version = rule.find('.//{%s}version' % XCCDF11_NS)
25
        if version is not None and version.text:
26
            dictionary[version.text] = rule.get('id')
27
    return dictionary
28