From 3e0bbf88cfa366073e8f13c46344fcf0da55d9c7 Mon Sep 17 00:00:00 2001 From: Damion R Mounts Date: Sun, 2 Jan 2022 22:54:45 -0500 Subject: [PATCH 1/2] Add API documentation for /contacts/{name} --- app/api/v2/handlers/contact_api.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/api/v2/handlers/contact_api.py b/app/api/v2/handlers/contact_api.py index 2308210e4..5d28e8344 100644 --- a/app/api/v2/handlers/contact_api.py +++ b/app/api/v2/handlers/contact_api.py @@ -15,7 +15,20 @@ def add_routes(self, app: web.Application): router = app.router router.add_get('/contacts/{name}', self.get_contact_report) - @aiohttp_apispec.docs(tags=['contacts']) + @aiohttp_apispec.docs(tags=['contacts'], + summary='Retrieve a List of Beacons made by Agents to the specified Contact', + description='Returns a list of beacons made by agents to the specified contact. The response' + ' is formatted as a list of dictionaries. The dictionaries have the keys "paw",' + ' "instructions", and "date". "paw" being the paw of the agent that made the' + ' beacon. "instructions" being a list of strings (commands) executed by the' + ' agent since its last beacon. "date" being a UTC date/time string.', + parameters=[{ + 'in': 'path', + 'name': 'name', + 'schema': {'type': 'string'}, + 'required': 'true', + 'description': 'Name of the contact to get beacons for, e.g. HTTP, TCP, et cetera.' + }]) async def get_contact_report(self, request: web.Request): contact_name = request.match_info['name'] report = self._api_manager.get_contact_report(contact_name) From c15df99fded82b3b490b3b8bb245fcb757a14ec6 Mon Sep 17 00:00:00 2001 From: Damion R Mounts Date: Thu, 6 Jan 2022 12:58:33 -0500 Subject: [PATCH 2/2] highlight dict keys returned --- app/api/v2/handlers/contact_api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/api/v2/handlers/contact_api.py b/app/api/v2/handlers/contact_api.py index 5d28e8344..b57841de9 100644 --- a/app/api/v2/handlers/contact_api.py +++ b/app/api/v2/handlers/contact_api.py @@ -18,10 +18,10 @@ def add_routes(self, app: web.Application): @aiohttp_apispec.docs(tags=['contacts'], summary='Retrieve a List of Beacons made by Agents to the specified Contact', description='Returns a list of beacons made by agents to the specified contact. The response' - ' is formatted as a list of dictionaries. The dictionaries have the keys "paw",' - ' "instructions", and "date". "paw" being the paw of the agent that made the' - ' beacon. "instructions" being a list of strings (commands) executed by the' - ' agent since its last beacon. "date" being a UTC date/time string.', + ' is formatted as a list of dictionaries. The dictionaries have the keys `paw`,' + ' `instructions`, and `date`. `paw` being the paw of the agent that made the' + ' beacon. `instructions` being a list of strings (commands) executed by the' + ' agent since its last beacon. `date` being a UTC date/time string.', parameters=[{ 'in': 'path', 'name': 'name',