Fixed Json Output
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ def menu():
|
|||||||
if choice == '5':
|
if choice == '5':
|
||||||
|
|
||||||
executionhist = utils.allowlist.allowlistexechistories(url,True)
|
executionhist = utils.allowlist.allowlistexechistories(url,True)
|
||||||
print(executionhist)
|
#print(executionhist)
|
||||||
|
|
||||||
aggregated = utils.hashfunctions.aggregateHashes(executionhist)
|
aggregated = utils.hashfunctions.aggregateHashes(executionhist)
|
||||||
print(aggregated)
|
print(aggregated)
|
||||||
|
|||||||
+5
-2
@@ -35,9 +35,12 @@ def allowlistexechistories(url, outputjson: bool):
|
|||||||
if (datetime.date.today() - datetime.timedelta(days=1) > datetime.datetime.strptime(item['datetime'].replace(' +0000 UTC', ''), '%Y-%m-%dT%H:%M:%SZ').date()):
|
if (datetime.date.today() - datetime.timedelta(days=1) > datetime.datetime.strptime(item['datetime'].replace(' +0000 UTC', ''), '%Y-%m-%dT%H:%M:%SZ').date()):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
json_output['response']['exechistories'].append(json_response_data['response']['exechistories'])
|
#json_output['response']['exechistories'].append(json_response_data['response']['exechistories'][1])
|
||||||
|
for output in json_response_data['response']['exechistories']:
|
||||||
|
json_output['response']['exechistories'].append(output)
|
||||||
|
json_output = json.dumps(json_output)
|
||||||
if outputjson == True:
|
if outputjson == True:
|
||||||
return (json_output)
|
return json_output
|
||||||
#endpoint = url + '/v1/logging/exechistories'
|
#endpoint = url + '/v1/logging/exechistories'
|
||||||
#payload_dict = {
|
#payload_dict = {
|
||||||
# "type":[1, 2, 6, 7],
|
# "type":[1, 2, 6, 7],
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ def aggregateHashes(executions_json) -> pd.DataFrame:
|
|||||||
"""
|
"""
|
||||||
Takes the executions, aggregates all the data with sha256 as primary, then returns aggregated dataframe
|
Takes the executions, aggregates all the data with sha256 as primary, then returns aggregated dataframe
|
||||||
"""
|
"""
|
||||||
data = executions_json
|
data = json.loads(executions_json)
|
||||||
df = pd.DataFrame(data["response"]["exechistories"])
|
df = pd.DataFrame(data["response"]["exechistories"])
|
||||||
|
|
||||||
if df.empty:
|
if df.empty:
|
||||||
return df
|
return df
|
||||||
|
print(df)
|
||||||
# Aggregate by sha256, deduplicate lists, and preserve order
|
# Aggregate by sha256, deduplicate lists, and preserve order
|
||||||
agg_df = df.groupby("sha256").agg(lambda x: list(dict.fromkeys(x))).reset_index()
|
agg_df = df.groupby("sha256").agg(lambda x: list(dict.fromkeys(x))).reset_index()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user