Island: Add StolenPropagationCredentials resource

This commit is contained in:
vakarisz 2022-07-08 17:09:44 +03:00 committed by Mike Salvatore
parent e8cd88420b
commit 90b8b3fc4e
3 changed files with 31 additions and 0 deletions

View File

@ -31,6 +31,9 @@ from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import (
from monkey_island.cc.resources.credentials.configured_propagation_credentials import (
ConfiguredPropagationCredentials,
)
from monkey_island.cc.resources.credentials.stolen_propagation_credentials import (
StolenPropagationCredentials,
)
from monkey_island.cc.resources.edge import Edge
from monkey_island.cc.resources.exploitations.manual_exploitation import ManualExploitation
from monkey_island.cc.resources.exploitations.monkey_exploitation import MonkeyExploitation
@ -189,6 +192,7 @@ def init_restful_endpoints(api: FlaskDIWrapper):
api.add_resource(PropagationCredentials)
api.add_resource(ConfiguredPropagationCredentials)
api.add_resource(StolenPropagationCredentials)
api.add_resource(RemoteRun)
api.add_resource(VersionUpdate)

View File

@ -0,0 +1,27 @@
import logging
from flask import jsonify, request
from common.credentials import Credentials
from monkey_island.cc.repository import ICredentialsRepository
from monkey_island.cc.resources.AbstractResource import AbstractResource
logger = logging.getLogger(__name__)
class StolenPropagationCredentials(AbstractResource):
# API Spec: Resource name should be plural
urls = ["/api/propagation-credentials/stolen"]
def __init__(self, credentials_repository: ICredentialsRepository):
self._credentials_repository = credentials_repository
def get(self):
return jsonify(self._credentials_repository.get_stolen_credentials())
def post(self):
credentials = Credentials.from_mapping(request.json)
self._credentials_repository.save_stolen_credentials(credentials)
def delete(self):
self._credentials_repository.remove_stolen_credentials()