BB: Add MonkeyIslandClient.get_agent_log()

This commit is contained in:
Mike Salvatore 2022-10-01 19:59:46 -04:00
parent 99c2c5c6ef
commit c706466cdd
1 changed files with 7 additions and 1 deletions

View File

@ -6,13 +6,14 @@ from typing import List, Mapping, Sequence, Union
from bson import json_util from bson import json_util
from common.credentials import Credentials 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.island_client.monkey_island_requests import MonkeyIslandRequests
from envs.monkey_zoo.blackbox.test_configurations.test_configuration import TestConfiguration from envs.monkey_zoo.blackbox.test_configurations.test_configuration import TestConfiguration
from monkey_island.cc.models import Agent, Machine from monkey_island.cc.models import Agent, Machine
SLEEP_BETWEEN_REQUESTS_SECONDS = 0.5 SLEEP_BETWEEN_REQUESTS_SECONDS = 0.5
GET_AGENTS_ENDPOINT = "api/agents" GET_AGENTS_ENDPOINT = "api/agents"
GET_LOG_ENDPOINT = "api/agent-logs"
GET_MACHINES_ENDPOINT = "api/machines" GET_MACHINES_ENDPOINT = "api/machines"
MONKEY_TEST_ENDPOINT = "api/test/monkey" MONKEY_TEST_ENDPOINT = "api/test/monkey"
TELEMETRY_TEST_ENDPOINT = "api/test/telemetry" TELEMETRY_TEST_ENDPOINT = "api/test/telemetry"
@ -172,6 +173,11 @@ class MonkeyIslandClient(object):
return {m.id: m for m in machines} 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): def find_log_in_db(self, query):
response = self.requests.get( response = self.requests.get(
LOG_TEST_ENDPOINT, MonkeyIslandClient.form_find_query_for_request(query) LOG_TEST_ENDPOINT, MonkeyIslandClient.form_find_query_for_request(query)