mirror of
https://github.com/aquasecurity/kube-hunter.git
synced 2026-05-10 03:07:16 +00:00
Merge pull request #82 from aquasecurity/pod-remote
Should be able to specify remote address inside pod too
This commit is contained in:
@@ -79,7 +79,7 @@ class EventQueue(Queue, object):
|
||||
try:
|
||||
hook.execute()
|
||||
except Exception as ex:
|
||||
logging.debug(ex.message)
|
||||
logging.debug(ex)
|
||||
self.task_done()
|
||||
logging.debug("closing thread...")
|
||||
|
||||
|
||||
@@ -74,18 +74,21 @@ class FromPodHostDiscovery(Hunter):
|
||||
self.event = event
|
||||
|
||||
def execute(self):
|
||||
# Discover master API server from in-pod environment variable.
|
||||
|
||||
if self.is_azure_pod():
|
||||
subnets, cloud =self.azure_metadata_discovery()
|
||||
# Scan any hosts that the user specified
|
||||
if config.remote or config.cidr:
|
||||
self.publish_event(HostScanEvent())
|
||||
else:
|
||||
subnets, cloud = self.traceroute_discovery()
|
||||
# Discover cluster subnets, we'll scan all these hosts
|
||||
if self.is_azure_pod():
|
||||
subnets, cloud = self.azure_metadata_discovery()
|
||||
else:
|
||||
subnets, cloud = self.traceroute_discovery()
|
||||
|
||||
for subnet in subnets:
|
||||
logging.debug("From pod scanning subnet {0}/{1}".format(subnet[0], subnet[1]))
|
||||
for ip in HostDiscoveryHelpers.generate_subnet(ip=subnet[0], sn=subnet[1]):
|
||||
self.publish_event(NewHostEvent(host=ip, cloud=cloud))
|
||||
|
||||
for subnet in subnets:
|
||||
logging.debug("From pod scanning subnet {0}/{1}".format(subnet[0], subnet[1]))
|
||||
for ip in HostDiscoveryHelpers.generate_subnet(ip=subnet[0], sn=subnet[1]):
|
||||
self.publish_event(NewHostEvent(host=ip, cloud=cloud))
|
||||
|
||||
def is_azure_pod(self):
|
||||
try:
|
||||
@@ -116,7 +119,7 @@ class FromPodHostDiscovery(Hunter):
|
||||
logging.debug("From pod discovered subnet {0}/{1}".format(address, subnet if not config.quick else "24"))
|
||||
subnets.append([address,subnet if not config.quick else "24"])
|
||||
|
||||
self.publish_event(AzureMetadataApi(cidr="{}/{}".format(address, subnet)))
|
||||
self.publish_event(AzureMetadataApi(cidr="{}/{}".format(address, subnet)))
|
||||
|
||||
return subnets, "Azure"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user