From 6df74f79690c46da706915c9ca203ea0d7a6e215 Mon Sep 17 00:00:00 2001 From: Justin Bollinger Date: Mon, 16 Mar 2026 14:32:14 -0400 Subject: [PATCH] fix: use os.path.join for rule paths in quick_crack and loopback_attack Replace 6 instances of f-string slash concatenation with os.path.join() for building rule file paths, consistent with get_rule_path() in main.py. --- hate_crack/attacks.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hate_crack/attacks.py b/hate_crack/attacks.py index 711417b..72fdabf 100644 --- a/hate_crack/attacks.py +++ b/hate_crack/attacks.py @@ -138,7 +138,7 @@ def quick_crack(ctx: Any) -> None: return if "98" in rule_choice: for rule in rule_files: - selected_hcatRules.append(f"-r {ctx.rulesDirectory}/{rule}") + selected_hcatRules.append(f"-r {os.path.join(ctx.rulesDirectory, rule)}") elif "0" in rule_choice: selected_hcatRules = [""] else: @@ -148,15 +148,15 @@ def quick_crack(ctx: Any) -> None: choices = choice.split("+") for rule in choices: try: - combined_choice = f"{combined_choice} -r {ctx.rulesDirectory}/{rule_files[int(rule) - 1]}" + rule_path = os.path.join(ctx.rulesDirectory, rule_files[int(rule) - 1]) + combined_choice = f"{combined_choice} -r {rule_path}" except Exception: continue selected_hcatRules.append(combined_choice) else: try: - selected_hcatRules.append( - f"-r {ctx.rulesDirectory}/{rule_files[int(choice) - 1]}" - ) + rule_path = os.path.join(ctx.rulesDirectory, rule_files[int(choice) - 1]) + selected_hcatRules.append(f"-r {rule_path}") except IndexError: continue @@ -229,7 +229,7 @@ def loopback_attack(ctx: Any) -> None: return if "98" in rule_choice: for rule in rule_files: - selected_hcatRules.append(f"-r {ctx.rulesDirectory}/{rule}") + selected_hcatRules.append(f"-r {os.path.join(ctx.rulesDirectory, rule)}") elif "0" in rule_choice: selected_hcatRules = [""] else: @@ -239,15 +239,15 @@ def loopback_attack(ctx: Any) -> None: choices = choice.split("+") for rule in choices: try: - combined_choice = f"{combined_choice} -r {ctx.rulesDirectory}/{rule_files[int(rule) - 1]}" + rule_path = os.path.join(ctx.rulesDirectory, rule_files[int(rule) - 1]) + combined_choice = f"{combined_choice} -r {rule_path}" except Exception: continue selected_hcatRules.append(combined_choice) else: try: - selected_hcatRules.append( - f"-r {ctx.rulesDirectory}/{rule_files[int(choice) - 1]}" - ) + rule_path = os.path.join(ctx.rulesDirectory, rule_files[int(choice) - 1]) + selected_hcatRules.append(f"-r {rule_path}") except IndexError: continue