1、任务、规则、白名单、策略模板新增更多的分页查询条件

This commit is contained in:
PushM
2024-05-07 22:33:59 +08:00
parent d6c487cd12
commit 3ce05a1e11
32 changed files with 317 additions and 85 deletions

View File

@@ -42,10 +42,12 @@ public class TemplateController implements TemplateControllerApi {
public ResponseResult queryTemplates(@RequestParam(value = "template_name", required = false) String templateName,
@RequestParam(value = "source_system", required = false) String sourceSystem,
@RequestParam(value = "create_user_name", required = false) String createUserName,
@RequestParam(value = "template_id", required = false) Integer templateId,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize) {
List<Template> templates = templateService.queryTemplates(
templateName, sourceSystem, createUserName,
templateName, sourceSystem, createUserName, templateId, auditStatus,
page, pageSize
);

View File

@@ -171,6 +171,8 @@ public interface TemplateControllerApi {
@Parameter(name = "template_name", description = "防御策略模板名称", example = "DDOS"),
@Parameter(name = "source_system", description = "策略模板来源那系统", example = "xxx系统"),
@Parameter(name = "create_user_name", description = "创建人名称", example = "xxx"),
@Parameter(name = "template_id", description = "防御策略模板ID", example = "1"),
@Parameter(name = "audit_status", description = "审核状态", example = "0"),
@Parameter(name = "page", description = "页码", example = "1"),
@Parameter(name = "page_size", description = "每页对象数量", example = "5")
}
@@ -178,6 +180,9 @@ public interface TemplateControllerApi {
ResponseResult queryTemplates(@RequestParam(value = "template_name", required = false) String templateName,
@RequestParam(value = "source_system", required = false) String sourceSystem,
@RequestParam(value = "create_user_name", required = false) String createUserName,
@RequestParam(value = "template_id", required = false) Integer templateId,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize);

View File

@@ -17,6 +17,8 @@ public interface TemplateMapper {
List<Template> queryTemplates(@Param("template_name") String templateName,
@Param("source_system") String sourceSystem,
@Param("create_username") String createUsername,
@Param("template_id")Integer templateId,
@Param("audit_status")Integer auditStatus,
@Param("page") Integer page,
@Param("page_size") Integer pageSize);

View File

@@ -34,8 +34,9 @@ public class TemplateService {
}
public List<Template> queryTemplates(String templateName, String sourceSystem, String createUserName,
Integer templateId, Integer auditStatus,
Integer page, Integer pageSize) {
return templateMapper.queryTemplates(templateName, sourceSystem, createUserName, page, pageSize);
return templateMapper.queryTemplates(templateName, sourceSystem, createUserName, templateId, auditStatus, page, pageSize);
}
public Boolean updateTemplate(Integer templateId, Template template) {
@@ -49,7 +50,7 @@ public class TemplateService {
}
public List<Template> queryTemplatesShort() {
List<Template> templates = templateMapper.queryTemplates(null, null, null, 1, 10000);
List<Template> templates = templateMapper.queryTemplates(null, null, null, null, null,1, 10000);
templates.forEach(template -> {
try {

View File

@@ -109,6 +109,10 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
@RequestParam(value = "source_system", required = false) String protectObjectSourceSystem,
@RequestParam(value = "creator", required = false) String creator,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam(value = "event_type", required = false) String eventType,
@RequestParam(value = "protect_level", required = false) Integer protectLevel,
@RequestParam(value = "template_name", required = false) String templateName,
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize) {
log.info("分页查询动态规则: {}:{}:{}:{}", dynamicRuleName, dynamicRuleId, page, pageSize);
@@ -116,9 +120,9 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
return ResponseResult.ok()
.setData("success", true)
.setData("dynamic_rule_list", dynamicRuleService.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator, auditStatus, page, pageSize))
protectObjectSourceSystem, creator, auditStatus, eventType, protectLevel, templateName, page, pageSize))
.setData("total_num",dynamicRuleService.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator, auditStatus));
protectObjectSourceSystem, creator, auditStatus, eventType, protectLevel, templateName));
}
//详情查看?? 就是按id查询吧
@@ -159,7 +163,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
}
return ResponseResult.ok()
.setData("success", dynamicRuleService.updateAuditStatusBatch(idsWithAuditStatusMap));
.setData("success", dynamicRuleService.updateAuditStatusBatch(idsWithAuditStatusMap));
}
@@ -172,7 +176,7 @@ public class DynamicRuleController implements DynamicRuleControllerApi {
return ResponseResult.ok()
.setData("dynamic_rule_num", dynamicRuleService.queryDynamicRuleTotalNum(null,null, null,
null, null))
null, null, null, null, null))
.setData("dynamic_rule_used_num", dynamicRuleService.queryAuditDynamicRuleTotalNum(
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
))

View File

@@ -348,6 +348,9 @@ public interface DynamicRuleControllerApi {
@Parameter(name = "source_system", description = "来源你系统", example = "BW系统"),
@Parameter(name = "creator", description = "创建人名称"),
@Parameter(name = "audit_status", description = "审核状态", example = "1"),
@Parameter(name = "event_type", description = "事件类型", example = "反射型DDOS"),
@Parameter(name = "protect_level", description = "保护级别", example = "1"),
// @Parameter(name = "template_name", description = "模板名称", example = "test"),
@Parameter(name = "page", description = "页码", example = "1"),
@Parameter(name = "page_size", description = "每页大小", example = "10")
}
@@ -357,6 +360,9 @@ public interface DynamicRuleControllerApi {
@RequestParam(value = "source_system", required = false) String protectObjectSourceSystem,
@RequestParam(value = "creator", required = false) String creator,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam(value = "event_type", required = false) String eventType,
@RequestParam(value = "protect_level", required = false) Integer protectLevel,
@RequestParam(value = "template_name", required = false) String templateName,
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);

