Merge remote-tracking branch 'origin/master' into haskafka

# Conflicts:
#	docker-nginx/Dockerfile
#	docker-springboot/Dockerfile
This commit is contained in:
Hao Miao
2024-02-01 17:28:57 +08:00
26 changed files with 357 additions and 117 deletions

View File

@@ -1,8 +1,8 @@
package com.realtime.protection.server.alertmessage;
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.defense.template.ProtectLevel;
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
import org.apache.ibatis.annotations.Mapper;

View File

@@ -1,8 +1,8 @@
package com.realtime.protection.server.alertmessage;
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.defense.template.ProtectLevel;
import com.realtime.protection.configuration.entity.task.FiveTupleWithMask;
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
import com.realtime.protection.configuration.utils.enums.StateEnum;

View File

@@ -70,14 +70,38 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
@GetMapping("/query")
public ResponseResult queryProtectObjects(@RequestParam(value = "proobj_name", required = false)
String protectObjectName,
@RequestParam(value = "proobj_id", required = false) @Min(1)
@RequestParam(value = "proobj_id", required = false)
@Min(value = 1, message = "ID值不可小于1")
Integer protectObjectId,
@RequestParam(value = "proobj_systemm_name", required = false)
String protectObjectSystemName,
@RequestParam(value = "proobj_ip_address", required = false)
String protectObjectIPAddress,
@RequestParam(value = "proobj_port_min", required = false)
Integer protectObjectPortMin,
@RequestParam(value = "proobj_port_max", required = false)
Integer protectObjectPortMax,
@RequestParam(value = "proobj_url", required = false)
String protectObjectURL,
@RequestParam(value = "proobj_protocol", required = false)
String protectObjectProtocol,
@RequestParam(value = "proobj_create_username", required = false)
String protectObjectCreateUsername,
@RequestParam(value = "proobj_audit_status", required = false)
Integer protectObjectAuditStatus,
@RequestParam("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize) {
return ResponseResult.ok()
.setData("proobj_list", protectObjectService.queryProtectObjects(protectObjectName,
protectObjectId, page, pageSize))
.setData("total_num", protectObjectService.queryProtectObjectsTotalNum(protectObjectName, protectObjectId));
.setData("proobj_list", protectObjectService.queryProtectObjects(
protectObjectName, protectObjectId, protectObjectSystemName, protectObjectIPAddress,
protectObjectPortMin, protectObjectPortMax, protectObjectURL, protectObjectProtocol,
protectObjectCreateUsername, protectObjectAuditStatus,
page, pageSize))
.setData("total_num", protectObjectService.queryProtectObjectsTotalNum(
protectObjectName, protectObjectId, protectObjectSystemName, protectObjectIPAddress,
protectObjectPortMin, protectObjectPortMax, protectObjectURL, protectObjectProtocol,
protectObjectCreateUsername, protectObjectAuditStatus
));
}
@Override

View File

@@ -158,14 +158,39 @@ public interface ProtectObjectControllerApi {
parameters = {
@Parameter(name = "proobj_name", description = "防护对象名称"),
@Parameter(name = "proobj_id", description = "防护对象ID"),
@Parameter(name = "proobj_system_name", description = "防护对象操作系统"),
@Parameter(name = "proobj_ip_address", description = "防护对象IP地址"),
@Parameter(name = "proobj_port_min", description = "防护对象端口最小值"),
@Parameter(name = "proobj_port_max", description = "防护对象端口最大值"),
@Parameter(name = "proobj_url", description = "防护对象URL"),
@Parameter(name = "proobj_protocol", description = "防护对象网络协议"),
@Parameter(name = "proobj_create_username", description = "防护对象创建人"),
@Parameter(name = "proobj_audit_status", description = "防护对象审核状态"),
@Parameter(name = "page", description = "页码", example = "1"),
@Parameter(name = "page_size", description = "每页的对象个数", example = "5")
}
)
ResponseResult queryProtectObjects(@RequestParam(value = "proobj_name", required = false)
String protectObjectName,
@RequestParam(value = "proobj_id", required = false) @Min(1)
@RequestParam(value = "proobj_id", required = false)
@Min(value = 1, message = "ID值不可小于1")
Integer protectObjectId,
@RequestParam(value = "proobj_systemm_name", required = false)
String protectObjectSystemName,
@RequestParam(value = "proobj_ip_address", required = false)
String protectObjectIPAddress,
@RequestParam(value = "proobj_port_min", required = false)
Integer protectObjectPortMin,
@RequestParam(value = "proobj_port_max", required = false)
Integer protectObjectPortMax,
@RequestParam(value = "proobj_url", required = false)
String protectObjectURL,
@RequestParam(value = "proobj_protocol", required = false)
String protectObjectProtocol,
@RequestParam(value = "proobj_create_username", required = false)
String protectObjectCreateUsername,
@RequestParam(value = "proobj_audit_status", required = false)
Integer protectObjectAuditStatus,
@RequestParam("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize);

View File

@@ -12,10 +12,6 @@ public interface ProtectObjectMapper {
void newProtectObjects(@Param("proobjs") List<ProtectObject> protectObject);
List<ProtectObject> queryProtectObjects(@Param("proobj_name") String protectObjectName,
@Param("proobj_id") Integer protectObjectId,
@Param("page") Integer page,
@Param("page_size") Integer pageSize);
ProtectObject queryProtectObject(@Param("proobj_id") Integer protectObjectId);
@@ -30,5 +26,26 @@ public interface ProtectObjectMapper {
Integer queryProtectObjectsTotalNum(@Param("proobj_name") String protectObjectName,
@Param("proobj_id") Integer protectObjectId);
@Param("proobj_id") Integer protectObjectId,
@Param("proobj_system_name") String protectObjectSystemName,
@Param("proobj_ip") String protectObjectIPAddress,
@Param("proobj_port_min") Integer protectObjectPortMin,
@Param("proobj_port_max") Integer protectObjectPortMax,
@Param("proobj_url") String protectObjectURL,
@Param("proobj_protocol") String protectObjectProtocol,
@Param("proobj_username") String protectObjectCreateUsername,
@Param("proobj_audit_status") Integer protectObjectAuditStatus);
List<ProtectObject> queryProtectObjects(@Param("proobj_name") String protectObjectName,
@Param("proobj_id") Integer protectObjectId,
@Param("proobj_system_name") String protectObjectSystemName,
@Param("proobj_ip") String protectObjectIPAddress,
@Param("proobj_port_min") Integer protectObjectPortMin,
@Param("proobj_port_max") Integer protectObjectPortMax,
@Param("proobj_url") String protectObjectURL,
@Param("proobj_protocol") String protectObjectProtocol,
@Param("proobj_username") String protectObjectCreateUsername,
@Param("proobj_audit_status") Integer protectObjectAuditStatus,
@Param("page") Integer page,
@Param("page_size") Integer pageSize);
}

View File

@@ -56,8 +56,17 @@ public class ProtectObjectService {
return sqlSessionWrapper.startBatchSession(ProtectObjectMapper.class, newProtectObjectFunction, protectObjectList);
}
public List<ProtectObject> queryProtectObjects(String protectObjectName, Integer protectObjectId, Integer page, Integer pageSize) {
return protectObjectMapper.queryProtectObjects(protectObjectName, protectObjectId, page, pageSize);
public List<ProtectObject> queryProtectObjects(String protectObjectName, Integer protectObjectId,
String protectObjectSystemName, String protectObjectIPAddress,
Integer protectObjectPortMin, Integer protectObjectPortMax,
String protectObjectURL, String protectObjectProtocol,
String protectObjectCreateUsername, Integer protectObjectAuditStatus,
Integer page, Integer pageSize) {
return protectObjectMapper.queryProtectObjects(
protectObjectName, protectObjectId, protectObjectSystemName, protectObjectIPAddress,
protectObjectPortMin, protectObjectPortMax, protectObjectURL, protectObjectProtocol,
protectObjectCreateUsername, protectObjectAuditStatus,
page, pageSize);
}
public ProtectObject queryProtectObject(Integer protectObjectId) {
@@ -113,7 +122,15 @@ public class ProtectObjectService {
return resultMap;
}
public Integer queryProtectObjectsTotalNum(String protectObjectName, Integer protectObjectId) {
return protectObjectMapper.queryProtectObjectsTotalNum(protectObjectName, protectObjectId);
public Integer queryProtectObjectsTotalNum(String protectObjectName, Integer protectObjectId,
String protectObjectSystemName, String protectObjectIPAddress,
Integer protectObjectPortMin, Integer protectObjectPortMax,
String protectObjectURL, String protectObjectProtocol,
String protectObjectCreateUsername, Integer protectObjectAuditStatus) {
return protectObjectMapper.queryProtectObjectsTotalNum(
protectObjectName, protectObjectId, protectObjectSystemName, protectObjectIPAddress,
protectObjectPortMin, protectObjectPortMax, protectObjectURL, protectObjectProtocol,
protectObjectCreateUsername, protectObjectAuditStatus
);
}
}

View File

@@ -39,13 +39,18 @@ public class TemplateController implements TemplateControllerApi {
@Override
@GetMapping("/query")
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("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize) {
List<Template> templates = templateService.queryTemplates(templateName, page, pageSize);
List<Template> templates = templateService.queryTemplates(
templateName, sourceSystem, createUserName,
page, pageSize
);
return ResponseResult.ok()
.setData("templates", templates)
.setData("total_num", templateService.queryTemplateTotalNum(templateName));
.setData("total_num", templateService.queryTemplateTotalNum(templateName, sourceSystem, createUserName));
}
@Override

View File

@@ -168,11 +168,15 @@ public interface TemplateControllerApi {
},
parameters = {
@Parameter(name = "template_name", description = "防御策略模板名称", example = "DDOS"),
@Parameter(name = "source_system", description = "策略模板来源那系统", example = "xxx系统"),
@Parameter(name = "create_user_name", description = "创建人名称", example = "xxx"),
@Parameter(name = "page", description = "页码", example = "1"),
@Parameter(name = "page_size", description = "每页对象数量", example = "5")
}
)
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("page") @Min(1) Integer page,
@RequestParam("page_size") @Min(1) Integer pageSize);
@@ -379,6 +383,5 @@ public interface TemplateControllerApi {
)
}
)
public ResponseResult queryTemplateId(@RequestBody Map<String,String> map);
ResponseResult queryTemplateId(@RequestBody Map<String, String> map);
}

View File

@@ -15,6 +15,8 @@ public interface TemplateMapper {
void newProtectLevel(@Param("level") ProtectLevel protectLevel);
List<Template> queryTemplates(@Param("template_name") String templateName,
@Param("source_system") String sourceSystem,
@Param("create_username") String createUsername,
@Param("page") Integer page,
@Param("page_size") Integer pageSize);
@@ -27,7 +29,9 @@ public interface TemplateMapper {
@Delete("DELETE FROM t_strategy_template WHERE strategy_template_id = #{template_id}")
Boolean deleteTemplate(@Param("template_id") Integer templateId);
Integer queryTemplateTotalNum(String templateName);
Integer queryTemplateTotalNum(@Param("template_name") String templateName,
@Param("source_system") String sourceSystem,
@Param("create_username") String createUsername);
List<String> querySourceSystem();

View File

@@ -29,8 +29,9 @@ public class TemplateService {
return template.getTemplateId();
}
public List<Template> queryTemplates(String templateName, Integer page, Integer pageSize) {
return templateMapper.queryTemplates(templateName, page, pageSize);
public List<Template> queryTemplates(String templateName, String sourceSystem, String createUserName,
Integer page, Integer pageSize) {
return templateMapper.queryTemplates(templateName, sourceSystem, createUserName, page, pageSize);
}
public Boolean updateTemplate(Integer templateId, Template template) {
@@ -47,8 +48,8 @@ public class TemplateService {
return templateMapper.deleteTemplate(templateId);
}
public Integer queryTemplateTotalNum(String templateName) {
return templateMapper.queryTemplateTotalNum(templateName);
public Integer queryTemplateTotalNum(String templateName, String sourceSystem, String createUserName) {
return templateMapper.queryTemplateTotalNum(templateName, sourceSystem, createUserName);
}
public List<String> querySourceSystem() {

View File

@@ -11,7 +11,10 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
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 java.io.IOException;
@@ -32,24 +35,25 @@ public interface StaticRuleControllerApi {
implementation = ResponseResult.class),
examples = @ExampleObject(
name = "新增静态规则",
value = "{\n" +
" \"code\": 200,\n" +
" \"message\": \"request succeed\",\n" +
" \"data\": {\n" +
" \"static_rule_id\": 1095,\n" +
" \"static_rule_name\": \"静态规则测试\"\n" +
" }\n" +
"}",
description = "static_rule_id:新增静态规则名称"+
value = """
{
"code": 200,
"message": "request succeed",
"data": {
"static_rule_id": 1095,
"static_rule_name": "静态规则测试"
}
}""",
description = "static_rule_id:新增静态规则名称" +
"static_rule_name:新增静态规则id"
)
)
)
)
},
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "静态规则信息")
)
ResponseResult newStaticRuleObject(@RequestBody @Valid StaticRuleObject object) ;
ResponseResult newStaticRuleObject(@RequestBody @Valid StaticRuleObject object);
@Operation(
summary = "批量导入静态规则",
@@ -66,7 +70,7 @@ public interface StaticRuleControllerApi {
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
description = "Excel文件")
)
ResponseResult uploadFile(@NotNull(message = "uploadFile字段不能为空")MultipartFile uploadFile) throws IOException;
ResponseResult uploadFile(@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile) throws IOException;
@Operation(
summary = "下载静态规则模板",
@@ -81,7 +85,7 @@ public interface StaticRuleControllerApi {
)
}
)
void downloadTemplate(HttpServletResponse response) throws IOException ;
void downloadTemplate(HttpServletResponse response) throws IOException;
@Operation(
summary = "删除静态规则",
@@ -94,17 +98,18 @@ public interface StaticRuleControllerApi {
schema = @Schema(implementation = ResponseResult.class),
examples = @ExampleObject(
name = "删除多个静态规则",
value = "{\n" +
" \"code\": 200,\n" +
" \"message\": \"request succeed\",\n" +
" \"data\": {\n" +
" \"success\": true,\n" +
" \"static_rule_id\": [\n" +
" 11\n" +
" ]\n" +
" }\n" +
"}",
description = "static_rule_id:删除静态规则id列表"+
value = """
{
"code": 200,
"message": "request succeed",
"data": {
"success": true,
"static_rule_id": [
11
]
}
}""",
description = "static_rule_id:删除静态规则id列表" +
"success:是否成功"
)
@@ -115,7 +120,7 @@ public interface StaticRuleControllerApi {
@Parameter(name = "ids", description = "静态规则id数组")
}
)
ResponseResult delete(@PathVariable List<Integer> ids) ;
ResponseResult delete(@PathVariable List<Integer> ids);
@Operation(
summary = "修改静态规则",
@@ -128,11 +133,12 @@ public interface StaticRuleControllerApi {
schema = @Schema(implementation = ResponseResult.class),
examples = @ExampleObject(
name = "修改静态规则",
value = "{\n" +
" \"code\": 200,\n" +
" \"message\": \"request succeed\",\n" +
" \"data\": {\"success\": true,}\n" +
"}"
value = """
{
"code": 200,
"message": "request succeed",
"data": {"success": true,}
}"""
)
)
@@ -145,7 +151,7 @@ public interface StaticRuleControllerApi {
description = "静态规则信息")
)
ResponseResult updateStaticRule(@PathVariable Integer id,
@RequestBody @Valid StaticRuleObject object) ;
@RequestBody @Valid StaticRuleObject object);
@Operation(
summary = "查询单个静态规则",
@@ -162,7 +168,7 @@ public interface StaticRuleControllerApi {
},
parameters = {@Parameter(name = "id", description = "静态规则ID", example = "38")}
)
ResponseResult queryStaticRuleById(@PathVariable Integer id) ;
ResponseResult queryStaticRuleById(@PathVariable Integer id);
@Operation(
summary = "分页查询静态规则",
@@ -177,17 +183,18 @@ public interface StaticRuleControllerApi {
anyOf = {ResponseResult.class, StaticRuleObject.class}),
examples = @ExampleObject(
name = "分页查询静态规则",
value = "{\n" +
" \"code\": 200,\n" +
" \"message\": \"request succeed\",\n" +
" \"data\": {\n" +
" \"static_rule_list\": [\n" +
" ],\n" +
" \"static_rule_total_num\": 1080\n" +
" }\n" +
"}",
value = """
{
"code": 200,
"message": "request succeed",
"data": {
"static_rule_list": [
],
"static_rule_total_num": 1080
}
}""",
description = "static_rule_list:静态规则列表"+
description = "static_rule_list:静态规则列表" +
"static_rule_total_num:静态规则总数"
)
)
@@ -211,7 +218,7 @@ public interface StaticRuleControllerApi {
);
@Operation( summary = "批量查询静态规则",
@Operation(summary = "批量查询静态规则",
description = "根据静态规则ID列表查询多个静态规则的所有详细信息",
responses = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(
@@ -239,11 +246,12 @@ public interface StaticRuleControllerApi {
mediaType = "application/json",
schema = @Schema(implementation = ResponseResult.class),
examples = @ExampleObject(
value = "{\n" +
" \"code\": 200,\n" +
" \"message\": \"request succeed\",\n" +
" \"data\": {}\n" +
"}"
value = """
{
"code": 200,
"message": "request succeed",
"data": {}
}"""
)
)
)
@@ -252,10 +260,7 @@ public interface StaticRuleControllerApi {
@Parameter(name = "id", description = "静态规则id")
}
)
ResponseResult deleteStaticRule(@PathVariable Integer id) ;
ResponseResult deleteStaticRule(@PathVariable Integer id);
@Operation(
@@ -275,6 +280,5 @@ public interface StaticRuleControllerApi {
@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.tags.Tag;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@@ -31,15 +30,16 @@ public interface WhiteListControllerApi {
mediaType = "application/json",
schema = @Schema(implementation = ResponseResult.class),
examples = {@ExampleObject(
value = "{\n" +
" \"code\": 200,\n" +
" \"message\": \"request succeed\",\n" +
" \"data\": {\n" +
" \"whiteobj_name\": \"白名单测试\",\n" +
" \"success\": true,\n" +
" \"whiteobj_id\": 7026\n" +
" }\n" +
"}"
value = """
{
"code": 200,
"message": "request succeed",
"data": {
"whiteobj_name": "白名单测试",
"success": true,
"whiteobj_id": 7026
}
}"""
)}
)
)