Bugfixes + QOL
This commit is contained in:
+60
-142
@@ -187,179 +187,97 @@ def displayIntro():
|
||||
|
||||
def printEnforceChecklist(selected_policies, destination_policy, destination_allowlist):
|
||||
working_dir = load_env("WORKING_DIR")
|
||||
print(
|
||||
colorText(
|
||||
"\n --------------------------------------------------------------------",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" ------------- 🛠️ 🔒 Prepare to Enforce Policy 🛠️ 🔒 ------------------",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" --------------------------------------------------------------------",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
"\nSequentually follow these steps to prepare a policy for enforcement:",
|
||||
"white",
|
||||
)
|
||||
)
|
||||
|
||||
print(
|
||||
colorText(
|
||||
"\n1. Choose which originating policy or policies to move to enforcement",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
def section_header(title):
|
||||
print(colorText("\n --------------------------------------------------------------------", "cyan"))
|
||||
print(colorText(f" ------------- {title} -------------", "cyan"))
|
||||
print(colorText(" --------------------------------------------------------------------", "cyan"))
|
||||
|
||||
section_header("🛠️ 🔒 Prepare to Enforce Policy 🛠️ 🔒")
|
||||
print(colorText("\nSequentially follow these steps to prepare a policy for enforcement:", "white"))
|
||||
|
||||
# Step 1: Originating Policies
|
||||
print(colorText("\n1. Choose which originating policy or policies to move to enforcement", "cyan"))
|
||||
if not selected_policies:
|
||||
print(colorText(" [✗] No policies have been chosen", "red"))
|
||||
else:
|
||||
print(colorText("The following policies have been choosen:", "green"))
|
||||
print(colorText("The following policies have been chosen:", "green"))
|
||||
for policy in selected_policies:
|
||||
print(colorText(f" [✓] {policy.name}", "green"))
|
||||
|
||||
print(colorText("2. Choose the destination policy and allowlist", "cyan"))
|
||||
|
||||
if not destination_policy:
|
||||
print(colorText(" [✗] No destination policy has been chosen", "red"))
|
||||
elif destination_policy:
|
||||
# Step 2: Destination Policy and Allowlist
|
||||
print(colorText("2. Choose the destination policy and allowlist", "cyan"))
|
||||
if destination_policy:
|
||||
print(colorText(f" [✓] {destination_policy[0].name} has been selected as the destination policy", "green"))
|
||||
else:
|
||||
print(colorText(" [✗] No destination policy has been chosen", "red"))
|
||||
|
||||
|
||||
|
||||
if not destination_allowlist:
|
||||
if destination_allowlist:
|
||||
print(colorText(f" [✓] {destination_allowlist[0].name} has been selected as allowlist", "green"))
|
||||
else:
|
||||
print(colorText(" [✗] No allowlist has been chosen", "red"))
|
||||
elif destination_allowlist:
|
||||
print(
|
||||
colorText(
|
||||
f" [✓] {destination_allowlist[0].name} has been selected as allowlist",
|
||||
"green",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
print(
|
||||
colorText(
|
||||
"3. Pull and stage event history, combine the histories, add hash info, then categorize the hashes",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
if not selected_policies:
|
||||
print(colorText(" [✗] No policies have been chosen", "red"))
|
||||
# Step 3: Data Preparation
|
||||
print(colorText("3. Pull and stage event history, combine the histories, add hash info, then categorize the hashes", "cyan"))
|
||||
if selected_policies:
|
||||
policy_id = selected_policies[0].name
|
||||
review_path = f"{working_dir}\\Needs_Review\\Review_First\\{policy_id}_approved_executions.csv"
|
||||
print(colorText(" [✓] Data has been fetched" if os.path.exists(review_path) else " [✗] Data has not been fetched", "green" if os.path.exists(review_path) else "red"))
|
||||
else:
|
||||
if os.path.exists(f"{working_dir}\\Needs_Review\\Review_First\\approved_executions.csv"):
|
||||
print(colorText(" [✓] Data has been fetched", "green"))
|
||||
else:
|
||||
print(colorText(" [✗] Data has not been fetched", "red"))
|
||||
print(colorText(" [✗] No policies selected, cannot check data fetch status", "red"))
|
||||
|
||||
# Step 4: Manual Review
|
||||
print(colorText("4. Manually review the files:", "cyan"))
|
||||
print(
|
||||
colorText(
|
||||
" 'prepare_policy\\needs_approved\\good_hashes.csv' and 'prepare_policy\\needs_approved\\unknown_hashes.csv'\n",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" Remove the rows containing hashes you do not approve of, and those you would not approve of without metarules.",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" If metarules need to be created, please make note of them, and remove the row from the csv.",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" When complete, save both csv files to the directory 'approved' and choose this option.",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" This will combine these approved hashes with the automatically approved hashes and generate a list of paths to be reviewed",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
|
||||
if os.path.exists(f"{working_dir}\\Approved\\approved_executions.csv"):
|
||||
print(colorText(" [✓] Reviewed hashes have been loaded", "green"))
|
||||
if selected_policies:
|
||||
policy_id = selected_policies[0].name
|
||||
print(colorText(f" 'prepare_policy\\needs_approved\\good_hashes.csv' and 'prepare_policy\\needs_approved\\{policy_id}_unknown_hashes.csv'\n", "cyan"))
|
||||
else:
|
||||
print(colorText(" [✗] Reviewed hashes have not been loaded", "red"))
|
||||
print(colorText(" 'prepare_policy\\needs_approved\\good_hashes.csv' and 'prepare_policy\\needs_approved\\<policy>_unknown_hashes.csv'\n", "cyan"))
|
||||
|
||||
if os.path.exists(
|
||||
f"{working_dir}\\Needs_Review\\Review_Second\\primary_Paths.csv",
|
||||
):
|
||||
print(colorText(" [✓] Path review list created", "green"))
|
||||
print(colorText(" Remove the rows containing hashes you do not approve of...", "cyan"))
|
||||
print(colorText(" When complete, save both csv files to the directory 'approved' and choose this option.", "cyan"))
|
||||
print(colorText(" This will combine these approved hashes with the automatically approved hashes and generate a list of paths to be reviewed", "cyan"))
|
||||
|
||||
if selected_policies:
|
||||
policy_id = selected_policies[0].name
|
||||
approved_path = f"{working_dir}\\Approved\\{policy_id}_approved_executions.csv"
|
||||
second_review_path = f"{working_dir}\\Needs_Review\\Review_Second\\{policy_id}_primary_Paths.csv"
|
||||
print(colorText(" [✓] Reviewed hashes have been loaded" if os.path.exists(approved_path) else " [✗] Reviewed hashes have not been loaded", "green" if os.path.exists(approved_path) else "red"))
|
||||
print(colorText(" [✓] Path review list created" if os.path.exists(second_review_path) else " [✗] Path review list has not been created", "green" if os.path.exists(second_review_path) else "red"))
|
||||
else:
|
||||
print(colorText(" [✗] Path review list has not been created", "red"))
|
||||
print(colorText(" [✗] No policies selected, cannot check reviewed hashes or path list", "red"))
|
||||
|
||||
print(
|
||||
colorText(
|
||||
"5. Manually review the files \n 'prepare_policy\\needs_approved\\primary_Paths.csv'\n 'prepare_policy\\needs_approved\\secondary_Paths.csv'",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(
|
||||
colorText(
|
||||
" Remove the rows containing path exclusions you do not approve of. The secondary list can be not added at all if nothing is useful",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
# Step 5: Path Review
|
||||
print(colorText("5. Manually review the files \n 'prepare_policy\\needs_approved\\primary_Paths.csv'\n 'prepare_policy\\needs_approved\\secondary_Paths.csv'", "cyan"))
|
||||
print(colorText(" Remove the rows containing path exclusions you do not approve of...", "cyan"))
|
||||
print(colorText(" When complete, save the csv file to the directory 'approved'", "cyan"))
|
||||
print(
|
||||
colorText(
|
||||
" Do the same process with the list of publishers forthe same directories",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(colorText(" Do the same process with the list of publishers for the same directories", "cyan"))
|
||||
print(colorText(" Preflight Lists will be generated", "cyan"))
|
||||
|
||||
if os.path.exists(
|
||||
f"{working_dir}\\Approved\\primary_Paths.csv",
|
||||
):
|
||||
print(colorText(" [✓] Reviewed path list detected", "green"))
|
||||
if selected_policies:
|
||||
policy_id = selected_policies[0].name
|
||||
reviewed_path = f"{working_dir}\\Approved\\{policy_id}_primary_Paths.csv"
|
||||
preflight_paths = f"{working_dir}\\Preflight\\{policy_id}_approved_paths.csv"
|
||||
preflight_hashes = f"{working_dir}\\Preflight\\{policy_id}_approved_hashes.csv"
|
||||
print(colorText(" [✓] Reviewed path list detected" if os.path.exists(reviewed_path) else " [✗] Path review list has not been detected", "green" if os.path.exists(reviewed_path) else "red"))
|
||||
preflight_ready = os.path.exists(preflight_paths) and os.path.exists(preflight_hashes)
|
||||
print(colorText(" [✓] Preflight Path Exclusion List has been generated" if preflight_ready else " [✗] Preflight Path Exclusion List has not been generated", "green" if preflight_ready else "red"))
|
||||
else:
|
||||
print(colorText(" [✗] Path review list has not been detected", "red"))
|
||||
|
||||
if os.path.exists(f"{working_dir}\\Preflight\\approved_paths.csv") and os.path.exists(
|
||||
f"{working_dir}\\Preflight\\approved_hashes.csv"
|
||||
):
|
||||
print(colorText(" [✓] Preflight Path Exclusion List has been generated", "green"))
|
||||
else:
|
||||
print(colorText(" [✗] Preflight Path Exclusion List has not been generated", "red"))
|
||||
print(colorText(" [✗] No policies selected, cannot check preflight status", "red"))
|
||||
|
||||
# Final Steps
|
||||
print(colorText("6. Test ------------------------------------------------------", "cyan"))
|
||||
print(colorText(" Print rather than apply selected data.", "cyan"))
|
||||
|
||||
print(colorText("7. Liftoff ------------------------------------------------------", "cyan"))
|
||||
print(
|
||||
colorText(
|
||||
" Apply path exclusions according to allowed and approved paths",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
print(colorText(" Apply path exclusions according to allowed and approved paths", "cyan"))
|
||||
print(colorText(" Apply signed or attested hashes to Parent Allow List", "cyan"))
|
||||
print(colorText(" Apply approved, but unsigned hashes to the Child Allow List", "cyan"))
|
||||
|
||||
print(
|
||||
colorText(
|
||||
"R. Remove/Reset Generated data - will prompt to allow keeping execution history",
|
||||
"cyan",
|
||||
)
|
||||
)
|
||||
# Utility Options
|
||||
print(colorText("R. Remove/Reset Generated data - will prompt to allow keeping execution history", "cyan"))
|
||||
print(colorText("F. 📂 - Open Working Directory", "cyan"))
|
||||
print(colorText("Q. 🔚 - Quit", "cyan"))
|
||||
print(colorText("B. 🔚 - Back", "cyan"))
|
||||
|
||||
|
||||
def areYouSure():
|
||||
|
||||
Reference in New Issue
Block a user