1、动态、静态规则、任务、白名单、防护对象、策略模板的查询总数增加了条件

2、指令分页查询还有bug
This commit is contained in:
Hao Miao
2024-01-23 12:17:10 +08:00
parent 121fff1d18
commit b6e046c754
28 changed files with 160 additions and 34 deletions

View File

@@ -32,4 +32,10 @@ public interface CommandMapper {
TaskCommandInfo queryCommandInfoByUUID(@Param("uuid") String uuid); TaskCommandInfo queryCommandInfoByUUID(@Param("uuid") String uuid);
String queryCommandInfo(@Param("command_info") TaskCommandInfo commandInfo); String queryCommandInfo(@Param("command_info") TaskCommandInfo commandInfo);
Integer queryCommandTotalNum(@Param("task_id") Long taskId,
@Param("src_ip") String sourceIP,
@Param("src_port") String sourcePort,
@Param("dst_ip") String destinationIP,
@Param("dst_port") String destinationPort);
} }

View File

@@ -93,4 +93,9 @@ public class CommandService {
public Boolean setCommandJudged(String commandId, Boolean isValid) { public Boolean setCommandJudged(String commandId, Boolean isValid) {
return commandMapper.setCommandJudged(commandId, isValid); return commandMapper.setCommandJudged(commandId, isValid);
} }
public Integer queryCommandTotalNum(Long taskId, String sourceIP, String sourcePort,
String destinationIP, String destinationPort){
return commandMapper.queryCommandTotalNum(taskId, sourceIP, sourcePort, destinationIP, destinationPort);
}
} }

View File

@@ -77,7 +77,7 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
return ResponseResult.ok() return ResponseResult.ok()
.setData("proobj_list", protectObjectService.queryProtectObjects(protectObjectName, .setData("proobj_list", protectObjectService.queryProtectObjects(protectObjectName,
protectObjectId, page, pageSize)) protectObjectId, page, pageSize))
.setData("total_num", protectObjectService.queryProtectObjectsTotalNum()); .setData("total_num", protectObjectService.queryProtectObjectsTotalNum(protectObjectName, protectObjectId));
} }
@Override @Override

View File

@@ -3,7 +3,6 @@ package com.realtime.protection.server.defense.object;
import com.realtime.protection.configuration.entity.defense.object.ProtectObject; import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@@ -29,6 +28,7 @@ public interface ProtectObjectMapper {
Boolean changeProtectObjectAuditStatus(@Param("proobj_id") Integer protectObjectId, Boolean changeProtectObjectAuditStatus(@Param("proobj_id") Integer protectObjectId,
@Param("proobj_audit_status") Integer protectObjectAuditStatus); @Param("proobj_audit_status") Integer protectObjectAuditStatus);
@Select("SELECT COUNT(protect_object_id) FROM t_protect_object")
Integer queryProtectObjectsTotalNum(); Integer queryProtectObjectsTotalNum(@Param("proobj_name") String protectObjectName,
@Param("proobj_id") Integer protectObjectId);
} }

View File

@@ -113,7 +113,7 @@ public class ProtectObjectService {
return resultMap; return resultMap;
} }
public Integer queryProtectObjectsTotalNum() { public Integer queryProtectObjectsTotalNum(String protectObjectName, Integer protectObjectId) {
return protectObjectMapper.queryProtectObjectsTotalNum(); return protectObjectMapper.queryProtectObjectsTotalNum(protectObjectName, protectObjectId);
} }
} }

View File

@@ -44,7 +44,7 @@ public class TemplateController implements TemplateControllerApi {
return ResponseResult.ok() return ResponseResult.ok()
.setData("templates", templates) .setData("templates", templates)
.setData("total_num", templateService.queryTemplateTotalNum()); .setData("total_num", templateService.queryTemplateTotalNum(templateName));
} }
@Override @Override

View File

