forked from p15670423/monkey
Carcass of analyzers added
This commit is contained in:
parent
ebd2628516
commit
919a7ddd11
|
@ -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'})
|
||||
|
||||
|
|
@ -25,3 +25,10 @@ class MonkeyIslandClient(object):
|
|||
data=config_contents,
|
||||
verify=False)
|
||||
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
|
||||
|
|
|
@ -4,6 +4,7 @@ import unittest
|
|||
import pytest
|
||||
|
||||
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):
|
||||
|
@ -34,7 +35,8 @@ class TestMonkeyBlackbox(unittest.TestCase):
|
|||
def test_ssh_exec(self):
|
||||
client = MonkeyIslandClient(self.island)
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue