From 107a15b5f00aeab79051b78767b2aff12d0302f2 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 19 Sep 2022 20:05:19 -0400 Subject: [PATCH] Agent: Call raise_for_status() in HTTPIslandAPIClient --- .../island_api_client/http_island_api_client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/island_api_client/http_island_api_client.py b/monkey/infection_monkey/island_api_client/http_island_api_client.py index 15afd5e44..37feb8942 100644 --- a/monkey/infection_monkey/island_api_client/http_island_api_client.py +++ b/monkey/infection_monkey/island_api_client/http_island_api_client.py @@ -46,23 +46,25 @@ class HTTPIslandAPIClient(IIslandAPIClient): @handle_island_errors def __init__(self, island_server: str): - requests.get( # noqa: DUO123 + response = requests.get( # noqa: DUO123 f"https://{island_server}/api?action=is-up", verify=False, timeout=MEDIUM_REQUEST_TIMEOUT, ) + response.raise_for_status() self._island_server = island_server self._api_url = f"https://{self._island_server}/api" @handle_island_errors def send_log(self, log_contents: str): - requests.post( # noqa: DUO123 + response = requests.post( # noqa: DUO123 f"{self._api_url}/log", json=log_contents, verify=False, timeout=MEDIUM_REQUEST_TIMEOUT, ) + response.raise_for_status() @handle_island_errors def get_pba_file(self, filename: str): @@ -71,5 +73,6 @@ class HTTPIslandAPIClient(IIslandAPIClient): verify=False, timeout=LONG_REQUEST_TIMEOUT, ) + response.raise_for_status() return response.content