diff --git a/AirlockTools.py b/AirlockTools.py index ad50df5..fda1204 100644 --- a/AirlockTools.py +++ b/AirlockTools.py @@ -215,8 +215,8 @@ def menu_prepare_to_enforce(): print(ct.colorText(" When complete, save the csv file to the directory 'manuallyapproved'", "cyan")) print(ct.colorText(" Preflight Lists will be generated", "cyan")) - if os.path.exists(f"manuallyapproved\\lcf_needs_approved_{first_policy}_{second_policy}.csv"): - print(ct.colorText(" [✓] Reviewed path list detected","green")) + if os.path.isfile(f"manuallyapproved\\df_paths_needing_review_{first_policy}_{second_policy}.csv") and os.path.isfile("dataframe_csv\\df_hashdestination_{first_policy}_{second_policy}.csv") and os.path.isfile(f"dataframe_csv\\df_addtochildpolicy_{first_policy}_{second_policy}.csv") and os.path.isfile(f"dataframe_csv\\f_addtobaseline_{first_policy}_{second_policy}.csv"): + print(ct.colorText(" [✓] This step has been completed","green")) else: print(ct.colorText(" [✗] Path review list has not been detected","red")) @@ -354,15 +354,36 @@ def menu_prepare_to_enforce(): else: print(ct.colorText(f"Please manually approve hashes prior to this step","red")) + + elif choice == "7": + if os.path.exists(f"manuallyapproved\\df_paths_needing_review_{first_policy}_{second_policy}.csv"): + df_approved = tryToReadCSV(f"manuallyapproved\\df_paths_needing_review_{first_policy}_{second_policy}.csv") + df_eligible = tryToReadCSV(f"dataframe_csv\\df_paths_needing_review_{first_policy}_{second_policy}.csv") + df_ineligible = tryToReadCSV(f"dataframe_csv\\df_path_ineligible_{first_policy}_{second_policy}.csv") - elif choice == "4": + approved_set = set([tuple(map(tuple, row)) for row in df_approved.values]) + + # Identify rows in eligible that are not in approved + not_approved_rows = df_eligible[~df_eligible.apply(lambda row: tuple(map(tuple, row)) in approved_set, axis=1)] + + # Append these rows to ineligible + df_ineligible= pd.concat([df_ineligible, not_approved_rows], ignore_index=True) + + df_approved.to_csv(f"preflight\\Approved_Path_Exclusions_{first_policy}_{second_policy}.csv") + ct.style_dataframe_dark(df_approved, f"preflight\\Approved_Path_Exclusions_{first_policy}_{second_policy}.html") + + #Seperate out what we arent excluding by path into those that will go into the baseline, and those that will b added to the child. + df_addtobaseline = df_ineligible[df_ineligible['reputation status'] == 'KNOWN'] + df_addtobaseline.to_csv(f"preflight\\Add_to_Baseline_{first_policy}_{second_policy}.csv", index=False) + ct.style_dataframe_dark(df_addtobaseline, f"preflight\\Add_to_Baseline_{first_policy}_{second_policy}.html") + + df_addtochildpolicy = df_ineligible[df_ineligible['reputation status'] == 'UNKNOWN'] + df_addtochildpolicy.to_csv(f"preflight\\Add_to_Child_Policy_{first_policy}_{second_policy}.csv", index=False) + ct.style_dataframe_dark(df_addtochildpolicy, f"preflight\\Add_to_Child_Policy_{first_policy}_{second_policy}.html") + + else: + print(ct.colorText(f"Please manually approve suggested paths prior to this step","red")) - if os.path.exists(f"dataframe_csv\\allinfo_{first_policy}_{second_policy}.csv") and os.path.exists(f"manuallyapproved\\lcf_needs_approved_{first_policy}_{second_policy}.csv"): - df1 = tryToReadCSV(f"dataframe_csv\\allinfo_{first_policy}_{second_policy}.csv") - pathexclusions,allowbyhash = utils.pathfunctions.mask_from_csv(df1, f"manuallyapproved\\lcf_needs_approved_{first_policy}_{second_policy}.csv","longestcfp") - - pathexclusions.to_csv(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv", index=False) - ct.style_dataframe_dark(pathexclusions, f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.html") allowbyhash.to_csv(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv", index=False) ct.style_dataframe_dark(allowbyhash, f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.html")