View File

@@ -32,6 +32,7 @@ public interface DynamicRuleMapper {
List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId,
String sourceSystem, String creator, Integer auditStatus,
String eventType, Integer protectLevel, String templateName,
Integer page, Integer pageSize);
void deleteDynamicRuleProtectObjectConcat(Integer dynamicRuleId);
@@ -43,7 +44,8 @@ public interface DynamicRuleMapper {
boolean queryProtectObjectById(Integer protectObjectId);
Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
String sourceSystem, String creator, Integer auditStatus);
String sourceSystem, String creator, Integer auditStatus
, String eventType, Integer protectLevel, String templateName);
List<DynamicRuleObject> queryDynamicRuleByIds(List<Integer> ids);
@@ -59,5 +61,5 @@ public interface DynamicRuleMapper {
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);
List<Integer> queryAuditStatusByIds(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idsWithAuditStatusMap);
List<Integer> queryAuditStatusByIds(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusMap);
}

View File

@@ -172,16 +172,17 @@ public class DynamicRuleService {
//分页查询基础的动态规则,暂时不返回关联的保护对象
public List<DynamicRuleObject> queryDynamicRuleObject(String dynamicRuleName, Integer dynamicRuleId,
String templateSourceSystem,String creator,Integer auditStatus,
String eventType, Integer protectLevel, String templateName,
Integer page, Integer pageSize) {
return dynamicRuleMapper.queryDynamicRuleObject(dynamicRuleName, dynamicRuleId,
templateSourceSystem, creator, auditStatus, page, pageSize);
templateSourceSystem, creator, auditStatus, eventType, protectLevel, templateName, page, pageSize);
}
public Integer queryDynamicRuleTotalNum(String dynamicRuleName, Integer dynamicRuleId,
String protectObjectSourceSystem, String creator,
Integer auditStatus) {
Integer auditStatus, String eventType, Integer protectLevel, String templateName) {
return dynamicRuleMapper.queryDynamicRuleTotalNum(dynamicRuleName, dynamicRuleId,
protectObjectSourceSystem, creator, auditStatus);
protectObjectSourceSystem, creator, auditStatus, eventType, protectLevel, templateName);
}
public List<DynamicRuleObject> queryDynamicRuleByIds(List<Integer> ids) {
@@ -215,6 +216,7 @@ public class DynamicRuleService {
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
//校验id和status是否合法
List<Integer> originalAuditStatusList = dynamicRuleMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
int index = 0;
List<Integer> errorIds = new ArrayList<>();
for(Map.Entry<Integer, Integer> entry: idsWithAuditStatusMap.entrySet()) {

View File

@@ -133,7 +133,10 @@ public class StaticRuleController implements StaticRuleControllerApi {
public ResponseResult queryStaticRule(@RequestParam(name = "name", required = false) String static_rule_name,
@RequestParam(name = "id", required = false) Integer static_rule_id,
@RequestParam(name = "creator", required = false) String static_rule_creator,
@RequestParam(name = "ip", required = false) String static_rule_ip,
@RequestParam(name = "sip", required = false) String static_rule_sip,
@RequestParam(name = "sport", required = false) Integer static_rule_sport,
@RequestParam(name = "dip", required = false) String static_rule_dip,
@RequestParam(name = "dport", required = false) Integer static_rule_dport,
@RequestParam(name = "auditStatus", required = false) Integer auditStatus,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer pageSize
@@ -142,11 +145,11 @@ public class StaticRuleController implements StaticRuleControllerApi {
//调用service新增
List<StaticRuleObject> pageResult = staticRuleService.queryStaticRule(
static_rule_name, static_rule_id,
static_rule_creator, static_rule_ip, auditStatus, page, pageSize);
static_rule_creator, static_rule_sip, static_rule_sport, static_rule_dip, static_rule_dport, auditStatus, page, pageSize);
return ResponseResult.ok()
.setData("static_rule_list", pageResult)
.setData("total_num",staticRuleService.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
static_rule_creator, static_rule_ip, auditStatus));
static_rule_creator, static_rule_sip, static_rule_sport, static_rule_dip, static_rule_dport, auditStatus));
}
@Override
@@ -209,7 +212,7 @@ public class StaticRuleController implements StaticRuleControllerApi {
public ResponseResult getStaticRuleStatisticsData(){
return ResponseResult.ok()
.setData("static_rule_num", staticRuleService.queryStaticRuleTotalNum(null, null, null, null, null))
.setData("static_rule_num", staticRuleService.queryStaticRuleTotalNum(null, null, null, null, null, null, null, null))
.setData("static_rule_used_num", staticRuleService.queryAuditStaticRuleTotalNum(
AuditStatusEnum.getNumByState(AuditStatusEnum.USING.getState())
))

View File

@@ -203,7 +203,10 @@ public interface StaticRuleControllerApi {
@Parameter(name = "name", description = "静态规则名称"),
@Parameter(name = "id", description = "静态规则id"),
@Parameter(name = "creator", description = "静态规则创建人"),
@Parameter(name = "ip", description = "静态规则ip匹配所有源和目的ip"),
@Parameter(name = "sip", description = "静态规则ip匹配源ip并考虑掩码"),
@Parameter(name = "sport", description = "静态规则port匹配源port"),
@Parameter(name = "dip", description = "静态规则ip匹配目的ip并考虑掩码"),
@Parameter(name = "dport", description = "静态规则port匹配目的port"),
@Parameter(name = "auditStatus", description = "静态规则审核状态"),
@Parameter(name = "page", description = "页码"),
@Parameter(name = "pageSize", description = "每页条数")
@@ -212,7 +215,10 @@ public interface StaticRuleControllerApi {
ResponseResult queryStaticRule(@RequestParam(required = false) String static_rule_name,
@RequestParam(required = false) Integer static_rule_id,
@RequestParam(required = false) String static_rule_creator,
@RequestParam(required = false) String static_rule_ip,
@RequestParam(required = false) String static_rule_sip,
@RequestParam(required = false) Integer static_rule_sport,
@RequestParam(required = false) String static_rule_dip,
@RequestParam(required = false) Integer static_rule_dport,
@RequestParam(required = false) Integer auditStatus,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer pageSize

View File

@@ -28,7 +28,9 @@ public interface StaticRuleMapper {
//多页查询静态规则
List<StaticRuleObject> queryStaticRule(String static_rule_name, Integer static_rule_id,
String static_rule_create_username, String ip, Integer auditStatus,
String static_rule_create_username, String sip,
Integer sport, String dip, Integer dport,
Integer auditStatus,
Integer page, Integer pageSize);
@@ -41,7 +43,10 @@ public interface StaticRuleMapper {
Boolean updateAuditStatusById(Integer id, Integer auditStatus);
Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
String static_rule_create_username, String ip, Integer auditStatus);
String static_rule_create_username,
String sip, Integer sport,
String dip, Integer dport,
Integer auditStatus);
List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids);

View File

@@ -166,11 +166,14 @@ public class StaticRuleService {
*/
public List<StaticRuleObject> queryStaticRule(
String static_rule_name, Integer static_rule_id,
String creator, String ip, Integer auditStatus,
String creator,
String static_rule_sip, Integer static_rule_sport,
String static_rule_dip, Integer static_rule_dport,
Integer auditStatus,
Integer page, Integer pageSize) {
return staticRuleMapper.queryStaticRule(static_rule_name, static_rule_id,
creator, ip, auditStatus, page, pageSize);
creator, static_rule_sip, static_rule_sport, static_rule_dip, static_rule_dport, auditStatus, page, pageSize);
}
public Boolean newStaticRuleObjects(List<StaticRuleObject> staticRuleList) {
@@ -233,9 +236,13 @@ public class StaticRuleService {
}
public Integer queryStaticRuleTotalNum(String static_rule_name, Integer static_rule_id,
String static_rule_creator, String static_rule_ip, Integer auditStatus) {
String static_rule_creator,
String static_rule_sip, Integer static_rule_sport,
String static_rule_dip, Integer static_rule_dport,
Integer auditStatus) {
return staticRuleMapper.queryStaticRuleTotalNum(static_rule_name, static_rule_id,
static_rule_creator, static_rule_ip, auditStatus);
static_rule_creator, static_rule_sip, static_rule_sport,
static_rule_dip, static_rule_dport, auditStatus);
}
public List<StaticRuleObject> queryStaticRuleByIds(List<Integer> ids) {

View File

@@ -75,12 +75,18 @@ public class TaskController implements TaskControllerApi {
@RequestParam(value = "task_name", required = false) String taskName,
@RequestParam(value = "task_creator", required = false) String taskCreator,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam(value = "task_act", required = false) String taskAct,
@RequestParam(value = "task_auditor", required = false) String taskAuditor,
@RequestParam(value = "task_source", required = false) String taskSource,
@RequestParam(value = "rule_name", required = false) String ruleName,
@RequestParam("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize) {
List<Task> tasks = taskService.queryTasks(taskStatus, taskType, taskName, taskCreator, auditStatus, page, pageSize);
List<Task> tasks = taskService.queryTasks(taskStatus, taskType, taskName, taskCreator, auditStatus,
taskAct, taskAuditor, taskSource, ruleName, page, pageSize);
return ResponseResult.ok()
.setData("task_list", tasks)
.setData("total_num", taskService.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus));
.setData("total_num", taskService.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus,
taskAct, taskAuditor, taskSource, ruleName));
}
@Override
@@ -192,9 +198,12 @@ public class TaskController implements TaskControllerApi {
@GetMapping("/statistics")
public ResponseResult statistics() {
return ResponseResult.ok()
.setData("total_num", taskService.queryTaskTotalNum(null, null, null, null, null))
.setData("running_num", taskService.queryTaskTotalNum(StateEnum.RUNNING.getStateNum(), null, null, null, null))
.setData("finished_num", taskService.queryTaskTotalNum(StateEnum.FINISHED.getStateNum(), null, null, null, null))
.setData("total_num", taskService.queryTaskTotalNum(null, null, null, null, null,
null, null, null, null))
.setData("running_num", taskService.queryTaskTotalNum(StateEnum.RUNNING.getStateNum(), null, null, null, null,
null, null, null, null))
.setData("finished_num", taskService.queryTaskTotalNum(StateEnum.FINISHED.getStateNum(), null, null, null, null,
null, null, null, null))
.setData("unaudit_num", taskService.queryAuditTaskTotalNum(
AuditStatusEnum.PENDING.getNum()
));

View File

@@ -184,6 +184,10 @@ public interface TaskControllerApi {
@Parameter(name = "task_name", description = "任务名称"),
@Parameter(name = "task_creator", description = "任务创建人"),
@Parameter(name = "audit_status", description = "审批状态"),
@Parameter(name = "task_act", description = "任务动作"),
@Parameter(name = "task_auditor", description = "任务审核人名称"),
@Parameter(name = "task_source", description = "任务来源系统"),
@Parameter(name = "rule_name", description = "规则名称"),
@Parameter(name = "page", description = "页码", example = "1"),
@Parameter(name = "page_size", description = "每页查询个数", example = "10")
}
@@ -193,6 +197,10 @@ public interface TaskControllerApi {
@RequestParam(value = "task_name", required = false) String taskName,
@RequestParam(value = "task_creator", required = false) String taskCreator,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam(value = "task_act", required = false) String taskAct,
@RequestParam(value = "task_auditor", required = false) String taskAuditor,
@RequestParam(value = "task_source", required = false) String taskSource,
@RequestParam(value = "rule_name", required = false) String ruleName,
@RequestParam("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize);

View File

@@ -25,6 +25,8 @@ public interface TaskMapper {
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_audit_status") Integer auditStatus,
@Param("task_act")String taskAct, @Param("task_auditor")String taskAuditor,
@Param("task_source")String taskSource, @Param("rule_name")String ruleName,
@Param("page") Integer page, @Param("page_size") Integer pageSize);
Task queryTask(@Param("task_id") Long taskId);
@@ -61,7 +63,9 @@ public interface TaskMapper {
Integer queryTaskTotalNum(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
@Param("task_name") String taskName, @Param("task_creator") String taskCreator,
@Param("audit_status") Integer auditStatus);
@Param("audit_status") Integer auditStatus,
@Param("task_act")String taskAct, @Param("task_auditor")String taskAuditor,
@Param("task_source")String taskSource, @Param("rule_name")String ruleName);
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);

View File

@@ -200,8 +200,12 @@ public class TaskService {
public List<Task> queryTasks(Integer taskStatus,
Integer taskType, String taskName, String taskCreator,
Integer auditStatus,
String taskAct, String taskAuditor,
String taskSource, String ruleName,
Integer page, Integer pageSize) {
List<Task> tasks = taskMapper.queryTasks(taskStatus, taskType, taskName, taskCreator, auditStatus, page, pageSize);
List<Task> tasks = taskMapper.queryTasks(taskStatus, taskType, taskName, taskCreator, auditStatus,
taskAct, taskAuditor, taskSource, ruleName, page, pageSize);
for (Task task : tasks) {
if (task == null) {
continue;
@@ -316,8 +320,10 @@ public class TaskService {
return taskMapper.queryTasksByStatus(StateEnum.FINISHED.getStateNum());
}
public Integer queryTaskTotalNum(Integer taskStatus, Integer taskType, String taskName, String taskCreator, Integer auditStatus) {
return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus);
public Integer queryTaskTotalNum(Integer taskStatus, Integer taskType, String taskName, String taskCreator, Integer auditStatus
,String taskAct, String taskAuditor, String taskSource, String ruleName) {
return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus,
taskAct, taskAuditor, taskSource, ruleName);
}
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
@@ -371,4 +377,10 @@ public class TaskService {
public Integer queryAuditTaskTotalNum(Integer auditState) {
return taskMapper.queryAuditTaskTotalNum(auditState);
}
public List<Integer> queryAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {
//校验id和status是否合法
return taskMapper.queryAuditStatusByIds(idsWithAuditStatusMap);
}
}

View File

@@ -63,6 +63,9 @@ public class WhiteListController implements WhiteListControllerApi {
@GetMapping("/query")
public ResponseResult queryWhiteListObject(@RequestParam(value = "whiteobj_name", required = false) String whiteListName,
@RequestParam(value = "whiteobj_id", required = false) Integer whiteListId,
@RequestParam(value = "system_name", required = false) String systemName,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam(value = "creator", required = false) String creator,
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize) {
if (page <= 0 || pageSize <= 0) {
@@ -70,8 +73,8 @@ public class WhiteListController implements WhiteListControllerApi {
.setData("whiteobj_list", null);
}
return ResponseResult.ok()
.setData("whiteobj_list", whiteListService.queryWhiteListObject(whiteListName, whiteListId, page, pageSize))
.setData("total_num", whiteListService.queryWhiteListTotalNum(whiteListName, whiteListId));
.setData("whiteobj_list", whiteListService.queryWhiteListObject(whiteListName, whiteListId, systemName, auditStatus, creator, page, pageSize))
.setData("total_num", whiteListService.queryWhiteListTotalNum(whiteListName, whiteListId, systemName, auditStatus, creator));
}
@Override
@@ -202,7 +205,7 @@ public class WhiteListController implements WhiteListControllerApi {
@GetMapping("/statistics")
public ResponseResult getWhiteListStatisticsData() {
return ResponseResult.ok()
.setData("whiteobj_num", whiteListService.queryWhiteListTotalNum(null, null))
.setData("whiteobj_num", whiteListService.queryWhiteListTotalNum(null, null, null, null, null))
.setData("whiteobj_audit_num", whiteListService.queryAuditWhiteListTotalNum(
AuditStatusEnum.getNumByState(AuditStatusEnum.AUDITED.getState())
))

View File

@@ -101,12 +101,20 @@ public interface WhiteListControllerApi {
parameters = {
@Parameter(name = "whiteobj_name", description = "白名单名称"),
@Parameter(name = "whiteobj_id", description = "白名单ID"),
@Parameter(name = "system_name", description = "白名单新建时配置的系统名称"),
@Parameter(name = "audit_status", description = "审核状态"),
@Parameter(name = "creator", description = "创建人名称"),
@Parameter(name = "page", description = "页码", example = "1"),
@Parameter(name = "page_size", description = "每页查询个数", example = "10")
}
)
ResponseResult queryWhiteListObject(@RequestParam(value = "whiteobj_name", required = false) String whiteListName,
@RequestParam(value = "whiteobj_id", required = false) Integer whiteListId,
@RequestParam(value = "system_name", required = false) String systemName,
@RequestParam(value = "audit_status", required = false) Integer auditStatus,
@RequestParam(value = "creator", required = false) String creator,
@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);

View File

@@ -17,7 +17,9 @@ public interface WhiteListMapper {
void newWhiteListObject(@Param("object") WhiteListObject object);
//分页查询
List<WhiteListObject> queryWhiteListObject(String whiteListName, Integer whiteListId, Integer page, Integer pageSize);
List<WhiteListObject> queryWhiteListObject(String whiteListName, Integer whiteListId,
String systemName, Integer auditStatus, String creator,
Integer page, Integer pageSize);
//根据主键查询
WhiteListObject queryWhiteListObjectById(Integer id);
@@ -40,7 +42,8 @@ public interface WhiteListMapper {
List<WhiteListObject> whiteListCommandCheck(@Param("command") FiveTupleWithMask fiveTupleWithMaskInCommand);
Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId);
Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId
, String systemName, Integer auditStatus, String creator);
List<WhiteListObject> whiteListCommandsCheck(List<TaskCommandInfo> taskCommandInfos);

View File

@@ -113,8 +113,9 @@ public class WhiteListService {
}
public List<WhiteListObject> queryWhiteListObject(String whiteListName, Integer whiteListId,
String systemName, Integer auditStatus, String creator,
Integer page, Integer pageSize) {
return whiteListMapper.queryWhiteListObject(whiteListName, whiteListId, page, pageSize);
return whiteListMapper.queryWhiteListObject(whiteListName, whiteListId, systemName, auditStatus, creator, page, pageSize);
}
public WhiteListObject queryWhiteListObjectById(Integer id) {
@@ -186,8 +187,9 @@ public class WhiteListService {
return resultMap;
}
public Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId){
return whiteListMapper.queryWhiteListTotalNum(whiteListName, whiteListId);
public Integer queryWhiteListTotalNum(String whiteListName, Integer whiteListId
, String systemName, Integer auditStatus, String creator){
return whiteListMapper.queryWhiteListTotalNum(whiteListName, whiteListId, systemName, auditStatus, creator);
}

View File

@@ -205,6 +205,13 @@
<if test="auditStatus != null">
and t_dynamic_rule.audit_status = #{auditStatus}
</if>
<if test="eventType != null and eventType !=''">
and t_strategy_template.strategy_template_name = #{eventType}
</if>
<if test="protectLevel != null">
and t_dynamic_rule.dynamic_rule_protect_level = #{protectLevel}
</if>
</where>
LIMIT ${(page - 1) * pageSize}, #{pageSize}
</select>
@@ -250,8 +257,15 @@
<if test="auditStatus != null">
and t_dynamic_rule.audit_status = #{auditStatus}
</if>
<if test="eventType != null and eventType !=''">
and t_strategy_template.strategy_template_name = #{eventType}
</if>
<if test="protectLevel != null">
and t_dynamic_rule.dynamic_rule_protect_level = #{protectLevel}
</if>
</where>
</select>
<select id="queryDynamicRuleByIds"
resultMap="dynamicRulePageQueryMap">
select *
@@ -286,11 +300,12 @@
from t_dynamic_rule
where dynamic_rule_id = #{dynamicRuleId}
</select>
<select id="queryAuditStatusByIds" resultType="java.lang.Integer">
select audit_status
from t_dynamic_rule
where dynamic_rule_id in
<foreach collection="idsWithAuditStatusMap" item="id" open="(" separator="," close=")">
<foreach collection="idWithAuditStatusBatch" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>

View File

@@ -152,9 +152,27 @@
<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 test="sip != null and sip != ''">
AND ((static_rule_msip IS NULL AND static_rule_sip = INET_ATON(#{sip}))
OR (
static_rule_msip IS NOT NULL AND ( static_rule_sip &amp; static_rule_msip) =
(INET_ATON(#{sip}) &amp; static_rule_msip)
)
)
</if>
<if test="dip != null and dip != ''">
AND ((static_rule_mdip IS NULL AND static_rule_dip = INET_ATON(#{dip}))
OR (
static_rule_mdip IS NOT NULL AND ( static_rule_dip &amp; static_rule_mdip) =
(INET_ATON(#{dip}) &amp; static_rule_mdip)
)
)
</if>
<if test="sport != null">
AND static_rule_sport = #{sport}
</if>
<if test="dport != null">
AND static_rule_dport = #{dport}
</if>
<if test="auditStatus != null">
AND static_rule_audit_status = #{auditStatus}
@@ -187,9 +205,27 @@
<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 test="sip != null and sip != ''">
AND ((static_rule_msip IS NULL AND static_rule_sip = INET_ATON(#{sip}))
OR (
static_rule_msip IS NOT NULL AND ( static_rule_sip &amp; static_rule_msip) =
(INET_ATON(#{sip}) &amp; static_rule_msip)
)
)
</if>
<if test="dip != null and dip != ''">
AND ((static_rule_mdip IS NULL AND static_rule_dip = INET_ATON(#{dip}))
OR (
static_rule_mdip IS NOT NULL AND ( static_rule_dip &amp; static_rule_mdip) =
(INET_ATON(#{dip}) &amp; static_rule_mdip)
)
)
</if>
<if test="sport != null">
AND static_rule_sport = #{sport}
</if>
<if test="dport != null">
AND static_rule_dport = #{dport}
</if>
<if test="auditStatus != null">
AND static_rule_audit_status = #{auditStatus}

View File

@@ -61,7 +61,14 @@
</resultMap>
<select id="queryTasks" resultMap="taskMap">
SELECT * FROM t_task
SELECT t_task.* FROM t_task
<if test="rule_name != null">
LEFT JOIN t_static_rule ON t_task.task_id = t_static_rule.static_rule_used_task_id
LEFT JOIN t_dynamic_rule ON t_task.task_id = t_dynamic_rule.dynamic_rule_used_task_id
WHERE
t_static_rule.static_rule_name LIKE CONCAT('%', #{rule_name}, '%')
OR t_dynamic_rule.dynamic_rule_name LIKE CONCAT('%', #{rule_name}, '%')
</if>
<where>
<if test="task_status != null">
AND task_status = #{task_status}
@@ -78,6 +85,19 @@
<if test="task_audit_status != null">
AND task_audit_status = #{task_audit_status}
</if>
<if test="task_audit_status != null">
AND task_audit_status = #{task_audit_status}
</if>
<if test="task_act != null">
AND task_act LIKE CONCAT('%', #{task_act}, '%')
</if>
<if test="task_auditor != null">
AND task_audit_username LIKE CONCAT('%', #{task_auditor}, '%')
</if>
<if test="task_source != null">
AND task_source LIKE CONCAT('%', #{task_source}, '%')
</if>
</where>
LIMIT ${(page - 1) * page_size}, #{page_size}
</select>
@@ -315,6 +335,13 @@
</select>
<select id="queryTaskTotalNum" resultType="java.lang.Integer">
SELECT COUNT(*) FROM t_task
<if test="rule_name != null">
LEFT JOIN t_static_rule ON t_task.task_id = t_static_rule.static_rule_used_task_id
LEFT JOIN t_dynamic_rule ON t_task.task_id = t_dynamic_rule.dynamic_rule_used_task_id
WHERE
t_static_rule.static_rule_name LIKE CONCAT('%', #{rule_name}, '%')
OR t_dynamic_rule.dynamic_rule_name LIKE CONCAT('%', #{rule_name}, '%')
</if>
<where>
<if test="task_status != null">
AND task_status = #{task_status}
@@ -331,6 +358,15 @@
<if test="audit_status != null">
AND task_audit_status = #{audit_status}
</if>
<if test="task_act != null">
AND task_act LIKE CONCAT('%', #{task_act}, '%')
</if>
<if test="task_auditor != null">
AND task_audit_username LIKE CONCAT('%', #{task_auditor}, '%')
</if>
<if test="task_source != null">
AND task_source LIKE CONCAT('%', #{task_source}, '%')
</if>
</where>

View File

@@ -103,6 +103,12 @@
<if test="template_name != null">
AND strategy_template_name LIKE CONCAT('%', #{template_name}, '%')
</if>
<if test="template_id != null">
AND strategy_template_id = #{template_id}
</if>
<if test="audit_status != null">
AND audit_status = #{audit_status}
</if>
</where>
LIMIT ${(page - 1) * page_size}, #{page_size}
</select>
@@ -155,11 +161,11 @@
<select id="queryAuditTemplateTotalNum" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM t_strategy_template
WHERE audit_state = #{auditState}
WHERE audit_status = #{auditState}
</select>
<select id="queryAuditStatusById" resultType="java.lang.Integer">
SELECT audit_state
SELECT audit_status
FROM t_strategy_template
WHERE strategy_template_id = #{id}
</select>
@@ -178,7 +184,7 @@
<update id="updateAuditStatusById">
UPDATE t_strategy_template
SET audit_state = #{auditStatus}
SET audit_status = #{auditStatus}
WHERE strategy_template_id = #{id}
</update>
</mapper>

View File

@@ -59,6 +59,15 @@
<if test="whiteListId != null">
and white_list_id = #{whiteListId}
</if>
<if test="systemName != null">
and white_list_system_name like concat('%', #{systemName}, '%')
</if>
<if test="auditStatus != null">
and white_list_audit_status = #{auditStatus}
</if>
<if test="creator != null">
and create_username = #{creator}
</if>
</where>
LIMIT ${(page - 1) * pageSize}, #{pageSize}
</select>
@@ -209,6 +218,15 @@
<if test="whiteListId != null">
and white_list_id = #{whiteListId}
</if>
<if test="systemName != null">
and white_list_system_name like concat('%', #{systemName}, '%')
</if>
<if test="auditStatus != null">
and white_list_audit_status = #{auditStatus}
</if>
<if test="creator != null">
and create_username = #{creator}
</if>
</where>
</select>

View File

@@ -49,7 +49,7 @@ public class AlertMessageTest {
null, null, null, null,
null, null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 1);
null, null, null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2");

View File

@@ -84,7 +84,7 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test
void testQueryTemplate() {
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 5);
null, null, null,null, null,1, 5);
templates.forEach(item -> System.out.println(item)) ;
//// assertEquals(5, templates.size());
// for (Template template : templates) {i
@@ -97,7 +97,7 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTemplateSuccess() {
List<Template> templates = templateService.queryTemplates(
"DDOS", null, null, 1, 1);
"DDOS", null, null, null, null,1, 1);
Template testTemplate = templates.get(0);
testTemplate.setTemplateName("洪泛型DDOS攻击-" + LocalDateTime.now());
@@ -107,7 +107,7 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTemplateAuditStatus(){
List<Template> templates = templateService.queryTemplates(
null, null, null, 1, 1);
null, null, null, null, null,1, 1);
Template testTemplate = templates.get(0);
templateService.updateAuditStatus(testTemplate.getTemplateId(), 2);
}

View File

@@ -42,7 +42,7 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
null,null,null,null,
null,null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null, 1, 1);
null, null, null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2");
@@ -71,7 +71,7 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
null,
1, 1);
List<Template> templates = templateService.queryTemplates(
null, null,null, 1, 1);
null, null,null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2");
@@ -129,24 +129,24 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
@Test
void testQueryDynamicRuleObject() {
List<DynamicRuleObject> objects = dynamicRuleService.queryDynamicRuleObject(
null,null,null, null,2,1, 10);
null,null,null, null,2,null,null,null,1, 10);
System.out.println(objects);
}
@Test
void testQueryDynamicRuleTotalNum(){
Integer num = dynamicRuleService.queryDynamicRuleTotalNum(
null,null,null,null,null);
null,null,null,null,null,null,null,null);
System.out.println(num);
}
@Test
void testUpdateDynamicRuleAuditStatusBatch(){
Map<Integer, Integer> map = new HashMap<>();
map.put(101, 1);
map.put(102, 2);
map.put(103, 2);
// map.put(101, 1);
map.put(110, 2);
map.put(112, 2);
// System.out.println(dynamicRuleMapper.queryAuditStatusByIds(map));
System.out.println(dynamicRuleService.updateAuditStatusBatch(map));
}

View File

@@ -99,13 +99,13 @@ public class StaticRuleServiceTest extends ProtectionApplicationTests {
@Test
void testQueryStaticRules(){
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(null, null, null, null,2, 1, 10);
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(null, null, null, null,null, null, null,2, 1, 10);
System.out.println(staticRuleObjects);
}
@Test
void testUpdateStaticRuleAuditStatusBatch(){
Map<Integer, Integer> map = new HashMap<>();
map.put(1325, 0);
map.put(1300, 0);
map.put(1326, 1);
map.put(1328, 1);

View File

@@ -73,14 +73,14 @@ class TaskServiceTest extends ProtectionApplicationTests {
void testNewTaskSuccess() {
for (int i = 1; i < 10; i++) {
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null,2, i, 2);
null, null, null, null,null, null, null,2, i, 2);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject ->
staticRuleIds.add(staticRuleObject.getStaticRuleId()));
task.setStaticRuleIds(staticRuleIds);
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleObject(
null, null, null, null,null, i, 2
null, null, null, null,null, null,null,null,i, 2
);
List<Integer> dynamicRuleIds = new ArrayList<>();
dynamicRuleObjects.forEach(dynamicRuleObject ->
@@ -107,7 +107,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testPageQueryTask(){
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, 1, 10);
List<Task> tasks = taskService.queryTasks(null, null, null, null, null,null, null, null, null, 1, 10);
System.out.println(tasks);
}
@@ -120,14 +120,14 @@ class TaskServiceTest extends ProtectionApplicationTests {
task.setTaskName(testName);
task.setTaskCreateUsername(testCreateName);
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null, null,1, 5);
null, null, null, null, null,null, null, null,1, 5);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject ->
staticRuleIds.add(staticRuleObject.getStaticRuleId()));
task.setStaticRuleIds(staticRuleIds);
List<DynamicRuleObject> dynamicRuleObjects = dynamicRuleService.queryDynamicRuleObject(
null, null, null, null, null,1, 5
null, null, null, null, null,null, null, null, 1, 5
);
List<Integer> dynamicRuleIds = new ArrayList<>();
dynamicRuleObjects.forEach(dynamicRuleObject ->
@@ -142,17 +142,17 @@ class TaskServiceTest extends ProtectionApplicationTests {
}
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, 1, 10);
List<Task> tasks = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 10);
assertEquals(10, tasks.size());
tasks = taskService.queryTasks(0, null, null, null, null, 1, 10);
tasks = taskService.queryTasks(0, null, null, null, null,null, null, null, null, 1, 10);
assertEquals(10, tasks.size());
tasks.forEach(task -> assertEquals(0, task.getTaskStatus()));
tasks = taskService.queryTasks(null, 0, null, null, null, 1, 10);
tasks = taskService.queryTasks(null, 0, null, null, null, null, null, null, null,1, 10);
assertEquals(0, tasks.size());
tasks = taskService.queryTasks(null, null, testName, null, null, 1, 10);
tasks = taskService.queryTasks(null, null, testName, null, null, null, null, null, null,1, 10);
assertEquals(10, tasks.size());
tasks.forEach(task -> assertEquals(testName, task.getTaskName()));
}
@@ -160,11 +160,11 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testUpdateTasks() {
Task originalTask = taskService.queryTasks(
null, null, null, null, null, 1, 1)
null, null, null, null, null, null, null, null, null,1, 1)
.get(0);
List<StaticRuleObject> staticRuleObjects = staticRuleService.queryStaticRule(
null, null, null, null, null,1, 4
null, null, null, null, null,null, null, null,1, 4
);
List<Integer> staticRuleIds = new ArrayList<>();
staticRuleObjects.forEach(staticRuleObject -> staticRuleIds.add(staticRuleObject.getStaticRuleId()));
@@ -177,7 +177,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testDeleteTask() {
long testNum = taskService.queryTasks(null, null, null, null, null, 1, 10)
long testNum = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 10)
.get(0).getTaskId();
assertTrue(taskService.deleteTask(testNum));
@@ -186,7 +186,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
@Test
void testChangeAuditStatus() {
long testNum = taskService.queryTasks(null, null, null, null, null, 1, 1)
long testNum = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1)
.get(0).getTaskId();
assertTrue(taskService.changeTaskAuditStatus(testNum, 2));
@@ -294,7 +294,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
null, null, null, null,
null, null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 1);
null, null, null,null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("testStartDynamicTask");
@@ -332,4 +332,25 @@ class TaskServiceTest extends ProtectionApplicationTests {
System.out.println(commandService.queryCommandInfos(taskId, null, null, null, null, 1, 5));
}
}
@Test
void testUpdateDynamicRuleAuditStatusBatch(){
Map<Integer, Integer> map = new HashMap<>();
// map.put(101, 1);
map.put(43848, 0);
map.put(43849,0);
// System.out.println(dynamicRuleMapper.queryAuditStatusByIds(map));
System.out.println(taskService.updateAuditStatusBatch(map));
}
@Test
void testQueryDynamicRuleAuditStatus(){
System.out.println(taskService.queryTaskAuditStatus(43848L));
Map<Integer, Integer> map = new HashMap<>();
map.put(43848, 0);
map.put(43849,0);
System.out.println(taskService.queryAuditStatusBatch(map));
}
}

View File

@@ -36,7 +36,7 @@ class CommandServiceTest extends ProtectionApplicationTests {
@BeforeEach
void mockCommand() {
Task task = taskService.queryTasks(null, null, null, null, null, 1, 1).get(0);
Task task = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1).get(0);
FiveTupleWithMask fiveTupleWithMask = new FiveTupleWithMask();
fiveTupleWithMask.setMaskSourceIP("192.168.155.24");
@@ -66,7 +66,7 @@ class CommandServiceTest extends ProtectionApplicationTests {
@Test
void createCommands() {
List<TaskCommandInfo> taskCommandInfos = ListUtils.newArrayListWithExpectedSize(100);
Task task = taskService.queryTasks(null, null, null, null, null, 1, 1).get(0);
Task task = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1).get(0);
for (int i = 0; i < 100; i++) {
int port = i + 1000;
TaskCommandInfo taskCommandInfo = new TaskCommandInfo();
@@ -92,7 +92,7 @@ class CommandServiceTest extends ProtectionApplicationTests {
@Test
void queryCommandInfos() {
Task task = taskService.queryTasks(null, null, null, null, null, 1, 1).get(0);
Task task = taskService.queryTasks(null, null, null, null, null, null, null, null, null,1, 1).get(0);
List<TaskCommandInfo> taskCommandInfos = commandService.queryCommandInfos(task.getTaskId(),
null, null, null, null,1, 5);
assertTrue(taskCommandInfos != null && !taskCommandInfos.isEmpty());

View File

@@ -114,7 +114,7 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
Integer id = staticRuleService.newStaticRuleObject(staticRuleTest);
List<Integer> ruleIds = new ArrayList<>(List.of(id));
List<StaticRuleObject> staticRules= staticRuleService.queryStaticRule(null,null,null,null,null,1,2);
List<StaticRuleObject> staticRules= staticRuleService.queryStaticRule(null,null,null,null,null,null, null, null,1,2);
for (StaticRuleObject staticRule : staticRules) {
ruleIds.add(staticRule.getStaticRuleId());
}
@@ -128,4 +128,10 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
whiteListService.newWhiteListObject(whiteListObject);
System.out.println(whiteListService.whiteListStaticRulesCheck(ruleIds));
}
@Test
void testQueryWhiteListObject() {
List<WhiteListObject> whiteListObjects = whiteListService.queryWhiteListObject(null, null, null, null, null, 1, 2);
System.out.println(whiteListObjects);
}
}