From c706466cddec52a5e6b3ad7ffde6562cbaf1d737 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Sat, 1 Oct 2022 19:59:46 -0400 Subject: [PATCH] BB: Add MonkeyIslandClient.get_agent_log() --- .../blackbox/island_client/monkey_island_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/envs/monkey_zoo/blackbox/island_client/monkey_island_client.py b/envs/monkey_zoo/blackbox/island_client/monkey_island_client.py index 85405af2d..ad30ef7f2 100644 --- a/envs/monkey_zoo/blackbox/island_client/monkey_island_client.py +++ b/envs/monkey_zoo/blackbox/island_client/monkey_island_client.py @@ -6,13 +6,14 @@ from typing import List, Mapping, Sequence, Union from bson import json_util from common.credentials import Credentials -from common.types import MachineID +from common.types import AgentID, MachineID from envs.monkey_zoo.blackbox.island_client.monkey_island_requests import MonkeyIslandRequests from envs.monkey_zoo.blackbox.test_configurations.test_configuration import TestConfiguration from monkey_island.cc.models import Agent, Machine SLEEP_BETWEEN_REQUESTS_SECONDS = 0.5 GET_AGENTS_ENDPOINT = "api/agents" +GET_LOG_ENDPOINT = "api/agent-logs" GET_MACHINES_ENDPOINT = "api/machines" MONKEY_TEST_ENDPOINT = "api/test/monkey" TELEMETRY_TEST_ENDPOINT = "api/test/telemetry" @@ -172,6 +173,11 @@ class MonkeyIslandClient(object): return {m.id: m for m in machines} + def get_agent_log(self, agent_id: AgentID) -> str: + response = self.requests.get(f"{GET_LOG_ENDPOINT}/{agent_id}") + + return response.json() + def find_log_in_db(self, query): response = self.requests.get( LOG_TEST_ENDPOINT, MonkeyIslandClient.form_find_query_for_request(query)