Fixed some logic, added functions to list allowlist, and category. Category list function will need work, the subcategories are not being parsed at this time
This commit is contained in:
+21
-18
@@ -132,8 +132,8 @@ def menu_prepare_to_enforce():
|
||||
|
||||
first_policy = " "
|
||||
second_policy = " "
|
||||
parentpolicy = " "
|
||||
childpolicy = " "
|
||||
parentallowlist = " "
|
||||
childallowlist = " "
|
||||
df_aggregated_combo = pd.DataFrame()
|
||||
|
||||
#If the directorys where we're going to store our output dont exist, make them.
|
||||
@@ -231,13 +231,13 @@ def menu_prepare_to_enforce():
|
||||
print(ct.colorText(" [✗] Preflight hash approval list has not been generated","red"))
|
||||
|
||||
print(ct.colorText(f"5. Choose the destination parent and child policy allow list", "cyan"))
|
||||
if childpolicy == " " and parentpolicy == " ":
|
||||
if childallowlist == " " and parentallowlist == " ":
|
||||
print(ct.colorText(f" [✗] No policies have been chosen","red"))
|
||||
elif parentpolicy != " " and childpolicy != " " and parentpolicy is childpolicy:
|
||||
print(ct.colorText(f" [✓] [✗] Only {parentpolicy} has been selected this is unusual, but potentially valid case, double check before proceeding,", "yellow"))
|
||||
elif parentpolicy != " " and childpolicy != " " and parentpolicy is not childpolicy:
|
||||
print(ct.colorText(f" [✓] {parentpolicy} has been selected as Parent Policy","green"))
|
||||
print(ct.colorText(f" [✓] {childpolicy} has been selected as Child Policy","green"))
|
||||
elif parentallowlist != " " and childallowlist != " " and parentallowlist is childallowlist:
|
||||
print(ct.colorText(f" [✓] [✗] Only {parentallowlist} has been selected this is unusual, but potentially valid case, double check before proceeding,", "yellow"))
|
||||
elif parentallowlist != " " and childallowlist != " " and parentallowlist is not childallowlist:
|
||||
print(ct.colorText(f" [✓] {parentallowlist} has been selected as Parent Policy","green"))
|
||||
print(ct.colorText(f" [✓] {childallowlist} has been selected as Child Policy","green"))
|
||||
|
||||
print(ct.colorText(f"6. Liftoff ------------------------------------------------------", "cyan"))
|
||||
print(ct.colorText(f" Apply path exclusions according to allowed and approved paths", "cyan"))
|
||||
@@ -369,14 +369,17 @@ def menu_prepare_to_enforce():
|
||||
|
||||
elif choice == "5":
|
||||
|
||||
parent_policy_tuple = utils.allowlist.listPolicies(url)
|
||||
parentpolicy = parent_policy_tuple[1][parent_policy_tuple[0]]
|
||||
print(ct.colorText(f"Please choose Parent Allowlist","white"))
|
||||
allowlist_parent_tuple = utils.allowlist.listAllowlists(url)
|
||||
allowlist_parent = allowlist_parent_tuple[1][allowlist_parent_tuple[0]]
|
||||
|
||||
|
||||
child_policy_tuple = utils.allowlist.listPolicies(url)
|
||||
childpolicy = child_policy_tuple[1][child_policy_tuple[0]]
|
||||
print(ct.colorText(f"Please choose Child Allowlist","white"))
|
||||
allowlist_child_tuple = utils.allowlist.listAllowlists(url)
|
||||
allowlist_child = allowlist_child_tuple[1][allowlist_child_tuple[0]]
|
||||
|
||||
elif choice == "6":
|
||||
if os.path.exists(f"preflight\\final_pathexclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and parentpolicy != " " and childpolicy != " ":
|
||||
if os.path.exists(f"preflight\\final_pathexclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and parentallowlist != " " and childallowlist != " ":
|
||||
|
||||
pathexclusions = tryToReadCSV(f"preflight\\final_pathexclusions_{first_policy}_{second_policy}.csv")
|
||||
allowbyhash = tryToReadCSV(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv")
|
||||
@@ -393,13 +396,13 @@ def menu_prepare_to_enforce():
|
||||
print(ct.colorText("Proceeding with the code...", "yellow"))
|
||||
|
||||
pathexcludelist = pathexclusions['longestcfp'].unique().tolist
|
||||
utils.policyfunctions.addPath(childpolicy,pathexcludelist)
|
||||
utils.policyfunctions.addPath(childallowlist,pathexcludelist)
|
||||
|
||||
parentpolicyhashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['target_column'].tolist()
|
||||
utils.policyfunctions.addHash(parentpolicy,parentpolicyhashlist)
|
||||
parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['target_column'].tolist()
|
||||
utils.policyfunctions.addHash(parentallowlist,parentallowlisthashlist)
|
||||
|
||||
childpolicyhashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['target_column'].tolist()
|
||||
utils.policyfunctions.addHash(childpolicy,childpolicyhashlist)
|
||||
childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['target_column'].tolist()
|
||||
utils.policyfunctions.addHash(childallowlist,childallowlisthashlist)
|
||||
|
||||
else:
|
||||
print(ct.colorText("Operation aborted. You MUST EXPLICITLY AGREE to proceed.", "red"))
|
||||
|
||||
Reference in New Issue
Block a user