Working preflight
This commit is contained in:
+10
-8
@@ -371,17 +371,19 @@ def menu_prepare_to_enforce():
|
|||||||
|
|
||||||
print(ct.colorText(f"Please choose Parent Allowlist","white"))
|
print(ct.colorText(f"Please choose Parent Allowlist","white"))
|
||||||
allowlist_parent_tuple = utils.allowlist.listAllowlists(url)
|
allowlist_parent_tuple = utils.allowlist.listAllowlists(url)
|
||||||
|
#print(allowlist_parent_tuple)
|
||||||
allowlist_parent = allowlist_parent_tuple[1][allowlist_parent_tuple[0]]
|
allowlist_parent = allowlist_parent_tuple[1][allowlist_parent_tuple[0]]
|
||||||
|
|
||||||
|
|
||||||
print(ct.colorText(f"Please choose Child Allowlist","white"))
|
print(ct.colorText(f"Please choose Child Allowlist","white"))
|
||||||
allowlist_child_tuple = utils.allowlist.listAllowlists(url)
|
allowlist_child_tuple = utils.allowlist.listAllowlists(url)
|
||||||
|
#print(allowlist_child_tuple)
|
||||||
allowlist_child = allowlist_child_tuple[1][allowlist_child_tuple[0]]
|
allowlist_child = allowlist_child_tuple[1][allowlist_child_tuple[0]]
|
||||||
|
|
||||||
elif choice == "6":
|
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")
|
allowbyhash = tryToReadCSV(f"preflight\\final_hash_approvals_{first_policy}_{second_policy}.csv")
|
||||||
|
|
||||||
print(ct.colorText(f"===========================================================================================================================================","red"))
|
print(ct.colorText(f"===========================================================================================================================================","red"))
|
||||||
@@ -395,14 +397,14 @@ def menu_prepare_to_enforce():
|
|||||||
if confirmation.strip().upper() == "I AGREE":
|
if confirmation.strip().upper() == "I AGREE":
|
||||||
print(ct.colorText("Proceeding with the code...", "yellow"))
|
print(ct.colorText("Proceeding with the code...", "yellow"))
|
||||||
|
|
||||||
pathexcludelist = pathexclusions['longestcfp'].unique().tolist
|
pathexcludelist = pathexclusions['longestcfp'].unique().tolist()
|
||||||
utils.policyfunctions.addPath(childallowlist,pathexcludelist)
|
utils.policyfunctions.addPath(allowlist_child,pathexcludelist)
|
||||||
|
|
||||||
parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['target_column'].tolist()
|
parentallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'KNOWN']['sha256'].tolist()
|
||||||
utils.policyfunctions.addHash(parentallowlist,parentallowlisthashlist)
|
utils.policyfunctions.addHash(allowlist_parent,parentallowlisthashlist)
|
||||||
|
|
||||||
childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['target_column'].tolist()
|
childallowlisthashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['sha256'].tolist()
|
||||||
utils.policyfunctions.addHash(childallowlist,childallowlisthashlist)
|
utils.policyfunctions.addHash(allowlist_child, childallowlisthashlist)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print(ct.colorText("Operation aborted. You MUST EXPLICITLY AGREE to proceed.", "red"))
|
print(ct.colorText("Operation aborted. You MUST EXPLICITLY AGREE to proceed.", "red"))
|
||||||
|
|||||||
@@ -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
@@ -116,7 +116,7 @@ def listAllowlists(url):
|
|||||||
if choice < 38:
|
if choice < 38:
|
||||||
print(ct.colorText("Please only choose an allowlist designed for this use - '38+'","red"))
|
print(ct.colorText("Please only choose an allowlist designed for this use - '38+'","red"))
|
||||||
elif choice >= 38:
|
elif choice >= 38:
|
||||||
choice = int(choice) - 1
|
choice = int(choice) - 38
|
||||||
return choice, policiesnames
|
return choice, policiesnames
|
||||||
#Need else and catch for upper bound
|
#Need else and catch for upper bound
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user