Island: Use HTTPStatus enum in new endpoints

This commit is contained in:
Mike Salvatore 2022-07-12 06:52:44 -04:00
parent 774b2c0116
commit fb1a3bcd74
3 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import logging
from http import HTTPStatus
from flask import make_response, send_file
@ -34,7 +35,7 @@ class AgentBinaries(AbstractResource):
except KeyError as err:
error_msg = f'No Agents are available for unsupported operating system "{os}": {err}'
logger.error(error_msg)
return make_response({"error": error_msg}, 404)
return make_response({"error": error_msg}, HTTPStatus.NOT_FOUND)
except RetrievalError as err:
logger.error(err)
return make_response({"error": str(err)}, 500)
return make_response({"error": str(err)}, HTTPStatus.INTERNAL_SERVER_ERROR)

View File

@ -1,3 +1,5 @@
from http import HTTPStatus
from flask import make_response
from monkey_island.cc.repository.i_credentials_repository import ICredentialsRepository
@ -20,4 +22,4 @@ class ClearSimulationData(AbstractResource):
Database.reset_db(reset_config=False)
self._credentials_repository.remove_stolen_credentials()
return make_response({}, 200)
return make_response({}, HTTPStatus.OK)

View File

@ -1,3 +1,5 @@
from http import HTTPStatus
from flask import make_response
from monkey_island.cc.repository import IAgentConfigurationRepository
@ -18,4 +20,4 @@ class ResetAgentConfiguration(AbstractResource):
"""
self._agent_configuration_repository.reset_to_default()
return make_response({}, 200)
return make_response({}, HTTPStatus.OK)