From 3df7ea85bc56250e752ba7f638a2ae15fef1ed0e Mon Sep 17 00:00:00 2001 From: danielsagi Date: Sat, 28 May 2022 14:51:43 -0700 Subject: [PATCH] fixed linting issues --- kube_hunter/conf/__init__.py | 2 +- kube_hunter/conf/parser.py | 6 +++++- kube_hunter/modules/discovery/cloud/aws.py | 1 - kube_hunter/modules/discovery/cloud/azure.py | 8 +++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kube_hunter/conf/__init__.py b/kube_hunter/conf/__init__.py index b0bf862..efb206c 100644 --- a/kube_hunter/conf/__init__.py +++ b/kube_hunter/conf/__init__.py @@ -22,7 +22,7 @@ class Config: - network_timeout: Timeout for network operations - num_worker_threads: Add a flag --threads to change the default 800 thread count of the event handler - pod: From pod scanning mode - - full_cloud_scan: disables limit for 24 cidr in cloud envs + - full_cloud_scan: disables limit for 24 cidr in cloud envs - remote: Hosts to scan - report: Output format - statistics: Include hunters statistics diff --git a/kube_hunter/conf/parser.py b/kube_hunter/conf/parser.py index 214afc2..c353305 100644 --- a/kube_hunter/conf/parser.py +++ b/kube_hunter/conf/parser.py @@ -18,7 +18,11 @@ def parser_add_arguments(parser): parser.add_argument("--pod", action="store_true", help="Set hunter as an insider pod") - parser.add_argument("--full-cloud-scan", action="store_true", help="Disable hardlimit of '/24' CIDR when scraping Instance Metadata API") + parser.add_argument( + "--full-cloud-scan", + action="store_true", + help="Disable hardlimit of '/24' CIDR when scraping Instance Metadata API", + ) parser.add_argument( "--include-patched-versions", diff --git a/kube_hunter/modules/discovery/cloud/aws.py b/kube_hunter/modules/discovery/cloud/aws.py index 7178052..75c877f 100644 --- a/kube_hunter/modules/discovery/cloud/aws.py +++ b/kube_hunter/modules/discovery/cloud/aws.py @@ -1,4 +1,3 @@ -import enum import logging import requests import ipaddress diff --git a/kube_hunter/modules/discovery/cloud/azure.py b/kube_hunter/modules/discovery/cloud/azure.py index eadd206..c24e5cc 100644 --- a/kube_hunter/modules/discovery/cloud/azure.py +++ b/kube_hunter/modules/discovery/cloud/azure.py @@ -78,13 +78,13 @@ class AzureInstanceMetadataServiceDiscovery(Discovery): logger.debug("Trying to access IMDS (Azure Metadata Service) from pod") available_versions = AzureInstanceMetadataService.get_versions(network_timeout=config.network_timeout) - + if not available_versions: logger.debug("IMDS not available") return versions_info = dict() - for version in available_versions['apiVersions']: + for version in available_versions["apiVersions"]: instance_data = AzureInstanceMetadataService.get_instance_data( api_version=version, network_timeout=config.network_timeout ) @@ -110,7 +110,9 @@ class AzureSubnetsDiscovery(Discovery): tmp_prefix = info["network"]["interface"][0]["ipv4"]["subnet"][0]["prefix"] if not config.full_cloud_scan: - logger.debug(f"Discovered azure subnet {tmp_prefix} but scanning {prefix} due to `full_cloud_scan=False` option ") + logger.debug( + f"Discovered azure subnet {tmp_prefix} but scanning {prefix} due to `full_cloud_scan=False` option " + ) else: prefix = tmp_prefix