From 8bb86f743c85829956c79c8163a14884569470f8 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 28 Aug 2025 19:51:08 -0400 Subject: [PATCH] Ready for liftoff --- AirlockTools.py | 41 ++++++++++++++++++++--------------------- allowlistandgroup.py | 2 +- utils/allowlist.py | 8 ++++---- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/AirlockTools.py b/AirlockTools.py index a183683..33a1577 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -134,7 +134,7 @@ def menu_prepare_to_enforce(): second_policy = " " allowlist_parent_name = " " allowlist_child_name = " " - destination_policy = " " + destination_name = " " df_aggregated_combo = pd.DataFrame() #If the directorys where we're going to store our output dont exist, make them. @@ -239,10 +239,10 @@ def menu_prepare_to_enforce(): elif allowlist_parent_name != " " and allowlist_child_name != " " and allowlist_parent_name is not allowlist_child_name: print(ct.colorText(f" [✓] {allowlist_parent_name} has been selected as Parent Policy","green")) print(ct.colorText(f" [✓] {allowlist_child_name} has been selected as Child Policy","green")) - if destination_policy == " ": + if destination_name == " ": print(ct.colorText(f" [✗] No destination_name policy has been chosen","red")) else: - print(ct.colorText(f" [✓] destination_name policy is {destination_policy}","green")) + print(ct.colorText(f" [✓] destination_name policy is {destination_name}","green")) print(ct.colorText(f"6. Liftoff ------------------------------------------------------", "cyan")) print(ct.colorText(f" Apply path exclusions according to allowed and approved paths", "cyan")) @@ -254,16 +254,15 @@ def menu_prepare_to_enforce(): choice = input(ct.colorText("\nEnter your choice: ", "white")) if choice == "1": - first_policy_tuple = utils.allowlist.listPolicies(url) - first_policy = first_policy_tuple[1][first_policy_tuple[0]] + choice, policynames, policyid = utils.allowlist.listPolicies(url) + first_policy = policynames[choice] while True: answer = input(ct.colorText(f"{"Do you want to load a second policy?"} (yes/no): ", "white").strip().lower()) if answer in ("yes", "y"): - second_policy_tuple = utils.allowlist.listPolicies(url) - second_policy = second_policy_tuple[1][second_policy_tuple[0]] + choice, policynames, policyid = utils.allowlist.listPolicies(url) + second_policy = policynames[choice] break elif answer in ("no", "n"): - second_policy_tuple = first_policy_tuple second_policy = first_policy break else: @@ -271,7 +270,7 @@ def menu_prepare_to_enforce(): elif choice == "2": if not os.path.exists(f"dataframe_csv\\executionhist_{first_policy}.csv"): - exe1 = utils.allowlist.pullPolicyExechistories(url,first_policy_tuple[0], first_policy_tuple[1],True) + exe1 = utils.allowlist.pullPolicyExechistories(url,choice, policynames,True) data = json.loads(exe1) executionhist_policy1 = pd.DataFrame(data["response"]["exechistories"]) executionhist_policy1.to_csv(f"dataframe_csv\\executionhist_{first_policy}.csv", index=False) @@ -279,7 +278,7 @@ def menu_prepare_to_enforce(): print(ct.colorText(f"Staging of Execution history for policy: {first_policy} is complete","green")) if not os.path.exists(f"dataframe_csv\\executionhist_{second_policy}.csv"): - exe2 = utils.allowlist.pullPolicyExechistories(url,first_policy_tuple[0], first_policy_tuple[1],True) + exe2 = utils.allowlist.pullPolicyExechistories(url,choice, policynames,True) data2 = json.loads(exe2) executionhist_policy2 = pd.DataFrame(data2["response"]["exechistories"]) executionhist_policy2.to_csv(f"dataframe_csv\\executionhist_{second_policy}.csv", index=False) @@ -373,28 +372,28 @@ def menu_prepare_to_enforce(): ct.style_dataframe_dark(allowbyhash, f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.html") elif choice == "5": - + print(ct.colorText(f"Please choose destination_name Policy for Path Exclusions","white")) - destination_tuple = utils.allowlist.listPolicies(url) + choice, policynames, policyid = utils.allowlist.listPolicies(url) #print(allowlist_parent_tuple) - destination_name = destination_tuple[1][destination_tuple[0]] - destination_id = destination_tuple[0][destination_tuple[0]] + destination_name = policynames[choice] + destination_id = policyid[choice] print(ct.colorText(f"Please choose Parent Allowlist for Known Hashes","white")) - allowlist_parent_tuple = utils.allowlist.listAllowlists(url) + choice, allowlists,allowid = utils.allowlist.listAllowlists(url) #print(allowlist_parent_tuple) - allowlist_parent_name = allowlist_parent_tuple[1][allowlist_parent_tuple[0]] - allowlist_parent_id = allowlist_parent_tuple[1][allowlist_parent_tuple[1]] + allowlist_parent_name = allowlists[choice] + allowlist_parent_id = allowid[choice] print(ct.colorText(f"Please choose Child Allowlist for Less-Known Hashes","white")) - allowlist_child_tuple = utils.allowlist.listAllowlists(url) + choice, allowlists, allowid = utils.allowlist.listAllowlists(url) #print(allowlist_child_tuple) - allowlist_child_name = allowlist_child_tuple[1][allowlist_child_tuple[0]] - allowlist_child_id = allowlist_child_tuple[0][allowlist_child_tuple[0]] + allowlist_child_name = allowlists[choice] + allowlist_child_id = allowid[choice] elif choice == "6": - if os.path.exists(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and allowlist_parent_name != " " and allowlist_child_name != " ": + if os.path.exists(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and allowlist_parent_name != " " and allowlist_child_name != " " and destination_name != " ": pathexclusions = tryToReadCSV(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv") allowbyhash = tryToReadCSV(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") diff --git a/allowlistandgroup.py b/allowlistandgroup.py index c079723..5fcf86f 100644 --- a/allowlistandgroup.py +++ b/allowlistandgroup.py @@ -19,4 +19,4 @@ parse_text = json.loads(response.text) for index, list in enumerate(parse_text['response']['applications'], start=1): if index >= 38: print(list) -#Need else and catch for upper bound \ No newline at end of file +#Need else and catch for upper bound diff --git a/utils/allowlist.py b/utils/allowlist.py index 7325799..5b6b262 100644 --- a/utils/allowlist.py +++ b/utils/allowlist.py @@ -94,7 +94,7 @@ def listPolicies(url): policyids.append(list['groupid']) choice = input(ct.colorText("Select Policy Group: ", "white")) choice = int(choice) - 1 - return choice, policiesnames + return choice, policiesnames, policyids def listAllowlists(url): endpoint = url + '/v1/application' @@ -116,8 +116,8 @@ def listAllowlists(url): if choice < 38: print(ct.colorText("Please only choose an allowlist designed for this use - '38+'","red")) elif choice >= 38: - choice = int(choice) - 38 - return choice, policiesnames + choice = choice - 38 + return choice, policiesnames, policyids #Need else and catch for upper bound @@ -140,5 +140,5 @@ def listCategories(url): choice = input(ct.colorText("Select Policy Group: ", "white")) choice = int(choice) - 1 - return choice, policiesnames + return choice, policiesnames, policyids