Passed
Pull Request — master (#3179)
by Matěj
02:26
created

ssg_test_suite.profile.ProfileChecker._test_target()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python2
2
from __future__ import print_function
3
4
import logging
5
6
7
import ssg_test_suite.oscap
8
import ssg_test_suite.virt
9
from ssg_test_suite.rule import get_viable_profiles
10
11
logging.getLogger(__name__).addHandler(logging.NullHandler())
12
13
14
class ProfileChecker(ssg_test_suite.oscap.Checker):
15
    """
16
    Iterate over profiles in datastream and perform scanning of unaltered system
17
    using every profile according to input. Also perform remediation run.
18
    Return value not defined, textual output and generated reports is the result.
19
    """
20
    def _test_target(self, target):
21
        profiles = get_viable_profiles(
22
            target, self.datastream, self.benchmark_id)
23
        self._test_by_profiles(profiles)
24
25
    def _run_test(self, profile, ** run_test_args):
26
        logging.info("Evaluation of profile {0}.".format(profile))
27
        self.executed_tests += 1
28
29
        runner_cls = ssg_test_suite.oscap.REMEDIATION_PROFILE_RUNNERS[self.remediate_using]
30
        runner = runner_cls(
31
            self.test_env.domain_ip, profile, self.datastream, self.benchmark_id)
32
33
        for stage in ("initial", "remediation", "final"):
34
            result = runner.run_stage(stage)
35
36
37
def perform_profile_check(options):
38
    checker = ProfileChecker(options.test_env)
39
40
    checker.datastream = options.datastream
41
    checker.benchmark_id = options.benchmark_id
42
    checker.remediate_using = options.remediate_using
43
44
    checker.test_target(options.target)
45