Passed
Push — master ( 037321...720596 )
by Marek
02:38
created

create_audit_rules_unsuccessful_file_modification_detailed   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ARUFMDetailedGenerator.generate() 0 26 2
A ARUFMDetailedGenerator.csv_format() 0 3 1
1
#!/usr/bin/python2
2
3
#
4
# create_audit_rules_unsuccessful_file_modification_detailed.py
5
#        generate template-based checks for unsuccessful file modifications detailed
6
#            - audit_rules_unsuccessful_file_modification_syscall_o_creat
7
#            - audit_rules_unsuccessful_file_modification_syscall_o_trunc_write
8
#            - audit_rules_unsuccessful_file_modification_syscall_rule_order
9
10
11
from template_common import FilesGenerator, UnknownTargetError
12
13
import re
14
15
class ARUFMDetailedGenerator(FilesGenerator):
16
    def generate(self, target, args):
17
        syscall = re.sub('[-\./]', '_', args[0])
18
        if target == "oval":
19
            self.file_from_template(
20
                "./template_OVAL_audit_rules_unsuccessful_file_modification_o_creat",
21
                {
22
                    "SYSCALL":	syscall
23
                },
24
                "./oval/audit_rules_unsuccessful_file_modification_{0}_o_creat.xml", syscall
25
            )
26
            self.file_from_template(
27
                "./template_OVAL_audit_rules_unsuccessful_file_modification_o_trunc_write",
28
                {
29
                    "SYSCALL":	syscall
30
                },
31
                "./oval/audit_rules_unsuccessful_file_modification_{0}_o_trunc_write.xml", syscall
32
            )
33
            self.file_from_template(
34
                "./template_OVAL_audit_rules_unsuccessful_file_modification_rule_order",
35
                {
36
                    "SYSCALL":	syscall
37
                },
38
                "./oval/audit_rules_unsuccessful_file_modification_{0}_rule_order.xml", syscall
39
            )
40
        else:
41
            raise UnknownTargetError(target)
42
43
    def csv_format(self):
44
        return("CSV should contains lines of the format: " +
45
               "SYSCALL")
46