1. 更新防护对象和模板的查询,添加更多筛选条件

This commit is contained in:
EnderByEndera
2024-02-01 09:08:45 +08:00
parent 9724ba0abd
commit 8864c2be3e
11 changed files with 89 additions and 81 deletions

View File

@@ -1,8 +1,8 @@
package com.realtime.protection.server.alertmessage; package com.realtime.protection.server.alertmessage;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.realtime.protection.configuration.entity.defense.template.ProtectLevel;
import com.realtime.protection.configuration.entity.alert.AlertMessage; import com.realtime.protection.configuration.entity.alert.AlertMessage;
import com.realtime.protection.configuration.entity.defense.template.ProtectLevel;
import com.realtime.protection.configuration.entity.task.TaskCommandInfo; import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,8 +1,8 @@
package com.realtime.protection.server.alertmessage; package com.realtime.protection.server.alertmessage;
import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.realtime.protection.configuration.entity.defense.template.ProtectLevel;
import com.realtime.protection.configuration.entity.alert.AlertMessage; import com.realtime.protection.configuration.entity.alert.AlertMessage;
import com.realtime.protection.configuration.entity.defense.template.ProtectLevel;
import com.realtime.protection.configuration.entity.task.FiveTupleWithMask; import com.realtime.protection.configuration.entity.task.FiveTupleWithMask;
import com.realtime.protection.configuration.entity.task.TaskCommandInfo; import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
import com.realtime.protection.configuration.utils.enums.StateEnum; import com.realtime.protection.configuration.utils.enums.StateEnum;

View File

@@ -11,7 +11,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
@@ -32,14 +35,15 @@ public interface StaticRuleControllerApi {
implementation = ResponseResult.class), implementation = ResponseResult.class),
examples = @ExampleObject( examples = @ExampleObject(
name = "新增静态规则", name = "新增静态规则",
value = "{\n" + value = """
" \"code\": 200,\n" + {
" \"message\": \"request succeed\",\n" + "code": 200,
" \"data\": {\n" + "message": "request succeed",
" \"static_rule_id\": 1095,\n" + "data": {
" \"static_rule_name\": \"静态规则测试\"\n" + "static_rule_id": 1095,
" }\n" + "static_rule_name": "静态规则测试"
"}", }
}""",
description = "static_rule_id:新增静态规则名称" + description = "static_rule_id:新增静态规则名称" +
"static_rule_name:新增静态规则id" "static_rule_name:新增静态规则id"
) )
@@ -94,16 +98,17 @@ public interface StaticRuleControllerApi {
schema = @Schema(implementation = ResponseResult.class), schema = @Schema(implementation = ResponseResult.class),
examples = @ExampleObject( examples = @ExampleObject(
name = "删除多个静态规则", name = "删除多个静态规则",
value = "{\n" + value = """
" \"code\": 200,\n" + {
" \"message\": \"request succeed\",\n" + "code": 200,
" \"data\": {\n" + "message": "request succeed",
" \"success\": true,\n" + "data": {
" \"static_rule_id\": [\n" + "success": true,
" 11\n" + "static_rule_id": [
" ]\n" + 11
" }\n" + ]
"}", }
}""",
description = "static_rule_id:删除静态规则id列表" + description = "static_rule_id:删除静态规则id列表" +
"success:是否成功" "success:是否成功"
) )
@@ -128,11 +133,12 @@ public interface StaticRuleControllerApi {
schema = @Schema(implementation = ResponseResult.class), schema = @Schema(implementation = ResponseResult.class),
examples = @ExampleObject( examples = @ExampleObject(
name = "修改静态规则", name = "修改静态规则",
value = "{\n" + value = """
" \"code\": 200,\n" + {
" \"message\": \"request succeed\",\n" + "code": 200,
" \"data\": {\"success\": true,}\n" + "message": "request succeed",
"}" "data": {"success": true,}
}"""
) )
) )
@@ -177,15 +183,16 @@ public interface StaticRuleControllerApi {
anyOf = {ResponseResult.class, StaticRuleObject.class}), anyOf = {ResponseResult.class, StaticRuleObject.class}),
examples = @ExampleObject( examples = @ExampleObject(
name = "分页查询静态规则", name = "分页查询静态规则",
value = "{\n" + value = """
" \"code\": 200,\n" + {
" \"message\": \"request succeed\",\n" + "code": 200,
" \"data\": {\n" + "message": "request succeed",
" \"static_rule_list\": [\n" + "data": {
" ],\n" + "static_rule_list": [
" \"static_rule_total_num\": 1080\n" + ],
" }\n" + "static_rule_total_num": 1080
"}", }
}""",
description = "static_rule_list:静态规则列表" + description = "static_rule_list:静态规则列表" +
"static_rule_total_num:静态规则总数" "static_rule_total_num:静态规则总数"
@@ -239,11 +246,12 @@ public interface StaticRuleControllerApi {
mediaType = "application/json", mediaType = "application/json",
schema = @Schema(implementation = ResponseResult.class), schema = @Schema(implementation = ResponseResult.class),
examples = @ExampleObject( examples = @ExampleObject(
value = "{\n" + value = """
" \"code\": 200,\n" + {
" \"message\": \"request succeed\",\n" + "code": 200,
" \"data\": {}\n" + "message": "request succeed",
"}" "data": {}
}"""
) )
) )
) )
@@ -255,9 +263,6 @@ public interface StaticRuleControllerApi {
ResponseResult deleteStaticRule(@PathVariable Integer id); ResponseResult deleteStaticRule(@PathVariable Integer id);
@Operation( @Operation(
summary = "更新静态规则审批状态", summary = "更新静态规则审批状态",
description = "更新静态规则审批状态0未审核、1审核不通过、2审核通过", description = "更新静态规则审批状态0未审核、1审核不通过、2审核通过",
@@ -275,6 +280,5 @@ public interface StaticRuleControllerApi {
@Parameter(name = "auditStatus", description = "要修改为的静态规则审核状态") @Parameter(name = "auditStatus", description = "要修改为的静态规则审核状态")
} }
) )
public ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus) ; ResponseResult updateStaticRuleAuditStatus(@PathVariable Integer id, @PathVariable Integer auditStatus);
} }

