From c7b26f171bb8c9d8a907e7d3ae7c95934610111e Mon Sep 17 00:00:00 2001 From: = <=> Date: Mon, 25 Aug 2025 11:09:14 -0400 Subject: [PATCH] Approval logic draft 1 --- AirlockTools.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/AirlockTools.py b/AirlockTools.py index 4ad9e9f..3684d37 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -121,7 +121,7 @@ def menu_prepare_to_enforce(): #If the directorys where we're going to store our output dont exist, make them. if not os.path.exists("dataframe_html"): os.makedirs("dataframe_html") if not os.path.exists("dataframe_csv"): os.makedirs("dataframe_csv") - if not os.path.exists("approvals"): os.makedirs("approvals") + if not os.path.exists("manuallyapproved"): os.makedirs("approvals") df_aggregated_combo = pd.DataFrame() while True: @@ -177,14 +177,25 @@ def menu_prepare_to_enforce(): print(ct.colorText(" [✓] This step has been completed","green")) else: print(ct.colorText(" [✗] This step has not been completed","red")) - + + print(ct.colorText(f"7. Manually review the files \\dataframe_csv\\df_hashes_needing_approval_{first_policy}_{second_policy}.csv and dataframe_csv\\df_automatically_approved_hashes_{first_policy}_{second_policy}.csv", "cyan")) + print(ct.colorText(" Remove the rows containing hashes you do not approve of, and those you would not approve of without metarules.", "cyan")) + print(ct.colorText(" If metarules need to be created, please make note of them, and remove the row from the csv.", "cyan")) + print(ct.colorText(" When complete, move both csv files to the directory 'manuallyapproved' and choose this option to combine these approved hashes with the automatically approved hashes", "cyan")) + + if os.path.isfile(f"dataframe_csv\\df_all_approved_hashes_{first_policy}_{second_policy}.csv"): + print(ct.colorText(" [✓] This step has been completed","green")) + else: + print(ct.colorText(" [✗] This step has not been completed","red")) + + """ print(ct.colorText("7. Compare potential path exclusions with allowed hashes", "cyan")) if os.path.exists(f"dataframe_csv\\df_allowed_paths_{first_policy}_{second_policy}.csv") == True: print(ct.colorText(" [✓] This step has been completed","green")) else: print(ct.colorText(" [✗] This step has not been completed","red")) - + """ print(ct.colorText("Q. Quit", "cyan")) @@ -268,6 +279,14 @@ def menu_prepare_to_enforce(): else: print(ct.colorText(f"Please Augment your data with hash threat info using step 4 prior to attempting this step","red")) + elif choice == "7": + if os.path.isfile(f"manuallyapproved\\df_hashes_needing_approval_{first_policy}_{second_policy}.csv"): + df1 = tryToReadCSV(f"manuallyapproved\\df_hashes_needing_approval_{first_policy}_{second_policy}.csv") + df2 = tryToReadCSV(f"manuallyapproved\\df_automatically_approved_hashes_{first_policy}_{second_policy}.csv") + df_all_approved_hashes = pd.concat([df1 , df2], ignore_index=True) + df_aggregated_combo.to_html(f"dataframe_html\\df_all_approved_hashes_{first_policy}_{second_policy}.html", index=False) + df_aggregated_combo.to_csv(f"dataframe_csv\\df_all_approved_hashes_{first_policy}_{second_policy}.csv", index=False) + """ elif choice == "7": if os.path.exists(f"dataframe_csv\\df_hashes_needing_approval_{first_policy}_{second_policy}.csv") and os.path.exists(f"dataframe_csv\\df_automatically_approved_hashes_{first_policy}_{second_policy}.csv") and os.path.exists(f"dataframe_csv\\df_unapproved_hashes__{first_policy}_{second_policy}.csv"): allowpaths = utils.allowfunctions.filter_and_drop(pd.read_csv(f"dataframe_csv\\df_automatically_approved_hashes_{first_policy}_{second_policy}.csv"),tryToReadCSV(f"dataframe_csv\\df_path_eligible_{first_policy}_{second_policy}.csv"), path_exclusion_constant) @@ -276,7 +295,8 @@ def menu_prepare_to_enforce(): print(ct.colorText(f"Allowable paths determined","green")) else: print(ct.colorText(f"Please complete step 6 prior to attempting this step","red")) - + """ + elif choice == "Q": break -- 2.34.1