mirror of
https://github.com/aquasecurity/kube-hunter.git
synced 2026-05-21 08:36:38 +00:00
Merge branch 'master' into access-secrets-hunter
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user