Cleaned up Generate Unexclueded Function to keep its files in check
This commit is contained in:
@@ -202,7 +202,7 @@ def allATpaths(url, pups, untrusted_publishers, badpathparts, threat_tolerance,
|
||||
import pandas as pd
|
||||
|
||||
# Load raw data
|
||||
hashes = pd.read_csv("allATPolicyExecs.csv")
|
||||
hashes = pd.read_csv("exclusions\\allATPolicyExecs.csv")
|
||||
|
||||
# Deduplicate hashes before augmentation
|
||||
deduped_hashes = hashes.drop_duplicates(subset=['sha256']).copy()
|
||||
@@ -245,7 +245,7 @@ def allATpaths(url, pups, untrusted_publishers, badpathparts, threat_tolerance,
|
||||
if 'PolicyName_x' in final_augmented.columns:
|
||||
final_augmented = final_augmented.rename(columns={'PolicyName_x': 'PolicyName'})
|
||||
|
||||
final_augmented.to_csv("testing.csv", index=False)
|
||||
final_augmented.to_csv("exclusions\\testing.csv", index=False)
|
||||
|
||||
# Reputation flag logic
|
||||
def reputationtool(row):
|
||||
@@ -306,21 +306,21 @@ def allATpaths(url, pups, untrusted_publishers, badpathparts, threat_tolerance,
|
||||
review_df = review_df.merge(sha_counts, on='longestcfp', how='left')
|
||||
review_df = review_df[review_df['unique_sha256_count'] >= min_files_for_path]
|
||||
|
||||
review_df.to_csv("ALL_AT_PATHS.csv", index=False)
|
||||
review_df.to_csv("exclusions\\ALL_AT_PATHS.csv", index=False)
|
||||
|
||||
# Cleanup
|
||||
del lcp_not_forbidden, sha_counts, review_df
|
||||
|
||||
def mergeTesting():
|
||||
# Load the two CSVs
|
||||
testing_df = pd.read_csv("testing.csv")
|
||||
paths_df = pd.read_csv("ALL_AT_PATHS.csv")
|
||||
testing_df = pd.read_csv("exclusions\\testing.csv")
|
||||
paths_df = pd.read_csv("exclusions\\ALL_AT_PATHS.csv")
|
||||
|
||||
# Merge on 'sha256' with testing as the left DataFrame
|
||||
merged_df = testing_df.merge(paths_df, on="sha256", how="left")
|
||||
|
||||
# Save the merged result
|
||||
merged_df.to_csv("merged_output.csv", index=False)
|
||||
merged_df.to_csv("exclusions\\merged_output.csv", index=False)
|
||||
|
||||
print(f"Merged DataFrame saved with {len(merged_df)} rows.")
|
||||
|
||||
|
||||
@@ -354,25 +354,7 @@ 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():
|
||||
|
||||
Reference in New Issue
Block a user