diff --git a/CHANGELOG.md b/CHANGELOG.md index f78b06508..b637ed441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - `/api/clear-simulation-data` endpoint. #2036 - `/api/registration-status` endpoint. #2149 - authentication to `/api/island/version`. #2109 +- `/api/events` endpoint. #2155 ### Changed - Reset workflow. Now it's possible to delete data gathered by agents without diff --git a/monkey/monkey_island/cc/app.py b/monkey/monkey_island/cc/app.py index c837328fc..c522c3082 100644 --- a/monkey/monkey_island/cc/app.py +++ b/monkey/monkey_island/cc/app.py @@ -14,6 +14,7 @@ from monkey_island.cc.resources import ( AgentBinaries, AgentConfiguration, ClearSimulationData, + Events, IPAddresses, IslandLog, PBAFileDownload, @@ -179,6 +180,8 @@ def init_restful_endpoints(api: FlaskDIWrapper): api.add_resource(IslandLog) api.add_resource(IPAddresses) + api.add_resource(Events) + # API Spec: These two should be the same resource, GET for download and POST for upload api.add_resource(PBAFileDownload) api.add_resource(PBAFileUpload) diff --git a/monkey/monkey_island/cc/resources/__init__.py b/monkey/monkey_island/cc/resources/__init__.py index d04190b7c..b58e159bc 100644 --- a/monkey/monkey_island/cc/resources/__init__.py +++ b/monkey/monkey_island/cc/resources/__init__.py @@ -8,3 +8,4 @@ from .ip_addresses import IPAddresses from .agent_configuration import AgentConfiguration from .pba_file_upload import PBAFileUpload, LINUX_PBA_TYPE, WINDOWS_PBA_TYPE from .pba_file_download import PBAFileDownload +from .events import Events diff --git a/monkey/monkey_island/cc/resources/events.py b/monkey/monkey_island/cc/resources/events.py new file mode 100644 index 000000000..1aa2092ea --- /dev/null +++ b/monkey/monkey_island/cc/resources/events.py @@ -0,0 +1,20 @@ +import logging +from http import HTTPStatus + +from flask import request + +from monkey_island.cc.resources.AbstractResource import AbstractResource + +logger = logging.getLogger(__name__) + + +class Events(AbstractResource): + urls = ["/api/events"] + + # Agents needs this + def post(self): + event = request.json + + logger.info(f"Event: {event}") + + return {}, HTTPStatus.NO_CONTENT