File: create_kernel_modules_disabled.py

package info (click to toggle)
scap-security-guide 0.1.39-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 31,836 kB
  • sloc: xml: 129,736; python: 7,462; sh: 3,796; makefile: 27
file content (46 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#
# create_kernel_modules_disabled.py
#   automatically generate checks for disabled kernel modules

from template_common import FilesGenerator, UnknownTargetError


class KernelModulesDisabledGenerator(FilesGenerator):
    def generate(self, target, kerninfo):
        # get the items out of the list
        kernmod = kerninfo[0]

        if target == "bash":
            self.file_from_template(
                "./template_BASH_kernel_module_disabled",
                {
                   "%KERNMODULE%": kernmod
                },
                "./bash/kernel_module_{0}_disabled.sh", kernmod
            )

        elif target == "oval":
            self.file_from_template(
                "./template_OVAL_kernel_module_disabled",
                {
                    "%KERNMODULE%": kernmod
                },
                "./oval/kernel_module_{0}_disabled.xml", kernmod
            )

        elif target == "ansible":
            self.file_from_template(
                "./template_ANSIBLE_kernel_module_disabled",
                {
                   "%KERNMODULE%": kernmod
                },
                "./ansible/kernel_module_{0}_disabled.yml", kernmod
            )

        else:
            raise UnknownTargetError(target)

    def csv_format(self):
        return (
            "CSV file should contains lines of the format: kernmod"
        )