From f3a172fc4af308389be75fa26a6a453d74ce7e8d Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Mon, 25 Sep 2017 18:02:21 +0300 Subject: [PATCH] Fixed CR notes https://github.com/guardicore/monkey/pull/48#pullrequestreview-64914540 --- chaos_monkey/config.py | 1 + chaos_monkey/network/elasticfinger.py | 11 ++++++----- chaos_monkey/system_info/__init__.py | 19 +++++-------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/chaos_monkey/config.py b/chaos_monkey/config.py index 81e583096..e5a7d736a 100644 --- a/chaos_monkey/config.py +++ b/chaos_monkey/config.py @@ -189,6 +189,7 @@ class Configuration(object): 8008, # HTTP alternate ] tcp_target_ports = [22, + 2222, 445, 135, 3389, diff --git a/chaos_monkey/network/elasticfinger.py b/chaos_monkey/network/elasticfinger.py index ea7bec14c..8c21887ee 100644 --- a/chaos_monkey/network/elasticfinger.py +++ b/chaos_monkey/network/elasticfinger.py @@ -9,15 +9,15 @@ from model.host import VictimHost from network import HostFinger ES_PORT = 9200 -ES_SERVICE = 'es-3306' - +ES_SERVICE = 'elastic-seach-3306' +ES_HTTP_TIMEOUT = 5 LOG = logging.getLogger(__name__) __author__ = 'danielg' class ElasticFinger(HostFinger): """ - Fingerprints mysql databases, only on port 3306 + Fingerprints elastic search clusters, only on port 3306 """ def __init__(self): @@ -32,11 +32,12 @@ class ElasticFinger(HostFinger): assert isinstance(host, VictimHost) try: url = 'http://%s:%s/' % (host.ip_addr, ES_PORT) - with closing(requests.get(url, timeout=1)) as req: + with closing(requests.get(url, timeout=ES_HTTP_TIMEOUT)) as req: data = json.loads(req.text) host.services[ES_SERVICE] = {} host.services[ES_SERVICE]['name'] = 'ElasticSearch' - host.services[ES_SERVICE]['cluster_name'] = data['name'] + host.services[ES_SERVICE]['cluster_name'] = data['cluster_name'] + host.services[ES_SERVICE]['name'] = data['name'] host.services[ES_SERVICE]['version'] = data['version']['number'] return True except Timeout: diff --git a/chaos_monkey/system_info/__init__.py b/chaos_monkey/system_info/__init__.py index c95caa444..ddf13d885 100644 --- a/chaos_monkey/system_info/__init__.py +++ b/chaos_monkey/system_info/__init__.py @@ -1,8 +1,10 @@ -import sys import socket +import sys + import psutil from enum import IntEnum -from network.info import get_host_subnets, local_ips + +from network.info import get_host_subnets __author__ = 'uri' @@ -68,18 +70,7 @@ class InfoCollector(object): "cmdline": " ".join(process.cmdline()), "full_image_path": process.exe(), } - except psutil.AccessDenied: - # we may be running as non root - # and some processes are impossible to acquire in Windows/Linux - # in this case we'll just add what we can - processes[process.pid] = {"name": "null", - "pid": process.pid, - "ppid": process.ppid(), - "cmdline": "ACCESS DENIED", - "full_image_path": "null", - } - continue - except WindowsError: + except (psutil.AccessDenied, WindowsError): # we may be running as non root # and some processes are impossible to acquire in Windows/Linux # in this case we'll just add what we can