| Total Complexity | 3 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |