Merge pull request #115 from guardicore/develop

Develop
This commit is contained in:
Daniel Goldberg 2018-04-02 17:40:51 +03:00 committed by GitHub
commit 3f54590785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -23,7 +23,7 @@ def _cast_by_example(value, example):
"""
example_type = type(example)
if example_type is str:
return str(os.path.expandvars(value))
return os.path.expandvars(value).encode("utf8")
elif example_type is tuple and len(example) != 0:
if value is None or value == tuple([None]):
return tuple()

View File

@ -232,5 +232,5 @@ class ElasticGroovyExploiter(HostExploiter):
try:
json_resp = json.loads(response.text)
return json_resp['hits']['hits'][0]['fields'][self.MONKEY_RESULT_FIELD]
except KeyError:
except (KeyError, IndexError):
return None

View File

@ -139,7 +139,7 @@ def check_tcp_ports(ip, ports, timeout=DEFAULT_TIMEOUT, get_banner=False):
"On host %s discovered the following ports %s" %
(str(ip), ",".join([str(s[0]) for s in connected_ports_sockets])))
banners = []
if get_banner:
if get_banner and (len(connected_ports_sockets) != 0):
readable_sockets, _, _ = select.select([s[1] for s in connected_ports_sockets], [], [], 0)
# read first BANNER_READ bytes
banners = [sock.recv(BANNER_READ) if sock in readable_sockets else ""