MemOpt #18

Merged
mysticmomba merged 30 commits from MemOpt into master 2025-09-02 17:53:43 -04:00
3 changed files with 33 additions and 9 deletions
Showing only changes of commit 942efd38e8 - Show all commits
+10 -8
View File
@@ -371,17 +371,19 @@ def menu_prepare_to_enforce():
print(ct.colorText(f"Please choose Parent Allowlist","white"))
allowlist_parent_tuple = utils.allowlist.listAllowlists(url)
#print(allowlist_parent_tuple)
allowlist_parent = allowlist_parent_tuple[1][allowlist_parent_tuple[0]]
print(ct.colorText(f"Please choose Child Allowlist","white"))
allowlist_child_tuple = utils.allowlist.listAllowlists(url)
#print(allowlist_child_tuple)
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 parentallowlist != " " and childallowlist != " ":
if os.path.exists(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv") and os.path.exists(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv") and allowlist_parent != " " and allowlist_child != " ":
pathexclusions = tryToReadCSV(f"preflight\\final_pathexclusions_{first_policy}_{second_policy}.csv")
pathexclusions = tryToReadCSV(f"preflight\\final_path_exclusions_{first_policy}_{second_policy}.csv")
allowbyhash = tryToReadCSV(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv")
print(ct.colorText(f"===========================================================================================================================================","red"))
@@ -395,14 +397,14 @@ def menu_prepare_to_enforce():
if confirmation.strip().upper() == "I AGREE":
print(ct.colorText("Proceeding with the code...", "yellow"))
pathexcludelist = pathexclusions['longestcfp'].unique().tolist
utils.policyfunctions.addPath(childallowlist,pathexcludelist)
pathexcludelist = pathexclusions['longestcfp'].unique().tolist()
utils.policyfunctions.addPath(allowlist_child,pathexcludelist)
parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['target_column'].tolist()
utils.policyfunctions.addHash(parentallowlist,parentallowlisthashlist)
parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['sha256'].tolist()
utils.policyfunctions.addHash(allowlist_parent,parentallowlisthashlist)
childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['target_column'].tolist()
utils.policyfunctions.addHash(childallowlist,childallowlisthashlist)
childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['sha256'].tolist()
utils.policyfunctions.addHash(allowlist_child, childallowlisthashlist)
else:
print(ct.colorText("Operation aborted. You MUST EXPLICITLY AGREE to proceed.", "red"))
+22
View File
@@ -0,0 +1,22 @@
import requests
import dotenv
import json
import os
import utils.pretty as ct
url = 'https://172.17.22.240:3129'
policiesnames = []
policyids=[]
dotenv.load_dotenv()
endpoint = url + '/v1/application'
print(ct.colorText("[+] Grabbing All Allowlists", "cyan"))
payload = {}
headers = {
"X-APIKey": os.getenv('APIKEY')
}
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
parse_text = json.loads(response.text)
for index, list in enumerate(parse_text['response']['applications'], start=1):
if index >= 38:
print(list)
#Need else and catch for upper bound
+1 -1
View File
@@ -116,7 +116,7 @@ def listAllowlists(url):
if choice < 38:
print(ct.colorText("Please only choose an allowlist designed for this use - '38+'","red"))
elif choice >= 38:
choice = int(choice) - 1
choice = int(choice) - 38
return choice, policiesnames
#Need else and catch for upper bound