LocalApproval in progress
This commit is contained in:
@@ -235,7 +235,7 @@ def checkpoint_stomper(checkpoint, url, type, policy, headers):
|
||||
parse_text = json.loads(json.dumps(json_output))
|
||||
return parse_text
|
||||
|
||||
def listPolicies(url):
|
||||
def listPolicies(url):
|
||||
endpoint = url + '/v1/group'
|
||||
print(ct.colorText("[+] Grabbing All Policies", "cyan"))
|
||||
payload = {}
|
||||
@@ -244,9 +244,13 @@ def listPolicies(url):
|
||||
}
|
||||
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
||||
parse_text = json.loads(response.text)
|
||||
return parse_text
|
||||
|
||||
def choosePolicies(url):
|
||||
allpolicies = listPolicies(url)
|
||||
policiesnames = []
|
||||
policyids = []
|
||||
for index, list in enumerate(parse_text['response']['groups'], start=1):
|
||||
for index, list in enumerate(allpolicies['response']['groups'], start=1):
|
||||
print(ct.colorText(f"{index}. {list['name']}", "yellow"))
|
||||
policiesnames.append(list['name'])
|
||||
policyids.append(list['groupid'])
|
||||
@@ -254,6 +258,9 @@ def listPolicies(url):
|
||||
choice = int(choice) - 1
|
||||
return choice, policiesnames, policyids
|
||||
|
||||
def getPolicyDataframe(url) -> pd.DataFrame:
|
||||
return pd.DataFrame(listPolicies(url)['response']['groups'])
|
||||
|
||||
def listATPolicies(url):
|
||||
endpoint = url + '/v1/group'
|
||||
print(ct.colorText("[+] Grabbing All Policies", "cyan"))
|
||||
@@ -440,7 +447,7 @@ def prepare_to_enforce(url, bad_publisher_list, pups, badpathparts, threat_toler
|
||||
elif choice == "2":
|
||||
|
||||
print(ct.colorText(f"Please choose destination_name Policy for Path Exclusions","white"))
|
||||
choice, policynames, policyid = listPolicies(url)
|
||||
choice, policynames, policyid = choosePolicies(url)
|
||||
#print(allowlist_parent_tuple)
|
||||
destination_name = policynames[choice]
|
||||
destination_id = policyid[choice]
|
||||
@@ -590,6 +597,7 @@ def savePreFlights(appr_base_dir, parq_base_dir, pflight_base_dir):
|
||||
ct.style_dataframe_dark(df, f"{pflight_base_dir}{name}.html")
|
||||
|
||||
def getMultiplePolicySelections(url):
|
||||
|
||||
policynameslist = []
|
||||
policyidlist = []
|
||||
while True:
|
||||
@@ -617,4 +625,32 @@ def getMultiplePolicySelections(url):
|
||||
break
|
||||
|
||||
|
||||
return policynameslist, policyidlist
|
||||
return policynameslist, policyidlist
|
||||
|
||||
def getDestAllowlist(url, groupid):
|
||||
|
||||
allowlists = getPolicyAllowlists(url, groupid)
|
||||
|
||||
matches = allowlists.loc[
|
||||
allowlists['name'].str.contains('local', case=False, na=False) &
|
||||
allowlists['name'].str.contains('approval', case=False, na=False),
|
||||
'applicationid'
|
||||
].values
|
||||
app_id = matches[0] if len(matches) > 0 else None
|
||||
|
||||
return app_id
|
||||
|
||||
def getPolicyAllowlists(url, groupid):
|
||||
|
||||
endpoint = url + '/v1/group/policies'
|
||||
payload = {
|
||||
"groupid" : f"{groupid}"
|
||||
}
|
||||
|
||||
headers = {"X-APIKey": os.getenv('APIKEY')}
|
||||
payload = json.dumps(payload)
|
||||
|
||||
response = requests.post(endpoint, headers=headers, data=payload, verify=False)
|
||||
result = json.loads(response.text)
|
||||
data = pd.DataFrame(result["response"]["applications"])
|
||||
return data
|
||||
Reference in New Issue
Block a user