@@ -358,19 +399,36 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
LOGGER.debug("Error sending KPIs to monitoring server: {}".format(e))
defmonitor_ml_model_confidence(self):
"""
Get the monitored KPI for the confidence of the ML model
Args:
None
Returns:
confidence (float): The monitored KPI for the confidence of the ML model
"""
confidence=None
ifself.l3_security_status==0:
returnself.l3_ml_model_confidence_normal
confidence=self.l3_ml_model_confidence_normal
else:
confidence=self.l3_ml_model_confidence_crypto
returnself.l3_ml_model_confidence_crypto
returnconfidence
defperform_inference(self,request):
"""
Classify connection as standard traffic or cryptomining attack and return results
-input:
+ request: L3CentralizedattackdetectorMetrics object with connection features information
-output: L3AttackmitigatorOutput object with information about the assigned class and prediction confidence
Performs inference on the input data using the Cryptomining Attack Detector model to classify the connection as standard traffic or cryptomining attack.
Args:
request (L3CentralizedattackdetectorMetrics): A L3CentralizedattackdetectorMetrics object with connection features information.
Returns:
dict: A dictionary containing the predicted class, the probability of that class, and other relevant information required to block the attack.
@@ -444,14 +502,17 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
returnoutput_message
defperform_batch_inference(self,requests):
"""
Classify connection as standard traffic or cryptomining attack and return results
-input:
+ request: L3CentralizedattackdetectorMetrics object with connection features information
-output: L3AttackmitigatorOutput object with information about the assigned class and prediction confidence
Performs batch inference on the input data using the Cryptomining Attack Detector model to classify the connection as standard traffic or cryptomining attack.
Args:
requests (list): A list of L3CentralizedattackdetectorMetrics objects with connection features information.
Returns:
list: A list of dictionaries containing the predicted class, the probability of that class, and other relevant information required to block the attack for each request.
"""
defperform_distributed_inference(self,requests):
batch_size=len(requests)
# Create an empty array to hold the input data
@@ -534,15 +595,19 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
Receive features from Attack Mitigator, predict attack and communicate with Attack Mitigator
-input:
+ request: L3CentralizedattackdetectorMetrics object with connection features information
-output: Empty object with a message about the execution of the function
Analyzes the connection statistics sent in the request, performs batch inference on the input data using the Cryptomining Attack Detector model to classify the connection as standard traffic or cryptomining attack, and notifies the Attack Mitigator component in case of attack.
Args:
request (L3CentralizedattackdetectorMetrics): A L3CentralizedattackdetectorMetrics object with connection features information.
context (Empty): The context of the request.
Returns:
Empty: An empty response indicating that the information was received and processed.
Analyzes a batch of connection statistics sent in the request, performs batch inference on the input data using the Cryptomining Attack Detector model to classify the connection as standard traffic or cryptomining attack, and notifies the Attack Mitigator component in case of attack.
Args:
request (L3CentralizedattackdetectorBatchMetrics): A L3CentralizedattackdetectorBatchMetrics object with connection features information.
context (Empty): The context of the request.
Returns:
Empty: An empty response indicating that the information was received and processed.
"""
batch_time_start=time.time()
formetricinrequest.metrics:
@@ -761,16 +847,22 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
returnEmpty(message="OK, information received.")
@safe_and_metered_rpc_method(METRICS_POOL,LOGGER)
defGetFeaturesIds(self,request,context):
"""
Send features allocated in the metadata of the onnx file to the DAD
-output: ONNX metadata as a list of integers
Returns a list of feature IDs used by the Cryptomining Attack Detector model.
Args:
request (Empty): An empty request object.
context (Empty): The context of the request.
Returns:
features_ids (AutoFeatures): A list of feature IDs used by the Cryptomining Attack Detector model.