Audit Policy Update Mechs added, both interactive & non
This commit is contained in:
@@ -354,3 +354,71 @@ def sendToPolicyTest(url, first_policy, second_policy, destination_name, destina
|
||||
allowlist_childhashlist = allowbyhash[allowbyhash['reputation_status'] == 'UNKNOWN']['sha256'].unique().tolist()
|
||||
addHash(url, allowlist_child_id, allowlist_childhashlist)
|
||||
|
||||
def getMetaRules(url,appid):
|
||||
endpoint = url + '/v1/application/export'
|
||||
payload = {
|
||||
"applicationid" : {appid}
|
||||
}
|
||||
headers = {
|
||||
"X-APIKey": os.getenv('APIKEY')
|
||||
}
|
||||
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
||||
parse_text = json.loads(response.text)
|
||||
policiesnames = []
|
||||
policyids = []
|
||||
for index, list in enumerate(parse_text['response']['groups'], start=1):
|
||||
print(ct.colorText(f"{index}. {list['name']}", "yellow"))
|
||||
policiesnames.append(list['name'])
|
||||
policyids.append(list['groupid'])
|
||||
choice = input(ct.colorText("Select Policy Group: ", "white"))
|
||||
choice = int(choice) - 1
|
||||
return choice, policiesnames, policyids
|
||||
|
||||
def updateAuditPoliciesFromEnforcementPolices(url, policy_relationship_map):
|
||||
for enforcement_policy, audit_policy in policy_relationship_map.items():
|
||||
assignPoliciesfromGroup(url, enforcement_policy, audit_policy)
|
||||
turnOnAudit(url, audit_policy)
|
||||
|
||||
def assignPoliciesfromGroup(url, source_policy_id, target_policy_id):
|
||||
|
||||
endpoint = url + '/v1/group/assign'
|
||||
|
||||
payload = {
|
||||
"groupid" : {source_policy_id},
|
||||
"targetgroupid" : {target_policy_id}
|
||||
}
|
||||
headers = {
|
||||
"X-APIKey": os.getenv('APIKEY')
|
||||
}
|
||||
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
||||
parse_text = json.loads(response.text)
|
||||
print(parse_text)
|
||||
|
||||
|
||||
def turnOnAudit(url, policyid):
|
||||
|
||||
endpoint = url + '/v1/group/settings/auditmode'
|
||||
|
||||
payload = {
|
||||
"groupid" : {policyid},
|
||||
"auditmode" : "1"
|
||||
}
|
||||
headers = {
|
||||
"X-APIKey": os.getenv('APIKEY')
|
||||
}
|
||||
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
||||
parse_text = json.loads(response.text)
|
||||
print(parse_text)
|
||||
|
||||
def agentsInPolicy(url, policyid):
|
||||
endpoint = url + '/v1/group/agents'
|
||||
|
||||
payload = {
|
||||
"groupid" : {policyid}
|
||||
}
|
||||
headers = {
|
||||
"X-APIKey": os.getenv('APIKEY')
|
||||
}
|
||||
response = requests.request("POST", endpoint, headers=headers, data=payload, verify=False)
|
||||
parse_text = json.loads(response.text)
|
||||
print(parse_text)
|
||||
|
||||
Reference in New Issue
Block a user