From 04791f324f595aef6819fd11428e6b4f19ee988e Mon Sep 17 00:00:00 2001 From: Silas Date: Mon, 12 Nov 2018 21:41:01 -0500 Subject: [PATCH] Clear old notifications. Working on update to v3 API --- crowdfms.py | 9 ++++++++- lib/core.py | 15 +++++++++++++++ lib/core.pyc | Bin 0 -> 4432 bytes 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 lib/core.pyc diff --git a/crowdfms.py b/crowdfms.py index 1e6bc24..fc2a207 100755 --- a/crowdfms.py +++ b/crowdfms.py @@ -8,7 +8,7 @@ import thread import time -from lib.core import funct_parse_rule_actions, func_pull_feed, func_to_epoch, func_download_sample, func_set_api_key, funct_run_rule_action +from lib.core import funct_parse_rule_actions, func_pull_feed, func_to_epoch, func_download_sample, func_set_api_key, funct_run_rule_action, func_delete_notif from lib.objects import sample from lib.db import db_shutdown @@ -39,12 +39,19 @@ def loop_pull_feed(): global LOOP_TIME rule_actions = funct_parse_rule_actions() + vtIDS = [] json_notif_feed = func_pull_feed(API_KEY) if (json_notif_feed == 0): print "Problem pulling feed. Sleeping..." return + # Notification Purge + for vt_notif in json_notif_feed["notifications"]: + vtIDS.append( int(vt_notif["id"]) ) + func_delete_notif(API_KEY, vtIDS) + + for vt_notif in json_notif_feed["notifications"]: if (func_to_epoch(vt_notif["date"]) > tmp_newest): diff --git a/lib/core.py b/lib/core.py index be25636..16388f7 100644 --- a/lib/core.py +++ b/lib/core.py @@ -14,6 +14,21 @@ from lib.db import * +# Purge old notifications +def func_delete_notif(str_api_key, notificationList): + req_user_agent = {'User-agent': 'VirusTotal FMS'} + try: + vt_request_results = requests.post("https://www.virustotal.com/intelligence/hunting/delete-notifications/programmatic/?key=%s" % (str_api_key), + headers=req_user_agent, + data=json.dumps(notificationList), + timeout=30, + verify=False) + except Exception, e: + print " [x] Exception in purge request: %s" % e + return "ERROR" + + return None + # Read ~/.virustotal and read the first line. This file only needs the API string in it. def func_set_api_key(): try: diff --git a/lib/core.pyc b/lib/core.pyc new file mode 100644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