diff --git a/ansible_risk_insight/cli/__init__.py b/ansible_risk_insight/cli/__init__.py index ab88e5ff..599c71f1 100644 --- a/ansible_risk_insight/cli/__init__.py +++ b/ansible_risk_insight/cli/__init__.py @@ -240,7 +240,7 @@ def run(self): temp_file_path = '' for j in range(1, len(nodes)): node_rules = nodes[j]['rules'] - for k in reversed(range(len(node_rules))): # loop through from rule 11, as that has the mutation + for k in reversed(range(len(node_rules))): # loop through from rule 11, as that has the mutation w007_rule = node_rules[k] if (w007_rule['rule']['rule_id']).lower() == 'w007': if not w007_rule.get('verdict') and w007_rule: @@ -259,7 +259,7 @@ def run(self): temp_file_path = target_file_path else: target_file_path = os.path.join(args.target_name, temp_data) - if temp_file_path != '' and target_file_path != temp_file_path: + if temp_file_path != '' and target_file_path != temp_file_path: update_the_yaml_target(target_file_path, line_number_list, mutated_yaml_list) line_number_list = [] mutated_yaml_list = [] diff --git a/ansible_risk_insight/finder.py b/ansible_risk_insight/finder.py index 2518c31d..db2fecd7 100644 --- a/ansible_risk_insight/finder.py +++ b/ansible_risk_insight/finder.py @@ -780,8 +780,8 @@ def check_diff_and_copy_olddata_to_newdata(line_number_list, lines, new_data): if line_number_list and isinstance(line_number_list, list): new_content_last_set = line_number_list[-1] new_content_last_line = int(new_content_last_set.lstrip("L").split("-")[1]) - if new_content_last_line < len(lines)-1: - for i in range(new_content_last_line, len(lines)-1): + if new_content_last_line < len(lines) - 1: + for i in range(new_content_last_line, len(lines) - 1): new_data.append(lines[i]) return new_data @@ -877,7 +877,7 @@ def update_the_yaml_target(file_path, line_number_list, new_content_list): break else: return IndexError("Line number out of range.") - # check for diff b/w new content and old contents, + # check for diff b/w new content and old contents, # and copy the old content that's not updated by ARI mutation data_copy = check_diff_and_copy_olddata_to_newdata(line_number_list, lines, data_copy) # Join the lines back to a single string