Carcass of analyzers added

This commit is contained in:
VakarisZ 2019-08-29 18:18:25 +03:00
parent ebd2628516
commit 919a7ddd11
4 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,16 @@
class CommunicationAnalyzer(object):
def __init__(self, island_client, machines):
self.island_client = island_client
self.machines = machines
def analyze_test_results(self):
for machine in self.machines:
if self.did_monkey_communicate_back(machine):
print("Monkey from {} communicated back".format(machine))
def did_monkey_communicate_back(self, monkey_ip):
request = self.island_client.send_get_request("api/telemetry", {'telem_category': 'state'})

View File

@ -25,3 +25,10 @@ class MonkeyIslandClient(object):
data=config_contents, data=config_contents,
verify=False) verify=False)
print(resp.text) print(resp.text)
def send_get_request(self, endpoint, data):
resp = requests.get(self.addr + endpoint,
headers={"Authorization": "JWT " + self.token},
params=data,
verify=False)
return resp

View File

@ -4,6 +4,7 @@ import unittest
import pytest import pytest
from envs.monkey_zoo.blackbox.monkey_island_client import MonkeyIslandClient from envs.monkey_zoo.blackbox.monkey_island_client import MonkeyIslandClient
from envs.monkey_zoo.blackbox.analyzers.communication_analyzer import CommunicationAnalyzer
def generic_blackbox_test_case(client, config_file_path, analyzers): def generic_blackbox_test_case(client, config_file_path, analyzers):
@ -34,7 +35,8 @@ class TestMonkeyBlackbox(unittest.TestCase):
def test_ssh_exec(self): def test_ssh_exec(self):
client = MonkeyIslandClient(self.island) client = MonkeyIslandClient(self.island)
conf_file_name = "SSH.conf" conf_file_name = "SSH.conf"
generic_blackbox_test_case(client, get_conf_file_path(conf_file_name), []) generic_blackbox_test_case(client, get_conf_file_path(conf_file_name),
[CommunicationAnalyzer(client, ["10.2.2.41", "10.2.2.42"])])
def get_conf_file_path(conf_file_name): def get_conf_file_path(conf_file_name):