Ready for liftoff
This commit is contained in:
+19
-20
@@ -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)
|
||||
@@ -375,26 +374,26 @@ def menu_prepare_to_enforce():
|
||||
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")
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user