@@ -5,7 +5,6 @@ import com.realtime.protection.configuration.entity.defense.template.Template;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@@ -28,6 +27,5 @@ public interface TemplateMapper {
@Delete("DELETE FROM t_strategy_template WHERE strategy_template_id = #{template_id}") @Delete("DELETE FROM t_strategy_template WHERE strategy_template_id = #{template_id}")
Boolean deleteTemplate(@Param("template_id") Integer templateId); Boolean deleteTemplate(@Param("template_id") Integer templateId);
@Select("SELECT COUNT(strategy_template_id) FROM t_strategy_template") Integer queryTemplateTotalNum(String templateName);
Integer queryTemplateTotalNum();
} }

View File

@@ -47,7 +47,7 @@ public class TemplateService {
return templateMapper.deleteTemplate(templateId); return templateMapper.deleteTemplate(templateId);
} }
public Integer queryTemplateTotalNum() { public Integer queryTemplateTotalNum(String templateName) {
return templateMapper.queryTemplateTotalNum(); return templateMapper.queryTemplateTotalNum(templateName);
} }
} }

View File

@@ -104,7 +104,8 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
.setData("success", true) .setData("success", true)
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId, .setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator, page, pageSize)) protectObjectSourceSystem, creator, page, pageSize))
.setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum()); .setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator));
} }
//详情查看?? 就是按id查询吧 //详情查看?? 就是按id查询吧

View File

@@ -41,5 +41,6 @@ public interface DynamicRuleMapper {
boolean queryProtectObjectById(Integer protectObjectId); boolean queryProtectObjectById(Integer protectObjectId);
Integer queryDynamicRuleTotalNum(); Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
String sourceSystem, String creator);
} }

View File

@@ -161,7 +161,9 @@ public class DynamicRuleService {
templateSourceSystem, creator, page, pageSize); templateSourceSystem, creator, page, pageSize);
} }
public Integer queryDynamicRuleTotalNum() { public Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
return dynamicRuleMapper.queryDynamicRuleTotalNum(); String protectObjectSourceSystem, String creator) {
return dynamicRuleMapper.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator);
} }
} }

View File

