Total Complexity | 3 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | #!/usr/bin/python2 |
||
2 | |||
3 | # |
||
4 | # create_audit_rules_path_syscall_detailed.py |
||
5 | # generate template-based checks for changes to a path via syscalls |
||
6 | |||
7 | |||
8 | from template_common import FilesGenerator, UnknownTargetError |
||
9 | |||
10 | import re |
||
11 | |||
12 | class AuditRulesPathSyscallGenerator(FilesGenerator): |
||
13 | def generate(self, target, args): |
||
14 | path,syscall = args[0:2] |
||
15 | pathid = re.sub('[-\./]', '_', path) |
||
16 | # remove root slash made into '_' |
||
17 | pathid = pathid[1:] |
||
18 | if target == "oval": |
||
19 | self.file_from_template( |
||
20 | "./template_OVAL_audit_rules_path_syscall", |
||
21 | { |
||
22 | "PATH": path, |
||
23 | "PATHID": pathid, |
||
24 | "SYSCALL": syscall |
||
25 | }, |
||
26 | "./oval/audit_rules_{0}_{1}.xml", pathid, syscall |
||
27 | ) |
||
28 | else: |
||
29 | raise UnknownTargetError(target) |
||
30 | |||
31 | def csv_format(self): |
||
32 | return("CSV should contains lines of the format: " + |
||
33 | "PATH,SYSCALL") |
||
34 |