Fixed several logic issues / generation of secondary paths. Cleaned up Policy Prep text to be accurate to current functionality. Fixed issue with going back from policy prep menu. Switched to logging.dict from standard logging config.
This commit is contained in:
+19
-8
@@ -41,6 +41,7 @@ from utils.utils import (
|
||||
get_sanitized_input,
|
||||
open_directory,
|
||||
printEnforceChecklist,
|
||||
locked
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -99,7 +100,7 @@ def menu_main(api: AirlockAPIWrapper):
|
||||
else:
|
||||
print(colorText("Invalid choice. Please try again.", "red"))
|
||||
|
||||
def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
def menu_policy_enforce(api: AirlockAPIWrapper): #TODO Need to clean up 6 and 7 into functions
|
||||
selected_policies = []
|
||||
destination_policy = []
|
||||
destination_allowlist = []
|
||||
@@ -139,7 +140,7 @@ def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
print("File not found. Please make sure it's saved correctly and try again.")
|
||||
|
||||
elif choice == "5":
|
||||
if os.path.exists(f"{working_dir}\\Approved\\{selected_policies[0].name}_hashes_to_add.csv") and os.path.exists(
|
||||
if os.path.exists(f"{working_dir}\\Approved\\{selected_policies[0].name}_approved_executions.csv") and os.path.exists(
|
||||
f"{working_dir}\\Approved\\{selected_policies[0].name}_primary_Paths.csv"
|
||||
):
|
||||
buildPreflights(selected_policies)
|
||||
@@ -167,11 +168,13 @@ def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
for path, ext in unique_combinations.itertuples(index=False, name=None)
|
||||
]
|
||||
|
||||
print(processed_paths)
|
||||
for path in processed_paths:
|
||||
print(path)
|
||||
|
||||
print(colorText("These publishers would added", "yellow"))
|
||||
|
||||
if os.path.exists(f"{working_dir}\\Preflight\\{selected_policies[0].name}_approved_publishers.csv"):
|
||||
publishers = pd.read_csv(f"{working_dir}\\Preflight\\{selected_policies[0].name}_approved_hashes.csv")
|
||||
publishers = pd.read_csv(f"{working_dir}\\Preflight\\{selected_policies[0].name}_approved_publishers.csv")
|
||||
if publishers.empty:
|
||||
print(colorText("The publishers list is empty.", "red"))
|
||||
else:
|
||||
@@ -181,13 +184,14 @@ def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
.drop_duplicates()
|
||||
.tolist()
|
||||
)
|
||||
print(processed_publishers)
|
||||
for publisher in processed_publishers:
|
||||
print(publisher)
|
||||
|
||||
print(colorText("These hashes would be added to:", "yellow"))
|
||||
print(destination_allowlist)
|
||||
|
||||
processed_hashes = hashes["sha256"].unique().tolist()
|
||||
print(processed_hashes)
|
||||
print_three_wide(processed_hashes)
|
||||
|
||||
if processed_paths and processed_hashes:
|
||||
tested = True
|
||||
@@ -207,7 +211,6 @@ def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
for item in missing_items:
|
||||
logger.error(f" - {item}")
|
||||
|
||||
|
||||
elif choice == "7":
|
||||
areYouSure()
|
||||
confirmation = get_sanitized_input("Type 'I AGREE' to continue: ")
|
||||
@@ -222,6 +225,9 @@ def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
api.policy_add_path_exclusions(destination_policy[0].groupid, processed_paths)
|
||||
if processed_publishers:
|
||||
api.policy_add_publishers(destination_policy[0].groupid, processed_publishers)
|
||||
|
||||
locked()
|
||||
|
||||
else:
|
||||
logger.error("Confirmation block failed. Reasons:")
|
||||
if not tested:
|
||||
@@ -237,7 +243,7 @@ def menu_policy_enforce(api: AirlockAPIWrapper):
|
||||
open_directory(working_dir)
|
||||
elif choice.upper() == "S":
|
||||
menu_settings()
|
||||
elif choice.upper == "B":
|
||||
elif choice.upper() == "B":
|
||||
break
|
||||
|
||||
|
||||
@@ -314,3 +320,8 @@ def menu_settings():
|
||||
break
|
||||
else:
|
||||
print("Invalid choice. Please try again.")
|
||||
|
||||
def print_three_wide(items):
|
||||
for i in range(0, len(items), 3):
|
||||
row = items[i:i+3]
|
||||
print(" | ".join(row))
|
||||
Reference in New Issue
Block a user