diff --git a/src/main/java/com/realtime/protection/configuration/entity/task/FiveTupleWithMask.java b/src/main/java/com/realtime/protection/configuration/entity/task/FiveTupleWithMask.java index baf5747..cb8f844 100644 --- a/src/main/java/com/realtime/protection/configuration/entity/task/FiveTupleWithMask.java +++ b/src/main/java/com/realtime/protection/configuration/entity/task/FiveTupleWithMask.java @@ -90,4 +90,26 @@ public class FiveTupleWithMask { assert protocol != null; this.protocolNum = protocol.getNumber(); } + + public void setMask() { + if (this.sourceIP != null && this.maskSourceIP == null) { + this.maskSourceIP = "255.255.255.255"; + } + + if (this.sourcePort != null && this.maskSourcePort == null) { + this.maskSourcePort = "65535"; + } + + if (this.destinationIP != null && this.maskDestinationIP == null) { + this.maskDestinationIP = "255.255.255.255"; + } + + if (this.destinationPort != null && this.maskDestinationPort == null) { + this.maskDestinationPort = "65535"; + } + + if (this.protocol != null && this.maskProtocol == null) { + this.maskProtocol = "255"; // 协议掩码这里填写255以确保覆盖大部分协议 + } + } } diff --git a/src/main/java/com/realtime/protection/configuration/entity/task/TaskCommandInfo.java b/src/main/java/com/realtime/protection/configuration/entity/task/TaskCommandInfo.java index e4c1ac9..7364a9f 100644 --- a/src/main/java/com/realtime/protection/configuration/entity/task/TaskCommandInfo.java +++ b/src/main/java/com/realtime/protection/configuration/entity/task/TaskCommandInfo.java @@ -48,6 +48,14 @@ public class TaskCommandInfo { @JsonProperty("task_act") private String taskAct; + @Schema(description = "部门", example = "XXX") + @JsonProperty("department") + private String department; + + @Schema(description = "局点", example = "北京") + @JsonProperty("distribute_point") + private String distributePoint; + @Schema(description = "指令下发频率", example = "30") @NotNull(message = "指令下发频率不能为空。") @JsonProperty("frequency") @@ -114,6 +122,8 @@ public class TaskCommandInfo { this.taskName = original.taskName; this.taskType = original.taskType; this.taskAct = original.taskAct; + this.department = original.department; + this.distributePoint = original.distributePoint; this.frequency = original.frequency; this.startTime = original.startTime; this.endTime = original.endTime; @@ -132,4 +142,8 @@ public class TaskCommandInfo { public void setProtocolNum() { this.fiveTupleWithMask.setProtocolNum(); } + + public void setMask() { + this.fiveTupleWithMask.setMask(); + } } diff --git a/src/main/java/com/realtime/protection/server/task/TaskService.java b/src/main/java/com/realtime/protection/server/task/TaskService.java index 20f5847..57732a8 100644 --- a/src/main/java/com/realtime/protection/server/task/TaskService.java +++ b/src/main/java/com/realtime/protection/server/task/TaskService.java @@ -109,7 +109,12 @@ public class TaskService { public List getStaticCommandInfos(Long taskId) { List staticCommandInfos = taskMapper.getStaticCommandInfos(taskId); - staticCommandInfos.forEach(TaskCommandInfo::setProtocolNum); + + staticCommandInfos.forEach(taskCommandInfo -> { + taskCommandInfo.setProtocolNum(); + taskCommandInfo.setMask(); + }); + return staticCommandInfos; } diff --git a/src/main/java/com/realtime/protection/server/task/status/StateHandler.java b/src/main/java/com/realtime/protection/server/task/status/StateHandler.java index 3d52af6..ac9b419 100644 --- a/src/main/java/com/realtime/protection/server/task/status/StateHandler.java +++ b/src/main/java/com/realtime/protection/server/task/status/StateHandler.java @@ -75,14 +75,11 @@ public class StateHandler { // todo: 如果是实时任务或者研判后处置任务,那么就需要在任务启动之后,立刻向动态规则中指定的系统发送日志筛选请求。 // 筛选完成后,系统返回日志,需要由接收端点提取字段,并且合成一条静态规则,再按照任务开始时间、结束时间和任务类型进行指令创建 private Boolean handleJudgedTaskStart(TaskService taskService, Long taskId) { -// return sendFilters(taskService, taskId); -// 还没配置帅选条件发送的url,不配置会出错,所以先注释 - return true; + return sendFilters(taskService, taskId); } private Boolean handleDynamicTaskStart(TaskService taskService, Long taskId) { -// return sendFilters(taskService, taskId); - return true; + return sendFilters(taskService, taskId); } private Boolean handleStaticTaskStart(CommandService commandService, TaskService taskService, Long taskId) { @@ -106,7 +103,7 @@ public class StateHandler { AtomicReference success = new AtomicReference<>(false); Mono mono = client.post() - .uri("") // todo: unfinished + .uri("192.168.107.89:65432") // todo: unfinished .bodyValue(dynamicTaskInfos) .exchangeToMono(res -> { if (res.statusCode().equals(HttpStatus.OK)) { diff --git a/src/main/resources/mappers/CommandMapper.xml b/src/main/resources/mappers/CommandMapper.xml index b446135..75396db 100644 --- a/src/main/resources/mappers/CommandMapper.xml +++ b/src/main/resources/mappers/CommandMapper.xml @@ -4,12 +4,12 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - insert into t_command(COMMAND_ID, TASK_ID, TASK_ACT, FREQUENCY, ADDR_TYPE, SRC_IP, SRC_PORT, DST_IP, DST_PORT, + insert into t_command(COMMAND_ID, TASK_ID, TASK_ACT, DEPARTMENT, DISTRIBUTEPOINT, FREQUENCY, ADDR_TYPE, SRC_IP, SRC_PORT, DST_IP, DST_PORT, PROTOCOL, MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME, INVALID_TIME, IS_VALID, IS_JUDGED, SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED) - values (#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.frequency}, + values (#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.department}, #{info.distributePoint}, #{info.frequency}, DEFAULT, #{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort}, #{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort}, @@ -24,14 +24,14 @@ - insert into t_command(COMMAND_ID, TASK_ID, TASK_ACT, FREQUENCY, ADDR_TYPE, SRC_IP, SRC_PORT, DST_IP, DST_PORT, + insert into t_command(COMMAND_ID, TASK_ID, TASK_ACT, DEPARTMENT, DISTRIBUTEPOINT, FREQUENCY, ADDR_TYPE, SRC_IP, SRC_PORT, DST_IP, DST_PORT, PROTOCOL, MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME, INVALID_TIME, IS_VALID, IS_JUDGED, SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED) values - (#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.frequency}, + (#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.department}, #{info.distributePoint}, #{info.frequency}, DEFAULT, #{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort}, #{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort}, diff --git a/src/main/resources/mappers/TaskMapper.xml b/src/main/resources/mappers/TaskMapper.xml index 2dece1c..9b23f76 100644 --- a/src/main/resources/mappers/TaskMapper.xml +++ b/src/main/resources/mappers/TaskMapper.xml @@ -161,6 +161,8 @@ + + @@ -204,6 +206,8 @@ t_task.task_type, t_task.task_act, + t_task.task_create_depart, + tsr.static_rule_range, tsr.static_rule_frequency, t_task.task_start_time,