@@ -139,7 +139,8 @@ public class StaticRuleController implements StaticRuleControllerApi {
static_rule_creator, static_rule_ip, page, pageSize); static_rule_creator, static_rule_ip, page, pageSize);
return ResponseResult.ok() return ResponseResult.ok()
.setData("static_rule_list", pageResult) .setData("static_rule_list", pageResult)
.setData("total_num",staticRuleService.queryStaticRuleTotalNum()); .setData("total_num",staticRuleService.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
static_rule_creator, static_rule_ip));
} }
/** /**

View File

@@ -39,5 +39,6 @@ public interface StaticRuleMapper {
Boolean updateAuditStatusById(Integer id, Integer auditStatus); Boolean updateAuditStatusById(Integer id, Integer auditStatus);
Integer queryStaticRuleTotalNum(); Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
String static_rule_create_username, String ip);
} }

View File

@@ -148,7 +148,9 @@ public class StaticRuleService {
staticRuleMapper.deleteStaticRuleById(id); staticRuleMapper.deleteStaticRuleById(id);
} }
public Integer queryStaticRuleTotalNum() { public Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
return staticRuleMapper.queryStaticRuleTotalNum(); String static_rule_creator, String static_rule_ip) {
return staticRuleMapper.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
static_rule_creator, static_rule_ip);
} }
} }

View File

@@ -67,7 +67,7 @@ public class TaskController implements TaskControllerApi {
@Override @Override
@GetMapping("/query") @GetMapping("/query")
public ResponseResult queryTasks(@RequestParam(value = "task_status", required = false) Integer taskStatus, public ResponseResult queryTasks(@RequestParam(value = "task_status", required = false) Integer taskStatus,
@RequestParam(value = "task_type", required = false) String taskType, @RequestParam(value = "task_type", required = false) Integer taskType,
@RequestParam(value = "task_name", required = false) String taskName, @RequestParam(value = "task_name", required = false) String taskName,
@RequestParam(value = "task_creator", required = false) String taskCreator, @RequestParam(value = "task_creator", required = false) String taskCreator,
@RequestParam("page") @Min(1) Integer page, @RequestParam("page") @Min(1) Integer page,
@@ -75,7 +75,7 @@ public class TaskController implements TaskControllerApi {
List<Task> tasks = taskService.queryTasks(taskStatus, taskType, taskName, taskCreator, page, pageSize); List<Task> tasks = taskService.queryTasks(taskStatus, taskType, taskName, taskCreator, page, pageSize);
return ResponseResult.ok() return ResponseResult.ok()
.setData("task_list", tasks) .setData("task_list", tasks)
.setData("total_num", taskService.queryTaskTotalNum()); .setData("total_num", taskService.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator));
} }
@Override @Override
@@ -143,7 +143,8 @@ public class TaskController implements TaskControllerApi {
return ResponseResult.ok() return ResponseResult.ok()
.setData("success", true) .setData("success", true)
.setData("commands", taskCommandInfos); .setData("commands", taskCommandInfos)
.setData("total_num", commandService.queryCommandTotalNum(taskId, sourceIP, sourcePort, destinationIP, destinationPort));
} }
@GetMapping("/{commandId}/valid/{isJudged}") @GetMapping("/{commandId}/valid/{isJudged}")

View File

@@ -186,7 +186,7 @@ public interface TaskControllerApi {
} }
) )
ResponseResult queryTasks(@RequestParam(value = "task_status", required = false) Integer taskStatus, ResponseResult queryTasks(@RequestParam(value = "task_status", required = false) Integer taskStatus,
@RequestParam(value = "task_type", required = false) String taskType, @RequestParam(value = "task_type", required = false) Integer taskType,
@RequestParam(value = "task_name", required = false) String taskName, @RequestParam(value = "task_name", required = false) String taskName,
@RequestParam(value = "task_creator", required = false) String taskCreator, @RequestParam(value = "task_creator", required = false) String taskCreator,
@RequestParam("page") @Min(1) Integer page, @RequestParam("page") @Min(1) Integer page,

View File

@@ -21,7 +21,7 @@ public interface TaskMapper {
void newTaskUsingCommandInfo(@Param("info") TaskCommandInfo taskCommandInfo); void newTaskUsingCommandInfo(@Param("info") TaskCommandInfo taskCommandInfo);
List<Task> queryTasks(@Param("task_status") Integer taskStatus, @Param("task_type") String task_type, List<Task> queryTasks(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
@Param("task_name") String taskName, @Param("task_creator") String taskCreator, @Param("task_name") String taskName, @Param("task_creator") String taskCreator,
@Param("page") Integer page, @Param("page_size") Integer pageSize); @Param("page") Integer page, @Param("page_size") Integer pageSize);
@@ -54,6 +54,7 @@ public interface TaskMapper {
@Select("SELECT task_id FROM t_task WHERE task_end_time < NOW() AND task_status != #{task_status}") @Select("SELECT task_id FROM t_task WHERE task_end_time < NOW() AND task_status != #{task_status}")
List<Long> queryTasksByStatus(@Param("task_status") Integer taskStatus); List<Long> queryTasksByStatus(@Param("task_status") Integer taskStatus);
@Select("SELECT COUNT(task_id) FROM t_task")
Integer queryTaskTotalNum(); Integer queryTaskTotalNum(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
@Param("task_name") String taskName, @Param("task_creator") String taskCreator);
} }

View File

@@ -41,7 +41,7 @@ public class TaskService {
@Transactional @Transactional
public List<Task> queryTasks(Integer taskStatus, public List<Task> queryTasks(Integer taskStatus,
String taskType, String taskName, String taskCreator, Integer taskType, String taskName, String taskCreator,
Integer page, Integer pageSize) { Integer page, Integer pageSize) {
List<Task> tasks = taskMapper.queryTasks(taskStatus, taskType, taskName, taskCreator, page, pageSize); List<Task> tasks = taskMapper.queryTasks(taskStatus, taskType, taskName, taskCreator, page, pageSize);
for (Task task : tasks) { for (Task task : tasks) {
@@ -132,7 +132,7 @@ public class TaskService {
return taskMapper.queryTasksByStatus(StateEnum.FINISHED.getStateNum()); return taskMapper.queryTasksByStatus(StateEnum.FINISHED.getStateNum());
} }
public Integer queryTaskTotalNum() { public Integer queryTaskTotalNum(Integer taskStatus, Integer taskType, String taskName,String taskCreator) {
return taskMapper.queryTaskTotalNum(); return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator);
} }
} }

View File

@@ -70,7 +70,7 @@ public class WhiteListController implements WhiteListControllerApi {
} }
return ResponseResult.ok() return ResponseResult.ok()
.setData("whiteobj_list", whiteListService.queryWhiteListObject(whiteListName, whiteListId, page, pageSize)) .setData("whiteobj_list", whiteListService.queryWhiteListObject(whiteListName, whiteListId, page, pageSize))
.setData("total_num", whiteListService.queryWhiteListTotalNum()); .setData("total_num", whiteListService.queryWhiteListTotalNum(whiteListName, whiteListId));
} }
@Override @Override

View File

@@ -39,5 +39,5 @@ public interface WhiteListMapper {
List<WhiteListObject> whiteListCommandJudge(@Param("command") FiveTupleWithMask fiveTupleWithMaskInCommand); List<WhiteListObject> whiteListCommandJudge(@Param("command") FiveTupleWithMask fiveTupleWithMaskInCommand);
Integer queryWhiteListTotalNum(); Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId);
} }

View File

@@ -157,8 +157,8 @@ public class WhiteListService {
return resultMap; return resultMap;
} }
public Integer queryWhiteListTotalNum(){ public Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId){
return whiteListMapper.queryWhiteListTotalNum(); return whiteListMapper.queryWhiteListTotalNum(whiteListName, whiteListId);
} }

View File

@@ -170,4 +170,41 @@
</if> </if>
</where> </where>
</select> </select>
<select id="queryCommandTotalNum" resultType="java.lang.Integer">
SELECT COUNT(COMMAND_ID)
FROM t_command
<where>
<if test="command_info.taskId != null">AND TASK_ID = #{command_info.taskId}</if>
<if test="command_info.fiveTupleWithMask.sourceIP != null">
AND SRC_IP = #{command_info.fiveTupleWithMask.sourceIP}
</if>
<if test="command_info.fiveTupleWithMask.destinationIP != null">
AND DST_IP = #{command_info.fiveTupleWithMask.destinationIP}
</if>
<if test="command_info.fiveTupleWithMask.sourcePort != null">
AND SRC_PORT = #{command_info.fiveTupleWithMask.sourcePort}
</if>
<if test="command_info.fiveTupleWithMask.destinationPort != null">
AND DST_PORT = #{command_info.fiveTupleWithMask.destinationPort}
</if>
<if test="command_info.fiveTupleWithMask.protocol != null">
AND PROTOCOL = #{command_info.fiveTupleWithMask.protocol}
</if>
<if test="command_info.fiveTupleWithMask.maskSourceIP != null">
AND MASK_SRC_IP = #{command_info.fiveTupleWithMask.maskSourceIP}
</if>
<if test="command_info.fiveTupleWithMask.maskSourcePort != null">
AND MASK_SOURCE_PORT = #{command_info.fiveTupleWithMask.maskSourcePort}
</if>
<if test="command_info.fiveTupleWithMask.maskDestinationIP != null">
AND MASK_DST_IP = #{command_info.fiveTupleWithMask.maskDestinationIP}
</if>
<if test="command_info.fiveTupleWithMask.maskDestinationPort != null">
AND MASK_DST_PORT = #{command_info.fiveTupleWithMask.maskDestinationPort}
</if>
<if test="command_info.fiveTupleWithMask.maskProtocol != null">
AND MASK_PROTOCOL = #{command_info.fiveTupleWithMask.maskProtocol}
</if>
</where>
</select>
</mapper> </mapper>

View File

@@ -209,6 +209,20 @@
<select id="queryDynamicRuleTotalNum" resultType="java.lang.Integer"> <select id="queryDynamicRuleTotalNum" resultType="java.lang.Integer">
SELECT COUNT(*) SELECT COUNT(*)
FROM t_dynamic_rule FROM t_dynamic_rule
<where>
<if test="dynamicRuleName != null">
t_dynamic_rule.dynamic_rule_name like concat('%', #{dynamicRuleName}, '%')
</if>
<if test="dynamicRuleId != null">
and t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}
</if>
<if test="sourceSystem != null">
and t_strategy_template.strategy_template_source_system = #{sourceSystem}
</if>
<if test="creator != null">
and t_dynamic_rule.dynamic_rule_create_username = #{creator}
</if>
</where>
</select> </select>

View File

@@ -69,6 +69,13 @@
FROM t_protect_object FROM t_protect_object
WHERE protect_object_id = #{proobj_id} WHERE protect_object_id = #{proobj_id}
</select> </select>
<select id="queryProtectObjectsTotalNum" resultType="java.lang.Integer">
SELECT COUNT(protect_object_id) FROM t_protect_object
<where>
<if test="proobj_name != null">protect_object_name LIKE CONCAT('%', #{proobj_name}, '%')</if>
<if test="proobj_id != null">protect_object_id = #{proobj_id}</if>
</where>
</select>
<update id="updateProtectObject"> <update id="updateProtectObject">
UPDATE t_protect_object UPDATE t_protect_object

View File

@@ -161,6 +161,21 @@
<select id="queryStaticRuleTotalNum" resultType="java.lang.Integer"> <select id="queryStaticRuleTotalNum" resultType="java.lang.Integer">
SELECT COUNT(*) SELECT COUNT(*)
FROM t_static_rule FROM t_static_rule
<where>
<if test="static_rule_name != null and static_rule_name != ''">
static_rule_name like concat('%', #{static_rule_name}, '%')
</if>
<if test="static_rule_id != null">
AND static_rule_id = #{static_rule_id}
</if>
<if test="static_rule_create_username != null and static_rule_create_username != ''">
AND static_rule_create_username like concat('%', #{static_rule_create_username}, '%')
</if>
<if test="ip != null and ip != ''">
AND (static_rule_sip = INET_ATON(#{ip}) or static_rule_msip = INET_ATON(#{ip})
or static_rule_dip = INET_ATON(#{ip}) or static_rule_mdip = INET_ATON(#{ip}))
</if>
</where>
</select> </select>
</mapper> </mapper>

View File

@@ -259,4 +259,22 @@
INNER JOIN realtime_protection.t_strategy_template tst on tdr.template_id = tst.strategy_template_id INNER JOIN realtime_protection.t_strategy_template tst on tdr.template_id = tst.strategy_template_id
WHERE task_id = #{task_id} WHERE task_id = #{task_id}
</select> </select>
<select id="queryTaskTotalNum" resultType="java.lang.Integer">
SELECT COUNT(*) FROM t_task
<where>
<if test="task_status != null">
AND task_status = #{task_status}
</if>
<if test="task_type != null">
AND task_type = #{task_type}
</if>
<if test="task_name != null">
AND task_name LIKE CONCAT('%', #{task_name}, '%')
</if>
<if test="task_creator != null">
AND task_create_username LIKE CONCAT('%', #{task_creator}, '%')
</if>
</where>
</select>
</mapper> </mapper>

View File

@@ -105,6 +105,14 @@
FROM t_protect_level FROM t_protect_level
WHERE protect_level_id = #{level_id} WHERE protect_level_id = #{level_id}
</select> </select>
<select id="queryTemplateTotalNum" resultType="java.lang.Integer">
SELECT COUNT(strategy_template_id) FROM t_strategy_template
<where>
<if test="template_name != null">
AND strategy_template_name LIKE CONCAT('%', #{template_name}, '%')
</if>
</where>
</select>
<update id="updateTemplateInformation"> <update id="updateTemplateInformation">
UPDATE t_strategy_template UPDATE t_strategy_template

View File

@@ -201,6 +201,14 @@
<select id="queryWhiteListTotalNum" resultType="java.lang.Integer"> <select id="queryWhiteListTotalNum" resultType="java.lang.Integer">
select COUNT(*) select COUNT(*)
from t_white_list from t_white_list
<where>
<if test="whiteListName != null">
white_list_name like concat('%', #{whiteListName}, '%')
</if>
<if test="whiteListId != null">
and white_list_id = #{whiteListId}
</if>
</where>
</select> </select>
</mapper> </mapper>