Commit 06d38829 authored by Luis de la Cal's avatar Luis de la Cal
Browse files

- Added EndpointId in the Centralized Attack Detector component.

- Enabled the correct code in the Attack Mitigator component to properly configure ACL rules in the corresponding service to block detected attack connections.
parent 064ffb26
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -146,8 +146,8 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
        )
        acl_entry.match.src_address = "{}/32".format(src_ip)
        acl_entry.match.dst_address = "{}/32".format(dst_ip)
        acl_entry.match.src_port = src_port
        acl_entry.match.dst_port = dst_port
        acl_entry.match.src_port = int(src_port)
        acl_entry.match.dst_port = int(dst_port)
        # TODO: update the following parameters; for instance, add them as parameters of the method configure_acl_rule
        acl_entry.action.forward_action = AclForwardActionEnum.ACLFORWARDINGACTION_DROP
        acl_entry.action.log_action = AclLogActionEnum.ACLLOGACTION_NOLOG
@@ -194,23 +194,23 @@ class l3_attackmitigatorServiceServicerImpl(L3AttackmitigatorServicer):
        LOGGER.info("Service obtained from ServiceId:\n{}".format(service))

        # Old version
        config_rule = self.GetConfigRule(ip_o, ip_d, port_o, port_d)
        # config_rule = self.GetConfigRule(ip_o, ip_d, port_o, port_d)

        service_config = ServiceConfig()
        service_config.config_rules.extend([config_rule])
        service.service_config.CopyFrom(service_config)
        # service_config = ServiceConfig()
        # service_config.config_rules.extend([config_rule])
        # service.service_config.CopyFrom(service_config)

        # New version
        # self.configure_acl_rule(
        #     context_uuid=service_id.context_id.context_uuid.uuid,
        #     service_uuid=service_id.service_uuid.uuid,
        #     device_uuid=request.device_id.device_uuid.uuid,
        #     endpoint_uuid=request.endpoint_id.endpoint_uuid.uuid,
        #     src_ip=ip_o,
        #     dst_ip=ip_d,
        #     src_port=port_o,
        #     dst_port=port_d,
        # )
        self.configure_acl_rule(
            context_uuid=service_id.context_id.context_uuid.uuid,
            service_uuid=service_id.service_uuid.uuid,
            device_uuid=request.endpoint_id.device_id.device_uuid.uuid,
            endpoint_uuid=request.endpoint_id.endpoint_uuid.uuid,
            src_ip=ip_o,
            dst_ip=ip_d,
            src_port=port_o,
            dst_port=port_d,
        )

        LOGGER.info("Service with new rule:\n{}".format(service))
        self.UpdateService(service)
+1 −1
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
            "port_d": request.port_d,
            "ml_id": "RandomForest",
            "service_id": request.service_id,
            "endpoint_id": request.endpoint_id,
            "time_start": request.time_start,
            "time_end": request.time_end,
        }
@@ -203,4 +204,3 @@ class l3_centralizedattackdetectorServiceServicerImpl(L3Centralizedattackdetecto
        k = np.sum(k)

        return self.make_inference(k)