1. 解除动态规则发送请求成功/失败返回状态

2. 在指令中添加局点/部门信息
This commit is contained in:
EnderByEndera
2024-04-11 08:56:35 +08:00
parent 5e17aa5e60
commit 9ceb2e583e
6 changed files with 53 additions and 11 deletions

View File

@@ -90,4 +90,26 @@ public class FiveTupleWithMask {
assert protocol != null; assert protocol != null;
this.protocolNum = protocol.getNumber(); 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以确保覆盖大部分协议
}
}
} }

View File

@@ -48,6 +48,14 @@ public class TaskCommandInfo {
@JsonProperty("task_act") @JsonProperty("task_act")
private String taskAct; 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") @Schema(description = "指令下发频率", example = "30")
@NotNull(message = "指令下发频率不能为空。") @NotNull(message = "指令下发频率不能为空。")
@JsonProperty("frequency") @JsonProperty("frequency")
@@ -114,6 +122,8 @@ public class TaskCommandInfo {
this.taskName = original.taskName; this.taskName = original.taskName;
this.taskType = original.taskType; this.taskType = original.taskType;
this.taskAct = original.taskAct; this.taskAct = original.taskAct;
this.department = original.department;
this.distributePoint = original.distributePoint;
this.frequency = original.frequency; this.frequency = original.frequency;
this.startTime = original.startTime; this.startTime = original.startTime;
this.endTime = original.endTime; this.endTime = original.endTime;
@@ -132,4 +142,8 @@ public class TaskCommandInfo {
public void setProtocolNum() { public void setProtocolNum() {
this.fiveTupleWithMask.setProtocolNum(); this.fiveTupleWithMask.setProtocolNum();
} }
public void setMask() {
this.fiveTupleWithMask.setMask();
}
} }

View File

@@ -109,7 +109,12 @@ public class TaskService {
public List<TaskCommandInfo> getStaticCommandInfos(Long taskId) { public List<TaskCommandInfo> getStaticCommandInfos(Long taskId) {
List<TaskCommandInfo> staticCommandInfos = taskMapper.getStaticCommandInfos(taskId); List<TaskCommandInfo> staticCommandInfos = taskMapper.getStaticCommandInfos(taskId);
staticCommandInfos.forEach(TaskCommandInfo::setProtocolNum);
staticCommandInfos.forEach(taskCommandInfo -> {
taskCommandInfo.setProtocolNum();
taskCommandInfo.setMask();
});
return staticCommandInfos; return staticCommandInfos;
} }

View File

@@ -75,14 +75,11 @@ public class StateHandler {
// todo: 如果是实时任务或者研判后处置任务,那么就需要在任务启动之后,立刻向动态规则中指定的系统发送日志筛选请求。 // todo: 如果是实时任务或者研判后处置任务,那么就需要在任务启动之后,立刻向动态规则中指定的系统发送日志筛选请求。
// 筛选完成后,系统返回日志,需要由接收端点提取字段,并且合成一条静态规则,再按照任务开始时间、结束时间和任务类型进行指令创建 // 筛选完成后,系统返回日志,需要由接收端点提取字段,并且合成一条静态规则,再按照任务开始时间、结束时间和任务类型进行指令创建
private Boolean handleJudgedTaskStart(TaskService taskService, Long taskId) { private Boolean handleJudgedTaskStart(TaskService taskService, Long taskId) {
// return sendFilters(taskService, taskId); return sendFilters(taskService, taskId);
// 还没配置帅选条件发送的url不配置会出错所以先注释
return true;
} }
private Boolean handleDynamicTaskStart(TaskService taskService, Long taskId) { private Boolean handleDynamicTaskStart(TaskService taskService, Long taskId) {
// return sendFilters(taskService, taskId); return sendFilters(taskService, taskId);
return true;
} }
private Boolean handleStaticTaskStart(CommandService commandService, TaskService taskService, Long taskId) { private Boolean handleStaticTaskStart(CommandService commandService, TaskService taskService, Long taskId) {
@@ -106,7 +103,7 @@ public class StateHandler {
AtomicReference<Boolean> success = new AtomicReference<>(false); AtomicReference<Boolean> success = new AtomicReference<>(false);
Mono<SimpleResponse> mono = client.post() Mono<SimpleResponse> mono = client.post()
.uri("") // todo: unfinished .uri("192.168.107.89:65432") // todo: unfinished
.bodyValue(dynamicTaskInfos) .bodyValue(dynamicTaskInfos)
.exchangeToMono(res -> { .exchangeToMono(res -> {
if (res.statusCode().equals(HttpStatus.OK)) { if (res.statusCode().equals(HttpStatus.OK)) {

View File

@@ -4,12 +4,12 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.realtime.protection.server.command.CommandMapper"> <mapper namespace="com.realtime.protection.server.command.CommandMapper">
<insert id="createCommand" parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo"> <insert id="createCommand" parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
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, PROTOCOL,
MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME, MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME,
INVALID_TIME, IS_VALID, IS_JUDGED, INVALID_TIME, IS_VALID, IS_JUDGED,
SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED) 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, DEFAULT,
#{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort}, #{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort},
#{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort}, #{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort},
@@ -24,14 +24,14 @@
</insert> </insert>
<insert id="createCommands" parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo"> <insert id="createCommands" parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
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, PROTOCOL,
MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME, INVALID_TIME, IS_VALID, MASK_SRC_IP, MASK_SRC_PORT, MASK_DST_IP, MASK_DST_PORT, MASK_PROTOCOL, VALID_TIME, INVALID_TIME, IS_VALID,
IS_JUDGED, IS_JUDGED,
SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED) SEND_TIMES, SUCCESS_TIMES, CREATE_TIME, LAST_UPDATE, IS_DELETED)
values values
<foreach collection="command_infos" item="info" separator=","> <foreach collection="command_infos" item="info" separator=",">
(#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.frequency}, (#{info.UUID}, #{info.taskId}, #{info.taskAct}, #{info.department}, #{info.distributePoint}, #{info.frequency},
DEFAULT, DEFAULT,
#{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort}, #{info.fiveTupleWithMask.sourceIP}, #{info.fiveTupleWithMask.sourcePort},
#{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort}, #{info.fiveTupleWithMask.destinationIP}, #{info.fiveTupleWithMask.destinationPort},

View File

@@ -161,6 +161,8 @@
<result column="static_rule_id" property="ruleId"/> <result column="static_rule_id" property="ruleId"/>
<result column="task_act" property="taskAct"/> <result column="task_act" property="taskAct"/>
<result column="task_create_depart" property="department"/>
<result column="static_rule_range" property="distributePoint"/>
<result column="task_type" property="taskType"/> <result column="task_type" property="taskType"/>
<result column="static_rule_frequency" property="frequency"/> <result column="static_rule_frequency" property="frequency"/>
<result column="task_start_time" property="startTime"/> <result column="task_start_time" property="startTime"/>
@@ -204,6 +206,8 @@
t_task.task_type, t_task.task_type,
t_task.task_act, t_task.task_act,
t_task.task_create_depart,
tsr.static_rule_range,
tsr.static_rule_frequency, tsr.static_rule_frequency,
t_task.task_start_time, t_task.task_start_time,