mirror of
https://github.com/aquasecurity/kube-hunter.git
synced 2026-02-14 18:09:56 +00:00
Fix empty report (#281)
* Fix empty report when active hunting Running kube-hunter active hunting with plain report did not show any report. This commit changes Vulnerability.vid default value to "None" (previously None) Closes #280 * Improve debug and exception messages Debugging hunters execution is hard due to lack of debug information. No indication is made when a hunter starts. Exceptions where printed without stack trace, which made it difficult to follow.
This commit is contained in:
committed by
GitHub
parent
fe3dba90d8
commit
a4a8c71653
@@ -128,6 +128,7 @@ class EventQueue(Queue, object):
|
||||
while self.running:
|
||||
try:
|
||||
hook = self.get()
|
||||
logging.debug("Executing {} with {}".format(hook.__class__, hook.event.__dict__))
|
||||
hook.execute()
|
||||
except Exception as ex:
|
||||
logging.debug("Exception: {} - {}".format(hook.__class__, ex))
|
||||
|
||||
@@ -80,7 +80,7 @@ class Vulnerability(object):
|
||||
})
|
||||
|
||||
# TODO: make vid mandatory once migration is done
|
||||
def __init__(self, component, name, category=None, vid=None):
|
||||
def __init__(self, component, name, category=None, vid="None"):
|
||||
self.vid = vid
|
||||
self.component = component
|
||||
self.category = category
|
||||
|
||||
@@ -92,7 +92,7 @@ class ApiServiceClassify(EventFilterBase):
|
||||
else:
|
||||
self.event = ApiServer()
|
||||
except Exception as e:
|
||||
logging.error("Could not access /version on API service: {}".format(e))
|
||||
logging.exception("Could not access /version on API service")
|
||||
|
||||
def execute(self):
|
||||
discovered_protocol = self.event.protocol
|
||||
|
||||
@@ -152,7 +152,7 @@ class HostDiscovery(Discovery):
|
||||
try:
|
||||
ip, sn = config.cidr.split('/')
|
||||
except ValueError as e:
|
||||
logging.error("unable to parse cidr: {0}".format(e))
|
||||
logging.exception("unable to parse cidr")
|
||||
return
|
||||
cloud = HostDiscoveryHelpers.get_cloud(ip)
|
||||
for ip in HostDiscoveryHelpers.generate_subnet(ip, sn=sn):
|
||||
|
||||
@@ -225,8 +225,9 @@ class AccessApiServer(Hunter):
|
||||
for item in resp["items"]:
|
||||
items.append(item["metadata"]["name"])
|
||||
return items
|
||||
logging.debug("Got HTTP {} respone: {}".format(r.status_code, r.text))
|
||||
except (requests.exceptions.ConnectionError, KeyError):
|
||||
pass
|
||||
logging.debug("Failed retrieving items from API server at {}".format(path))
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class HTTPDispatcher(object):
|
||||
)
|
||||
except requests.HTTPError as e:
|
||||
# specific http exceptions
|
||||
logging.error(
|
||||
logging.exception(
|
||||
"\nCould not dispatch report using HTTP {method} to {url}\nResponse Code: {status}".format(
|
||||
status=r.status_code,
|
||||
url=dispatch_url,
|
||||
@@ -42,10 +42,9 @@ class HTTPDispatcher(object):
|
||||
)
|
||||
except Exception as e:
|
||||
# default all exceptions
|
||||
logging.error("\nCould not dispatch report using HTTP {method} to {url} - {error}".format(
|
||||
logging.exception("\nCould not dispatch report using HTTP {method} to {url}".format(
|
||||
method=dispatch_method,
|
||||
url=dispatch_url,
|
||||
error=e
|
||||
url=dispatch_url
|
||||
))
|
||||
|
||||
class STDOUTDispatcher(object):
|
||||
|
||||
Reference in New Issue
Block a user