View File

@@ -9,7 +9,6 @@ import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@@ -31,15 +30,16 @@ public interface WhiteListControllerApi {
mediaType = "application/json", mediaType = "application/json",
schema = @Schema(implementation = ResponseResult.class), schema = @Schema(implementation = ResponseResult.class),
examples = {@ExampleObject( examples = {@ExampleObject(
value = "{\n" + value = """
" \"code\": 200,\n" + {
" \"message\": \"request succeed\",\n" + "code": 200,
" \"data\": {\n" + "message": "request succeed",
" \"whiteobj_name\": \"白名单测试\",\n" + "data": {
" \"success\": true,\n" + "whiteobj_name": "白名单测试",
" \"whiteobj_id\": 7026\n" + "success": true,
" }\n" + "whiteobj_id": 7026
"}" }
}"""
)} )}
) )
) )

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="1361px" height="609px" viewBox="0 0 1361 609" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <svg width="1361px" height="609px" viewBox="0 0 1361 609" version="1.1" xmlns="http://www.w3.org/2000/svg">
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch --> <!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
<title>Group 21</title> <title>Group 21</title>
<desc>Created with Sketch.</desc> <desc>Created with Sketch.</desc>

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve"> viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve">
<style type="text/css"> <style type="text/css">
.st0{fill:#1890FF;} .st0{fill:#1890FF;}

Before

Width:  |  Height:  |  Size: 988 B

After

Width:  |  Height:  |  Size: 948 B

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!-- Generator: Adobe Illustrator 22.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve"> viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve">
<style type="text/css"> <style type="text/css">
.st0{fill:#FFFFFF;} .st0{fill:#FFFFFF;}

Before

Width:  |  Height:  |  Size: 972 B

After

Width:  |  Height:  |  Size: 932 B

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <svg viewBox="0 0 128 128" version="1.1" xmlns="http://www.w3.org/2000/svg">
<!-- Generator: Sketch 52.6 (67491) - http://www.bohemiancoding.com/sketch --> <!-- Generator: Sketch 52.6 (67491) - http://www.bohemiancoding.com/sketch -->
<title>Vue</title> <title>Vue</title>
<desc>Created with Sketch.</desc> <desc>Created with Sketch.</desc>

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -39,8 +39,12 @@ public class AlertMessageTest {
@Test @Test
void testReceiveAlertMessage() { void testReceiveAlertMessage() {
List<ProtectObject> protectObject = protectObjectService.queryProtectObjects(null, null, 1, 1); List<ProtectObject> protectObject = protectObjectService.queryProtectObjects(
List<Template> templates = templateService.queryTemplates(null, 1, 1); null, null, null, null,
null, null, null, null,
null, null, 1, 1);
List<Template> templates = templateService.queryTemplates(
null, null, null,1, 1);
DynamicRuleObject object = new DynamicRuleObject(); DynamicRuleObject object = new DynamicRuleObject();
object.setDynamicRuleName("UpdateDynamicRule2"); object.setDynamicRuleName("UpdateDynamicRule2");

View File

@@ -82,7 +82,8 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test @Test
void testQueryTemplate() { void testQueryTemplate() {
List<Template> templates = templateService.queryTemplates("DDOS", 1, 5); List<Template> templates = templateService.queryTemplates(
"DDOS", null, null,1, 5);
assertEquals(5, templates.size()); assertEquals(5, templates.size());
for (Template template : templates) { for (Template template : templates) {
assertTrue(template.getTemplateId() > 0); assertTrue(template.getTemplateId() > 0);
@@ -93,7 +94,8 @@ class TemplateServiceTest extends ProtectionApplicationTests {
@Test @Test
void testUpdateTemplateSuccess() { void testUpdateTemplateSuccess() {
List<Template> templates = templateService.queryTemplates("DDOS", 1, 1); List<Template> templates = templateService.queryTemplates(
"DDOS", null, null, 1, 1);
Template testTemplate = templates.get(0); Template testTemplate = templates.get(0);
testTemplate.setTemplateName("洪泛型DDOS攻击-" + LocalDateTime.now()); testTemplate.setTemplateName("洪泛型DDOS攻击-" + LocalDateTime.now());

View File

@@ -12,10 +12,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cglib.core.Local;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -30,7 +28,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
private Task task; private Task task;
@Autowired @Autowired
TaskServiceTest(TaskService taskService, StaticRuleService staticRuleService, DynamicRuleService dynamicRuleService, StateChangeService stateChangeService) { TaskServiceTest(TaskService taskService, StaticRuleService staticRuleService, DynamicRuleService dynamicRuleService) {
this.taskService = taskService; this.taskService = taskService;
this.staticRuleService = staticRuleService; this.staticRuleService = staticRuleService;
this.dynamicRuleService = dynamicRuleService; this.dynamicRuleService = dynamicRuleService;