ComplianceAsCode/content

View on GitHub

Showing 238 of 1,093 total issues

Function __init__ has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def __init__(self, rule, cis_ns):
self.id = rule.get("id")
self.oval = rule.find('./{%s}check[@system="%s"]' % (XCCDF12_NS, oval_ns))
self.sce = rule.find('./{%s}check[@system="%s"]' % (XCCDF12_NS, sce_ns))
self.bash_fix = rule.find('./{%s}fix[@system="%s"]' % (XCCDF12_NS, bash_rem_system))
Severity: Minor
Found in ssg/build_profile.py - About 25 mins to fix

Function filter_rule_ids has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def filter_rule_ids(all_keys, queries):
"""
Filters a set of keys based on a set of queries.
 
A set of queries is a comma separated list of queries, where a query is either a rule id or
Severity: Minor
Found in ssg/rule_dir_stats.py - About 25 mins to fix

Function join_text_elements has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def join_text_elements(self):
"""
Collects and concatenates text from relevant subelements of the root element.
 
This function iterates over the subelements of the root element, collects their text,
Severity: Minor
Found in ssg/xml.py - About 25 mins to fix

Function added_variables has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def added_variables(self):
variables = set()
for task in self.tasks_data:
if "tags" not in task:
next
Severity: Minor
Found in utils/ansible_playbook_to_role.py - About 25 mins to fix

Function main has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def main():
args = parse_args()
 
input_path, input_basename, path_base, output_dir = \
ssg.build_guides.get_path_args(args)
Severity: Minor
Found in build-scripts/build_all_guides.py - About 25 mins to fix

Function _get_rules_in_profile has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def _get_rules_in_profile(built_profiles_root) -> Generator[str, None, None]:
for profile_file in built_profiles_root.iterdir(): # type: pathlib.Path
if not profile_file.name.endswith(".profile"):
continue
profile_data = ssg.yaml.open_raw(str(profile_file.absolute()))
Severity: Minor
Found in build-scripts/build_tests.py - About 25 mins to fix

Function file has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def file(self, filepath):
if filepath == 'tasks/main.yml':
return self.tasks_local_content
elif filepath == 'vars/main.yml':
if len(self.vars_data) < 1:
Severity: Minor
Found in utils/ansible_playbook_to_role.py - About 25 mins to fix

Function product_names_remediation has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def product_names_remediation(rule_obj, r_type):
"""
Checks the consistency between the scope of platforms and the product names of the
remediations of a given type for a rule object.
 
 
Severity: Minor
Found in ssg/rule_dir_stats.py - About 25 mins to fix

Function product_names_oval has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def product_names_oval(rule_obj):
"""
Checks the consistency between the product names and OVAL object names for a given rule object.
 
Args:
Severity: Minor
Found in ssg/rule_dir_stats.py - About 25 mins to fix

Function get_variable_options has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def get_variable_options(content_dir: str, variable_id: str = None) -> dict_type:
"""
Retrieve the options for specific or all variables from the content root directory.
 
If `variable_id` is provided, returns options for that variable only.
Severity: Minor
Found in ssg/variables.py - About 25 mins to fix

Function resolve has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def resolve(self, all_profiles, rules_by_id, controls_manager=None):
if self.resolved:
return
 
if controls_manager:
Severity: Minor
Found in ssg/entities/profile.py - About 25 mins to fix

Function is_virtual_oscap_profile has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def is_virtual_oscap_profile(profile):
""" Test if the profile belongs to the so called category virtual
from OpenSCAP available profiles. It can be (all) or other id we
might come up in the future, it just needs to be encapsulated
with parenthesis for example "(custom_profile)".
Severity: Minor
Found in tests/ssg_test_suite/oscap.py - About 25 mins to fix

Function has_empty_identifier has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def has_empty_identifier(rule_path, rule, rule_lines):
if 'identifiers' in rule and rule['identifiers'] is None:
return True
 
if 'identifiers' in rule and rule['identifiers'] is not None:
Severity: Minor
Found in utils/fix_rules.py - About 25 mins to fix

Function preprocess has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def preprocess(data, lang):
path = data["path"]
name = ssg.utils.escape_id(os.path.basename(path))
data["name"] = name
if lang == "oval":
Severity: Minor
Found in shared/templates/audit_rules_privileged_commands/template.py - About 25 mins to fix

Function _audit_rules_file_deletion_events has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def _audit_rules_file_deletion_events(data, lang):
if lang == "bash":
if "syscall_grouping" in data:
# Make it easier to tranform the syscall_grouping into a Bash array
data["syscall_grouping"] = " ".join(data["syscall_grouping"])
Severity: Minor
Found in shared/templates/audit_rules_file_deletion_events/template.py - About 25 mins to fix

Function _run_test has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def _run_test(self, profile, test_data):
scenario = test_data["scenario"]
rule_id = test_data["rule_id"]
remediation_available = test_data["remediation_available"]
 
 
Severity: Minor
Found in tests/ssg_test_suite/rule.py - About 25 mins to fix

Function _audit_rules_unsuccessful_file_modification has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def _audit_rules_unsuccessful_file_modification(data, lang):
if lang == "bash":
if "syscall_grouping" in data:
# Make it easier to tranform the syscall_grouping into a Bash array
data["syscall_grouping"] = " ".join(data["syscall_grouping"])
Severity: Minor
Found in shared/templates/audit_rules_unsuccessful_file_modification/template.py - About 25 mins to fix

Function preprocess has a Cognitive Complexity of 8 (exceeds 7 allowed). Consider refactoring.
Open

def preprocess(data, lang):
 
embedded_data = parse_template_boolean_value(data, parameter="embedded_data", default_value=False)
data["embedded_data"] = embedded_data
 
 
Severity: Minor
Found in shared/templates/yamlfile_value/template.py - About 25 mins to fix
Severity
Category
Status
Source
Language