ComplianceAsCode/content

View on GitHub
shared/templates/audit_rules_file_deletion_events/template.py

Summary

Maintainability
C
1 day
Test Coverage
Similar blocks of code found in 2 locations. Consider refactoring.
def _audit_rules_file_deletion_events(data, lang):
Similar blocks of code found in 2 locations. Consider refactoring.
if lang == "bash":
Similar blocks of code found in 2 locations. Consider refactoring.
if "syscall_grouping" in data:
Similar blocks of code found in 2 locations. Consider refactoring.
# Make it easier to tranform the syscall_grouping into a Bash array
Similar blocks of code found in 2 locations. Consider refactoring.
data["syscall_grouping"] = " ".join(data["syscall_grouping"])
Similar blocks of code found in 2 locations. Consider refactoring.
elif lang == "ansible":
Similar blocks of code found in 2 locations. Consider refactoring.
if "name" in data:
Similar blocks of code found in 2 locations. Consider refactoring.
# Tranform the syscall into a Ansible list
Similar blocks of code found in 2 locations. Consider refactoring.
# The syscall is under 'name'
Similar blocks of code found in 2 locations. Consider refactoring.
data["name"] = [data["name"]]
Similar blocks of code found in 2 locations. Consider refactoring.
if "syscall_grouping" not in data:
Similar blocks of code found in 2 locations. Consider refactoring.
# Ensure that syscall_grouping is a list
Similar blocks of code found in 2 locations. Consider refactoring.
data["syscall_grouping"] = []
Similar blocks of code found in 2 locations. Consider refactoring.
return data
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
 
Similar blocks of code found in 2 locations. Consider refactoring.
def preprocess(data, lang):
Similar blocks of code found in 2 locations. Consider refactoring.
return _audit_rules_file_deletion_events(data, lang)