Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Clear old notifications. Working on update to v3 API #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion crowdfms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
15 changes: 15 additions & 0 deletions lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Binary file added lib/core.pyc
Binary file not shown.