Island: Add ConfiguredPropagationCredentials resource
This commit is contained in:
parent
bda661c7ae
commit
e8cd88420b
|
@ -28,6 +28,9 @@ from monkey_island.cc.resources.blackbox.monkey_blackbox_endpoint import MonkeyB
|
|||
from monkey_island.cc.resources.blackbox.telemetry_blackbox_endpoint import (
|
||||
TelemetryBlackboxEndpoint,
|
||||
)
|
||||
from monkey_island.cc.resources.credentials.configured_propagation_credentials import (
|
||||
ConfiguredPropagationCredentials,
|
||||
)
|
||||
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
|
||||
|
@ -185,6 +188,8 @@ def init_restful_endpoints(api: FlaskDIWrapper):
|
|||
api.add_resource(FileUpload)
|
||||
|
||||
api.add_resource(PropagationCredentials)
|
||||
api.add_resource(ConfiguredPropagationCredentials)
|
||||
|
||||
api.add_resource(RemoteRun)
|
||||
api.add_resource(VersionUpdate)
|
||||
api.add_resource(StopAgentCheck)
|
||||
|
|
|
@ -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 ConfiguredPropagationCredentials(AbstractResource):
|
||||
# API Spec: Resource name should be plural
|
||||
urls = ["/api/propagation-credentials/configured"]
|
||||
|
||||
def __init__(self, credentials_repository: ICredentialsRepository):
|
||||
self._credentials_repository = credentials_repository
|
||||
|
||||
def get(self):
|
||||
return jsonify(self._credentials_repository.get_configured_credentials())
|
||||
|
||||
def post(self):
|
||||
credentials = Credentials.from_mapping(request.json)
|
||||
self._credentials_repository.save_configured_credentials(credentials)
|
||||
|
||||
def delete(self):
|
||||
self._credentials_repository.remove_configured_credentials()
|
Loading…
Reference in New Issue