diff --git a/manifests/l3_attackmitigatorservice.yaml b/manifests/l3_attackmitigatorservice.yaml index be335171f9d616bdbe5a31c335675c05fad58af3..7ac91b02fd2b3be51a9e810ae194fb0d7a9bf0d7 100644 --- a/manifests/l3_attackmitigatorservice.yaml +++ b/manifests/l3_attackmitigatorservice.yaml @@ -19,10 +19,6 @@ spec: ports: - containerPort: 10002 env: - - name: DB_ENGINE - value: "redis" - - name: REDIS_DATABASE_ID - value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: @@ -51,20 +47,3 @@ spec: - name: grpc port: 10002 targetPort: 10002 ---- -apiVersion: v1 -kind: Service -metadata: - name: attackmitigatorservice-public - labels: - app: attackmitigatorservice -spec: - type: NodePort - selector: - app: attackmitigatorservice - ports: - - name: grpc - protocol: TCP - port: 10002 - targetPort: 10002 ---- diff --git a/manifests/l3_centralizedattackdetectorservice.yaml b/manifests/l3_centralizedattackdetectorservice.yaml index 9381bf10d77a879e106839ac8f9e8135856df5f5..4b4b629294dc72f0d158b923364bb65d559df624 100644 --- a/manifests/l3_centralizedattackdetectorservice.yaml +++ b/manifests/l3_centralizedattackdetectorservice.yaml @@ -19,10 +19,6 @@ spec: ports: - containerPort: 10001 env: - - name: DB_ENGINE - value: "redis" - - name: REDIS_DATABASE_ID - value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: @@ -51,20 +47,3 @@ spec: - name: grpc port: 10001 targetPort: 10001 ---- -apiVersion: v1 -kind: Service -metadata: - name: centralizedattackdetectorservice-public - labels: - app: centralizedattackdetectorservice -spec: - type: NodePort - selector: - app: centralizedattackdetectorservice - ports: - - name: grpc - protocol: TCP - port: 10001 - targetPort: 10001 ---- diff --git a/manifests/l3_distributedattackdetectorservice.yaml b/manifests/l3_distributedattackdetectorservice.yaml index 1163ed87d98ac15f8428a254afdeb3e84fa63939..22157d9a4e9faa3af6ea76c6212c7914a0868726 100644 --- a/manifests/l3_distributedattackdetectorservice.yaml +++ b/manifests/l3_distributedattackdetectorservice.yaml @@ -19,10 +19,6 @@ spec: ports: - containerPort: 10000 env: - - name: DB_ENGINE - value: "redis" - - name: REDIS_DATABASE_ID - value: "0" - name: LOG_LEVEL value: "DEBUG" readinessProbe: @@ -51,20 +47,3 @@ spec: - name: grpc port: 10000 targetPort: 10000 ---- -apiVersion: v1 -kind: Service -metadata: - name: distributedattackdetectorservice-public - labels: - app: distributedattackdetectorservice -spec: - type: NodePort - selector: - app: distributedattackdetectorservice - ports: - - name: grpc - protocol: TCP - port: 10000 - targetPort: 10000 ---- diff --git a/report_coverage_l3_attackmitigator.sh b/report_coverage_l3_attackmitigator.sh index 9ae29d8130123fda53c03b17f634e40be140c7a3..74df2c280b94af016d974a56e1019e42a54d6753 100644 --- a/report_coverage_l3_attackmitigator.sh +++ b/report_coverage_l3_attackmitigator.sh @@ -1,3 +1,3 @@ #!/bin/bash -./report_coverage_all.sh | grep --color -E -i "^attackmitigator/.*$|$" +./report_coverage_all.sh | grep --color -E -i "^l3_attackmitigator/.*$|$" diff --git a/report_coverage_l3_centralizedattackdetector.sh b/report_coverage_l3_centralizedattackdetector.sh index ea34a11315cfdfbc8c05427c8d4f6e78dad4b42c..46faba45d245bd951c80652af8f3eed8e56a8ab6 100644 --- a/report_coverage_l3_centralizedattackdetector.sh +++ b/report_coverage_l3_centralizedattackdetector.sh @@ -1,3 +1,3 @@ #!/bin/bash -./report_coverage_all.sh | grep --color -E -i "^centralizedattackdetector/.*$|$" +./report_coverage_all.sh | grep --color -E -i "^l3_centralizedattackdetector/.*$|$" diff --git a/report_coverage_l3_distributedattackdetector.sh b/report_coverage_l3_distributedattackdetector.sh index 842a55de4b39090f9366c4042543a186327d684a..eff6b1ce5e96f4500ae0efc58e6da586cf36fd25 100644 --- a/report_coverage_l3_distributedattackdetector.sh +++ b/report_coverage_l3_distributedattackdetector.sh @@ -1,3 +1,3 @@ #!/bin/bash -./report_coverage_all.sh | grep --color -E -i "^distributedattackdetector/.*$|$" +./report_coverage_all.sh | grep --color -E -i "^l3_distributedattackdetector/.*$|$" diff --git a/src/l3_attackmitigator/client/l3_attackmitigatorClient.py b/src/l3_attackmitigator/client/l3_attackmitigatorClient.py index dca6c60ec1a2469087a30e544a27d7fd94e5f3ee..190d6388459151e42fdebd0642fb9ccde3621ce0 100644 --- a/src/l3_attackmitigator/client/l3_attackmitigatorClient.py +++ b/src/l3_attackmitigator/client/l3_attackmitigatorClient.py @@ -3,6 +3,10 @@ from common.tools.client.RetryDecorator import retry, delay_exponential from l3_attackmitigator.proto.l3_attackmitigator_pb2_grpc import ( L3AttackmitigatorStub, ) +from l3_attackmitigator.proto.l3_attackmitigator_pb2 import ( + Output, + EmptyMitigator +) LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 @@ -28,3 +32,17 @@ class l3_attackmitigatorClient: self.channel = None self.stub = None + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def SendOutput(self, request: Output) -> EmptyMitigator: + LOGGER.debug('SendOutput request: {}'.format(request)) + response = self.stub.SendOutput(request) + LOGGER.debug('SendOutput result: {}'.format(response)) + return response + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def GetMitigation(self, request: EmptyMitigator) -> EmptyMitigator: + LOGGER.debug('GetMitigation request: {}'.format(request)) + response = self.stub.GetMitigation(request) + LOGGER.debug('GetMitigation result: {}'.format(response)) + return response + diff --git a/src/l3_attackmitigator/requirements.in b/src/l3_attackmitigator/requirements.in index 7a76467307d14566540fd4a327c980b042452009..e11480b450adad83b398c2a6a21cf8fe1a7b186d 100644 --- a/src/l3_attackmitigator/requirements.in +++ b/src/l3_attackmitigator/requirements.in @@ -6,4 +6,3 @@ pytest pytest-benchmark numpy scikit-learn -redis diff --git a/src/l3_attackmitigator/service/__main__.py b/src/l3_attackmitigator/service/__main__.py index 3843c6c18e4dc6f72c07bad6e0a71880a73b82de..baa85988bd169e9ce54afcb97689d3f1c9ac4b3a 100644 --- a/src/l3_attackmitigator/service/__main__.py +++ b/src/l3_attackmitigator/service/__main__.py @@ -1,7 +1,6 @@ import logging, signal, sys, threading, os from prometheus_client import start_http_server from common.Settings import get_setting -from common.orm.Factory import get_database_backend as get_database from l3_attackmitigator.service.l3_attackmitigatorService import l3_attackmitigatorService from l3_attackmitigator.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT @@ -33,9 +32,6 @@ def main(): # Start metrics server start_http_server(metrics_port) - # Get database instance - #database = get_database() - # Starting l3_attackmitigator service grpc_service = l3_attackmitigatorService( port=service_port, max_workers=max_workers, grace_period=grace_period) diff --git a/src/l3_attackmitigator/service/l3_attackmitigatorServiceServicerImpl.py b/src/l3_attackmitigator/service/l3_attackmitigatorServiceServicerImpl.py index ce365548bc28384d7c6443a611179ae68e0cc0f5..725dc36b4907579c494845a3e8e594acca31059e 100644 --- a/src/l3_attackmitigator/service/l3_attackmitigatorServiceServicerImpl.py +++ b/src/l3_attackmitigator/service/l3_attackmitigatorServiceServicerImpl.py @@ -1,69 +1,40 @@ from __future__ import print_function -from concurrent import futures -from subprocess import Popen, DEVNULL -import argparse -import sys -import time -import os -import grpc import logging -from typing import Dict -import grpc, logging -from prometheus_client import Counter, Histogram -from common.orm.Database import Database -from l3_attackmitigator.proto.context_pb2 import Empty from l3_attackmitigator.proto.l3_attackmitigator_pb2 import ( EmptyMitigator ) from l3_attackmitigator.proto.l3_attackmitigator_pb2_grpc import ( L3AttackmitigatorServicer, - add_L3AttackmitigatorServicer_to_server ) LOGGER = logging.getLogger(__name__) -LAST_VALUE = -1 - - class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer): def __init__(self): LOGGER.debug("Creating Servicer...") + self.last_value = -1 + self.last_tag = 0 def SendOutput(self, request, context): # SEND CONFIDENCE TO MITIGATION SERVER logging.debug("") print("Server received mitigation values...", request.confidence) - LAST_VALUE = request.confidence - LAST_TAG = request.tag + last_value = request.confidence + last_tag = request.tag # RETURN OK TO THE CALLER return EmptyMitigator( - message=f"OK, received values: {LAST_TAG} with confidence {LAST_VALUE}." + message=f"OK, received values: {last_tag} with confidence {last_value}." ) def GetMitigation(self, request, context): # GET OR PERFORM MITIGATION STRATEGY logging.debug("") print("Returing mitigation strategy...") - k = LAST_VALUE * 2 + k = self.last_value * 2 return EmptyMitigator( message=f"Mitigation with double confidence = {k}" ) - ''' - def serve(self): - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - add_L3AttackmitigatorServicer_to_server(self.Mitigator(), server) - server.add_insecure_port('[::]:10002') - server.start() - print('Server Started') - server.wait_for_termination() - print('Server Terminated') - - def setupl3_attackmitigator(self): - logging.basicConfig() - self.serve() - ''' - diff --git a/src/l3_attackmitigator/tests/test_unitary.py b/src/l3_attackmitigator/tests/test_unitary.py index 7ef202f2455d605f33c6ab19f272647009316d20..1aa6fc4a843ae04e4d520507c789c669eefcd31a 100644 --- a/src/l3_attackmitigator/tests/test_unitary.py +++ b/src/l3_attackmitigator/tests/test_unitary.py @@ -1,21 +1,11 @@ -import copy -import grpc import logging import pytest -import multiprocessing -import subprocess -import time -from l3_attackmitigator.proto.monitoring_pb2 import Kpi, KpiList -from common.orm.Factory import get_database_backend as get_database, BackendEnum as DatabaseEngineEnum from l3_attackmitigator.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from l3_attackmitigator.client.l3_attackmitigatorClient import l3_attackmitigatorClient from l3_attackmitigator.service.l3_attackmitigatorService import l3_attackmitigatorService from l3_attackmitigator.proto.l3_attackmitigator_pb2 import ( Output, ) -from l3_attackmitigator.proto.l3_attackmitigator_pb2_grpc import ( - L3AttackmitigatorStub, -) port = 10000 + GRPC_SERVICE_PORT # avoid privileged ports @@ -43,30 +33,21 @@ def test_demo(): LOGGER.info('Demo Test') pass -def test_grpc_server(l3_attackmitigator_service): +def test_grpc_server(l3_attackmitigator_client): output_message = { - "confidence": 0.8, - "timestamp": "date", - "ip_o": "randomIP", - "tag_name": "HTTP", - "tag": 0, - "flow_id": "FlowID", - "protocol": "RandomProtocol", - "port_d": "3456", - "ml_id": "RandomForest", - "time_start": 0.0, - "time_end": 10.0, - } - - def open_channel(input_information): - LOGGER.info(str(f"localhost:{port}")) - with grpc.insecure_channel(f"localhost:{port}") as channel: - stub = L3AttackmitigatorStub(channel) - response = stub.SendOutput(input_information) - LOGGER.info("Inferencer send_input sent and received: "+str(response.message)) - try: - open_channel(Output(**output_message)) - LOGGER.info('Success!') - except: - assert 0=="GRPC server failed" - + "confidence": 0.8, + "timestamp": "date", + "ip_o": "randomIP", + "tag_name": "HTTP", + "tag": 0, + "flow_id": "FlowID", + "protocol": "RandomProtocol", + "port_d": "3456", + "ml_id": "RandomForest", + "time_start": 0.0, + "time_end": 10.0, + } + response = l3_attackmitigator_client.SendOutput(Output(**output_message)) + LOGGER.info("Inferencer send_input sent and received: " + + str(response.message)) + LOGGER.info('Success!') diff --git a/src/l3_centralizedattackdetector/client/l3_centralizedattackdetectorClient.py b/src/l3_centralizedattackdetector/client/l3_centralizedattackdetectorClient.py index cc08a7559217ae39f6f16c726359bbd9ea8bf956..cd1178348aaa862dbabfd7be6e44bbd43cf0c439 100644 --- a/src/l3_centralizedattackdetector/client/l3_centralizedattackdetectorClient.py +++ b/src/l3_centralizedattackdetector/client/l3_centralizedattackdetectorClient.py @@ -4,12 +4,16 @@ from l3_centralizedattackdetector.proto.context_pb2 import Empty from l3_centralizedattackdetector.proto.l3_centralizedattackdetector_pb2_grpc import ( L3CentralizedattackdetectorStub, ) +from l3_centralizedattackdetector.proto.l3_centralizedattackdetector_pb2 import ( + Empty, + ModelInput, + ModelOutput +) LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) - class l3_centralizedattackdetectorClient: def __init__(self, address, port): self.endpoint = "{}:{}".format(address, port) @@ -30,10 +34,17 @@ class l3_centralizedattackdetectorClient: self.stub = None @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') - def DetectAttack(self, request : Empty) -> Empty: - LOGGER.debug('DetectAttack request: {}'.format(request)) - response = self.stub.DetectAttack(request) - LOGGER.debug('DetectAttack result: {}'.format(response)) + def SendInput(self, request: ModelInput) -> Empty: + LOGGER.debug('SendInput request: {}'.format(request)) + response = self.stub.SendInput(request) + LOGGER.debug('SendInput result: {}'.format(response)) + return response + + @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect') + def GetOutput(self, request: Empty) -> ModelOutput: + LOGGER.debug('GetOutput request: {}'.format(request)) + response = self.stub.GetOutput(request) + LOGGER.debug('GetOutput result: {}'.format(response)) return response diff --git a/src/l3_centralizedattackdetector/requirements.in b/src/l3_centralizedattackdetector/requirements.in index 7a76467307d14566540fd4a327c980b042452009..e3d53682f3c0002168ff3b9744310ce7ceb1866b 100644 --- a/src/l3_centralizedattackdetector/requirements.in +++ b/src/l3_centralizedattackdetector/requirements.in @@ -5,5 +5,4 @@ prometheus-client pytest pytest-benchmark numpy -scikit-learn -redis +scikit-learn \ No newline at end of file diff --git a/src/l3_centralizedattackdetector/service/__main__.py b/src/l3_centralizedattackdetector/service/__main__.py index 1e593111bf580e692115de502c2817cea0a821dc..b05d5b14782a7dae8b34a49e03c0d00e1b39d3ca 100644 --- a/src/l3_centralizedattackdetector/service/__main__.py +++ b/src/l3_centralizedattackdetector/service/__main__.py @@ -1,7 +1,6 @@ import logging, signal, sys, threading, os from prometheus_client import start_http_server from common.Settings import get_setting -from common.orm.Factory import get_database_backend as get_database from l3_centralizedattackdetector.service.l3_centralizedattackdetectorService import l3_centralizedattackdetectorService from l3_centralizedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD, LOG_LEVEL, METRICS_PORT diff --git a/src/l3_centralizedattackdetector/service/l3_centralizedattackdetectorServiceServicerImpl.py b/src/l3_centralizedattackdetector/service/l3_centralizedattackdetectorServiceServicerImpl.py index 993198c5e2f641ee0d0669e6d1b2d259afea14bc..47ba5fe3765494461e3719cf3d5288170cded636 100644 --- a/src/l3_centralizedattackdetector/service/l3_centralizedattackdetectorServiceServicerImpl.py +++ b/src/l3_centralizedattackdetector/service/l3_centralizedattackdetectorServiceServicerImpl.py @@ -1,24 +1,16 @@ from __future__ import print_function -from concurrent import futures -from subprocess import Popen, DEVNULL -import argparse -import sys -import time from datetime import datetime import os import grpc import numpy as np import pickle as pkl import logging -import grpc, logging -from common.orm.Database import Database from l3_centralizedattackdetector.proto.context_pb2 import Empty from l3_centralizedattackdetector.proto.l3_centralizedattackdetector_pb2 import ( Empty, ) from l3_centralizedattackdetector.proto.l3_centralizedattackdetector_pb2_grpc import ( L3CentralizedattackdetectorServicer, - add_L3CentralizedattackdetectorServicer_to_server ) from l3_centralizedattackdetector.proto.l3_attackmitigator_pb2 import ( @@ -31,48 +23,17 @@ from l3_centralizedattackdetector.proto.l3_attackmitigator_pb2_grpc import ( LOGGER = logging.getLogger(__name__) here = os.path.dirname(os.path.abspath(__file__)) MODEL_FILE = os.path.join(here, "ml_model/RF_Netflow_TF") -INFERENCE_VALUES = [] - class l3_centralizedattackdetectorServiceServicerImpl(L3CentralizedattackdetectorServicer): def __init__(self): LOGGER.debug("Creating Servicer...") + self.inference_values = [] with open(MODEL_FILE, "rb") as f: self.ml_model = pkl.load(f) - def SendInput(self, request, context): - # PERFORM INFERENCE WITH SENT INPUTS - logging.debug("") - print("Inferencing ...") - - # STORE VALUES - INFERENCE_VALUES.append(request) - - # MAKE INFERENCE - output = self.make_inference(request) - - # SEND INFO TO MITIGATION SERVER - try: - with grpc.insecure_channel("localhost:10002") as channel: - stub = L3AttackmitigatorStub(channel) - print("Sending to mitigator...") - response = stub.SendOutput(output) - print("Sent output to mitigator and received: ", response.message) - - # RETURN "OK" TO THE CALLER - return Empty( - message="OK, information received and mitigator notified" - ) - except: - print('Couldnt find l3_attackmitigator') - return Empty( - message="Mitigator Not found" - ) - def make_inference(self, request): # ML MODEL - # new_predictions = model.predict_proba(list(new_connections.values())) predictions = self.ml_model.predict_proba( [ [ @@ -112,32 +73,42 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto return Output(**output_message) + def SendInput(self, request, context): + # PERFORM INFERENCE WITH SENT INPUTS + logging.debug("") + print("Inferencing ...") + + # STORE VALUES + self.inference_values.append(request) + + # MAKE INFERENCE + output = self.make_inference(request) + + # SEND INFO TO MITIGATION SERVER + try: + with grpc.insecure_channel("localhost:10002") as channel: + stub = L3AttackmitigatorStub(channel) + print("Sending to mitigator...") + response = stub.SendOutput(output) + print("Sent output to mitigator and received: ", response.message) + + # RETURN "OK" TO THE CALLER + return Empty( + message="OK, information received and mitigator notified" + ) + except: + print('Couldnt find l3_attackmitigator') + return Empty( + message="Mitigator Not found" + ) + def GetOutput(self, request, context): logging.debug("") print("Returing inference output...") - k = np.multiply(INFERENCE_VALUES, [2]) + k = np.multiply(self.inference_values, [2]) k = np.sum(k) return self.make_inference(k) - ''' - def setup_l3_centralizedattackdetector(self): - print('Starting CAD') - with open(MODEL_FILE, "rb") as f: - ml_model = pkl.load(f) - server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - add_L3CentralizedattackdetectorServicer_to_server( - self.CAD(ml_model), server) - server.add_insecure_port("[::]:10001") - server.start() - server.wait_for_termination() - - def DetectAttack(self, request: Empty, grpc_context: grpc.ServicerContext) -> Empty: - LOGGER.debug('DetectAttack request: {}'.format(str(request))) - reply = Empty() - LOGGER.debug('DetectAttack reply: {}'.format(str(reply))) - return reply - ''' - diff --git a/src/l3_centralizedattackdetector/tests/test_unitary.py b/src/l3_centralizedattackdetector/tests/test_unitary.py index e7cabcba5bf72ee95a4724e2193695879e6df75f..2f991feda3c9b421b5cffc591fa404f38e038e35 100644 --- a/src/l3_centralizedattackdetector/tests/test_unitary.py +++ b/src/l3_centralizedattackdetector/tests/test_unitary.py @@ -1,13 +1,8 @@ -import copy -import grpc import logging import pytest from l3_centralizedattackdetector.Config import GRPC_SERVICE_PORT, GRPC_MAX_WORKERS, GRPC_GRACE_PERIOD from l3_centralizedattackdetector.client.l3_centralizedattackdetectorClient import l3_centralizedattackdetectorClient from l3_centralizedattackdetector.service.l3_centralizedattackdetectorService import l3_centralizedattackdetectorService -from l3_centralizedattackdetector.proto.l3_centralizedattackdetector_pb2_grpc import ( - L3CentralizedattackdetectorStub, -) from l3_centralizedattackdetector.proto.l3_centralizedattackdetector_pb2 import ( ModelInput, ) @@ -36,33 +31,29 @@ def test_demo(): LOGGER.info('Demo Test') pass -def test_system(l3_centralizedattackdetector_service): + +def test_system(l3_centralizedattackdetector_client): inference_information = { - "n_packets_server_seconds": 5.0, - "n_packets_client_seconds": 5.0, - "n_bits_server_seconds": 5.0, - "n_bits_client_seconds": 5.0, - "n_bits_server_n_packets_server": 5.0, - "n_bits_client_n_packets_client": 5.0, - "n_packets_server_n_packets_client": 5.0, - "n_bits_server_n_bits_client": 5.0, - "ip_o": "ipo", - "port_o": "porto", - "ip_d": "ipd", - "port_d": "portd", - "flow_id": "flowid", - "protocol": "protocol", - "time_start": 0.0, - "time_end": 10.0, + "n_packets_server_seconds": 5.0, + "n_packets_client_seconds": 5.0, + "n_bits_server_seconds": 5.0, + "n_bits_client_seconds": 5.0, + "n_bits_server_n_packets_server": 5.0, + "n_bits_client_n_packets_client": 5.0, + "n_packets_server_n_packets_client": 5.0, + "n_bits_server_n_bits_client": 5.0, + "ip_o": "ipo", + "port_o": "porto", + "ip_d": "ipd", + "port_d": "portd", + "flow_id": "flowid", + "protocol": "protocol", + "time_start": 0.0, + "time_end": 10.0, } - def open_channel(input_information): - LOGGER.info(str(f"localhost:{port}")) - with grpc.insecure_channel(f"localhost:{port}") as channel: - stub = L3CentralizedattackdetectorStub(channel) - response = stub.SendInput(input_information) - LOGGER.info("Cad send_input sent and received: "+str(response.message)) - try: - open_channel(ModelInput(**inference_information)) - except: - assert 0=="GRPC server failed" + response = l3_centralizedattackdetector_client.SendInput( + ModelInput(**inference_information)) + LOGGER.info("Cad send_input sent and received: "+str(response.message)) + LOGGER.info('Success!') + diff --git a/src/l3_distributedattackdetector/client/l3_distributedattackdetectorClient.py b/src/l3_distributedattackdetector/client/l3_distributedattackdetectorClient.py index 03ae029ee1bf6233bebb058ceef6baf3343b2c3b..4f061ac79c67d443225af5bb9a78564f9957e7cb 100644 --- a/src/l3_distributedattackdetector/client/l3_distributedattackdetectorClient.py +++ b/src/l3_distributedattackdetector/client/l3_distributedattackdetectorClient.py @@ -1,7 +1,5 @@ import grpc, logging from common.tools.client.RetryDecorator import retry, delay_exponential -from l3_distributedattackdetector.proto.context_pb2 import Empty -from l3_distributedattackdetector.proto.monitoring_pb2 import KpiList from l3_distributedattackdetector.proto.l3_centralizedattackdetector_pb2_grpc import ( L3CentralizedattackdetectorStub, ) @@ -10,7 +8,6 @@ LOGGER = logging.getLogger(__name__) MAX_RETRIES = 15 DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0) - class l3_distributedattackdetectorClient: def __init__(self, address, port): self.endpoint = "{}:{}".format(address, port) diff --git a/src/l3_distributedattackdetector/requirements.in b/src/l3_distributedattackdetector/requirements.in index 7a76467307d14566540fd4a327c980b042452009..e11480b450adad83b398c2a6a21cf8fe1a7b186d 100644 --- a/src/l3_distributedattackdetector/requirements.in +++ b/src/l3_distributedattackdetector/requirements.in @@ -6,4 +6,3 @@ pytest pytest-benchmark numpy scikit-learn -redis