Cleaned up Generate Unexclueded Function to keep its files in check

This commit is contained in:
=
2025-09-19 12:19:35 -04:00
parent 9b5ac1c5cf
commit 26ea73392b
3 changed files with 19 additions and 43 deletions
+12 -18
View File
@@ -121,7 +121,7 @@ def menu_main():
ct.displayIntro();
print(ct.colorText("1. Get All Events for Single Device", "yellow"))
print(ct.colorText("2. OTP", "yellow"))
print(ct.colorText("3. Divide by Exclusion", "yellow"))
print(ct.colorText("3. Find Unexcluded from 24hr Execution", "yellow"))
print(ct.colorText("4. Prepare Policy For Enforcement", "yellow"))
print(ct.colorText("5. Update Audit Policies from Enforcement Policies", "yellow"))
print(ct.colorText("Q. Quit", "yellow"))
@@ -132,7 +132,7 @@ def menu_main():
elif choice == "2":
menu_otp()
elif choice == "3":
menu_feature2()
find_unexcluded()
elif choice == "4":
menu_prepare_to_enforce()
elif choice == "5":
@@ -162,15 +162,17 @@ def menu_otp():
else:
print("Invalid choice. Please try again.")
def menu_feature2():
def find_unexcluded():
while True:
print("\n--- Submenu ---")
print("\n--- Follow Steps Sequentially, Files will land in directory named 'exclusions'")
print("1. Pull last 24 hours execution for all ATPolicys")
print("2. Generate Paths")
print("3. Merge")
print("4. Pull existing paths")
print("5. Divide By Excluded or not excluded by path")
print("Q. Exit")
if not os.path.exists("exclusions"): os.makedirs("exclusions")
choice = input("Enter your choice: ")
if choice == "1":
@@ -203,7 +205,7 @@ def menu_feature2():
combined_df = pd.DataFrame()
print("⚠️ No data was retrieved.")
combined_df.to_csv("allATPolicyExecs.csv", index=False)
combined_df.to_csv("exclusions\\allATPolicyExecs.csv", index=False)
elif choice == "2":
@@ -248,12 +250,12 @@ def menu_feature2():
print("⚠️ No paths were retrieved.")
# Save to CSV
paths_df.to_csv("paths.csv", index=False)
paths_df.to_csv("exclusions\\paths.csv", index=False)
elif choice == "5":
# Load and clean data
filenames_df = pd.read_csv('merged_output.csv') # Contains 'PolicyName' and 'filename'
exclusions_df = pd.read_csv('paths.csv') # Contains 'PolicyName' and 'Path'
filenames_df = pd.read_csv('exclusions\\merged_output.csv') # Contains 'PolicyName' and 'filename'
exclusions_df = pd.read_csv('exclusions\\paths.csv') # Contains 'PolicyName' and 'Path'
# Clean and normalize columns
filenames_df['filename'] = filenames_df['filename'].fillna('').astype(str).str.strip()
@@ -308,16 +310,8 @@ def menu_feature2():
# Save results
excluded.to_csv('excluded_filenames.csv', index=False)
not_excluded.to_csv('non_excluded_filenames.csv', index=False)
elif choice == "6":
pattern = utils.pathfunctions.wildcardRegex("C:\\Windows\\SystemTemp\\????????\\????????.dll")
test_path = "C:\\Windows\\SystemTemp\\fsq2xzua\\fsq2xzua.dll"
print("Match:", pattern.match(test_path) is not None)
excluded.to_csv('exclusions\\excluded_filenames.csv', index=False)
not_excluded.to_csv('exclusions\\non_excluded_filenames.csv', index=False)
elif choice == "Q":