Merge branch 'master' into access-secrets-hunter

This commit is contained in:
Liz Rice
2018-11-06 09:08:14 +00:00
committed by GitHub
7 changed files with 65 additions and 14 deletions

View File

@@ -12,7 +12,8 @@ from ..types import ActiveHunter, Hunter
from ...core.events.types import HuntFinished
import threading
working_count = 0
global queue_lock
queue_lock = Lock()
# Inherits Queue object, handles events asynchronously
class EventQueue(Queue, object):
@@ -34,12 +35,12 @@ class EventQueue(Queue, object):
t.daemon = True
t.start()
# decorator wrapping for easy subscription
def subscribe(self, event, hook=None, predicate=None):
def wrapper(hook):
self.subscribe_event(event, hook=hook, predicate=predicate)
return hook
return wrapper
# getting uninstantiated event object
@@ -72,7 +73,9 @@ class EventQueue(Queue, object):
# executes callbacks on dedicated thread as a daemon
def worker(self):
while self.running:
queue_lock.acquire()
hook = self.get()
queue_lock.release()
try:
hook.execute()
except Exception as ex:

View File

@@ -65,6 +65,9 @@ class Vulnerability(object):
def explain(self):
return self.__doc__
global event_id_count_lock
event_id_count_lock = threading.Lock()
event_id_count = 0
""" Discovery/Hunting Events """
@@ -75,8 +78,10 @@ class NewHostEvent(Event):
global event_id_count
self.host = host
self.cloud = cloud
event_id_count_lock.acquire()
self.event_id = event_id_count
event_id_count += 1
event_id_count_lock.release()
def __str__(self):
return str(self.host)