1. 修改防护对象、策略模板和任务的Swagger文档
2. 修改任务和指令部分逻辑
This commit is contained in:
@@ -76,8 +76,8 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
||||
@RequestParam("page_size") @Min(1) Integer pageSize) {
|
||||
return ResponseResult.ok()
|
||||
.setData("proobj_list", protectObjectService.queryProtectObjects(protectObjectName,
|
||||
protectObjectId, page, pageSize));
|
||||
|
||||
protectObjectId, page, pageSize))
|
||||
.setData("total_num", protectObjectService.queryProtectObjectsTotalNum());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -29,7 +30,28 @@ public interface ProtectObjectControllerApi {
|
||||
description = "返回新建对象结果",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"proobj_name": "静态对象测试",
|
||||
"success": true,
|
||||
"proobj_id": 14542
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"proobj_name": 防护对象名称
|
||||
|
||||
"success": 新建防护对象是否成功
|
||||
|
||||
"proobj_id": 新建防护对象ID
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -80,7 +102,56 @@ public interface ProtectObjectControllerApi {
|
||||
description = "返回多个防护对象",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"proobj_list": [
|
||||
{
|
||||
"proobj_id": 6068,
|
||||
"proobj_name": "x-2-2",
|
||||
"proobj_system_name": "xxxx system",
|
||||
"proobj_port": 11,
|
||||
"proobj_url": "alice.bob.com",
|
||||
"proobj_protocol": "UDP",
|
||||
"proobj_audit_status": 1
|
||||
},
|
||||
{
|
||||
"proobj_id": 6069,
|
||||
"proobj_name": "x-2-2",
|
||||
"proobj_system_name": "xxxx system",
|
||||
"proobj_port": 11,
|
||||
"proobj_url": "alice.bob.com",
|
||||
"proobj_protocol": "UDP",
|
||||
"proobj_audit_status": 0
|
||||
}
|
||||
],
|
||||
"total_num": 8470
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"proobj_id": 防护对象ID
|
||||
|
||||
"proobj_name": 防护对象名称
|
||||
|
||||
"proobj_system_name": 防护对象操作系统
|
||||
|
||||
"proobj_ip_address": 防护对象IP地址
|
||||
|
||||
"proobj_port": 防护对象端口
|
||||
|
||||
"proobj_url": 防护对象URL
|
||||
|
||||
"proobj_protocol": 防护对象协议
|
||||
|
||||
"proobj_audit_status": 防护对象审核状态
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -107,7 +178,44 @@ public interface ProtectObjectControllerApi {
|
||||
description = "返回单个防护对象信息",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"protect_object": {
|
||||
"proobj_id": 14544,
|
||||
"proobj_name": "静态对象测试",
|
||||
"proobj_system_name": "xxx操作系统",
|
||||
"proobj_port": 8080,
|
||||
"proobj_url": "alice.bob.com",
|
||||
"proobj_protocol": "TCP",
|
||||
"proobj_audit_status": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"proobj_id": 防护对象ID
|
||||
|
||||
"proobj_name": 防护对象名称
|
||||
|
||||
"proobj_system_name": 防护对象操作系统
|
||||
|
||||
"proobj_ip_address": 防护对象IP地址
|
||||
|
||||
"proobj_port": 防护对象端口
|
||||
|
||||
"proobj_url": 防护对象URL
|
||||
|
||||
"proobj_protocol": 防护对象协议
|
||||
|
||||
"proobj_audit_status": 防护对象审核状态
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -126,7 +234,25 @@ public interface ProtectObjectControllerApi {
|
||||
description = "防护对象更新情况",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"proobj_id": 14544
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 防护对象更新是否成功
|
||||
|
||||
"proobj_id": 防护对象ID
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -148,7 +274,25 @@ public interface ProtectObjectControllerApi {
|
||||
description = "防护对象删除情况",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"proobj_id": 14544
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 防护对象删除是否成功
|
||||
|
||||
"proobj_id": 删除的防护对象ID
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -167,7 +311,28 @@ public interface ProtectObjectControllerApi {
|
||||
description = "防护对象删除情况",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"proobj_ids": [
|
||||
14543,
|
||||
14542
|
||||
]
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 防护对象删除是否成功
|
||||
|
||||
"proobj_ids": 删除的防护对象ID列表
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -186,7 +351,28 @@ public interface ProtectObjectControllerApi {
|
||||
description = "防护对象审核状态修改情况",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"proobj_id": 14541,
|
||||
"audit_status": 2
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 审核状态修改是否成功
|
||||
|
||||
"proobj_id": 防护对象ID
|
||||
|
||||
"audit_status": 防护对象当前审核状态
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.realtime.protection.server.defense.object;
|
||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,4 +28,7 @@ public interface ProtectObjectMapper {
|
||||
|
||||
Boolean changeProtectObjectAuditStatus(@Param("proobj_id") Integer protectObjectId,
|
||||
@Param("proobj_audit_status") Integer protectObjectAuditStatus);
|
||||
|
||||
@Select("SELECT COUNT(protect_object_id) FROM t_protect_object")
|
||||
Integer queryProtectObjectsTotalNum();
|
||||
}
|
||||
|
||||
@@ -112,4 +112,8 @@ public class ProtectObjectService {
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public Integer queryProtectObjectsTotalNum() {
|
||||
return protectObjectMapper.queryProtectObjectsTotalNum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,12 +43,13 @@ public class TemplateController implements TemplateControllerApi {
|
||||
List<Template> templates = templateService.queryTemplates(templateName, page, pageSize);
|
||||
|
||||
return ResponseResult.ok()
|
||||
.setData("templates", templates);
|
||||
.setData("templates", templates)
|
||||
.setData("total_num", templateService.queryTemplateTotalNum());
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("/{templateId}/query")
|
||||
public ResponseResult queryTemplate(@PathVariable Integer templateId) throws IllegalAccessException {
|
||||
public ResponseResult queryTemplate(@PathVariable Integer templateId) {
|
||||
Template template = templateService.queryTemplate(templateId);
|
||||
if (template == null) {
|
||||
return ResponseResult.invalid()
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.realtime.protection.configuration.response.ResponseResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -23,7 +24,25 @@ public interface TemplateControllerApi {
|
||||
description = "返回新建防御策略模板结果",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"template_id": 1442
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 新建防御策略模板是否成功
|
||||
|
||||
"template_id": 新建防御策略模板ID
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -40,7 +59,108 @@ public interface TemplateControllerApi {
|
||||
description = "返回所有查询到的防御策略模板",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"templates": [
|
||||
{
|
||||
"template_id": 18,
|
||||
"template_name": "洪泛型DDOS攻击-2024-01-18T16:46:14.640176900",
|
||||
"protect_level_low": {
|
||||
"protectLevelId": 46,
|
||||
"hasProtectObjectIP": false,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": true,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": false
|
||||
},
|
||||
"protect_level_medium": {
|
||||
"protectLevelId": 47,
|
||||
"hasProtectObjectIP": true,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": false,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": false
|
||||
},
|
||||
"protect_level_high": {
|
||||
"protectLevelId": 48,
|
||||
"hasProtectObjectIP": false,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": false,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": true
|
||||
},
|
||||
"template_used_times": 0,
|
||||
"running_tasks": 0
|
||||
},
|
||||
{
|
||||
"template_id": 24,
|
||||
"template_name": "反射型DDOS攻击-2024-01-12T17:52:32.077477700",
|
||||
"protect_level_low": {
|
||||
"protectLevelId": 64,
|
||||
"hasProtectObjectIP": false,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": true,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": false
|
||||
},
|
||||
"protect_level_medium": {
|
||||
"protectLevelId": 65,
|
||||
"hasProtectObjectIP": true,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": false,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": false
|
||||
},
|
||||
"protect_level_high": {
|
||||
"protectLevelId": 66,
|
||||
"hasProtectObjectIP": false,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": false,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": true
|
||||
},
|
||||
"template_used_times": 0,
|
||||
"running_tasks": 0
|
||||
}
|
||||
],
|
||||
"total_num": 708
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"template_id": 防御策略模板ID
|
||||
|
||||
"template_name": 防御策略模板名称
|
||||
|
||||
"protect_level_low": 防御策略模板日常态数据
|
||||
|
||||
"protect_level_medium": 防御策略模板应急态数据
|
||||
|
||||
"protect_level_high": 防御策略模板紧急态数据
|
||||
|
||||
"template_used_times": 防御策略模板使用次数
|
||||
|
||||
"running_tasks": 防御策略模板任务运行数量
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -63,7 +183,69 @@ public interface TemplateControllerApi {
|
||||
description = "返回单个防御策略模板信息",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"template": {
|
||||
"template_id": 245,
|
||||
"template_name": "反射型DDOS攻击-2024-01-12T18:10:49.975561700",
|
||||
"protect_level_low": {
|
||||
"protectLevelId": 727,
|
||||
"hasProtectObjectIP": false,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": true,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": false
|
||||
},
|
||||
"protect_level_medium": {
|
||||
"protectLevelId": 728,
|
||||
"hasProtectObjectIP": true,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": false,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": false
|
||||
},
|
||||
"protect_level_high": {
|
||||
"protectLevelId": 729,
|
||||
"hasProtectObjectIP": false,
|
||||
"hasProtectObjectPort": false,
|
||||
"hasPeerIP": false,
|
||||
"hasPeerPort": false,
|
||||
"hasProtocol": false,
|
||||
"hasURL": false,
|
||||
"hasDNS": true
|
||||
},
|
||||
"template_used_times": 0,
|
||||
"running_tasks": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"template_id": 防御策略模板ID
|
||||
|
||||
"template_name": 防御策略模板名称
|
||||
|
||||
"protect_level_low": 防御策略模板日常态数据
|
||||
|
||||
"protect_level_medium": 防御策略模板应急态数据
|
||||
|
||||
"protect_level_high": 防御策略模板紧急态数据
|
||||
|
||||
"template_used_times": 防御策略模板使用次数
|
||||
|
||||
"running_tasks": 防御策略模板任务运行数量
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -82,7 +264,25 @@ public interface TemplateControllerApi {
|
||||
description = "返回防御策略模板信息更新结果",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"template_id": 262
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 更新是否成功
|
||||
|
||||
"template_id": 更新的策略模板ID
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
@@ -102,7 +302,25 @@ public interface TemplateControllerApi {
|
||||
description = "返回防御策略模板删除结果",
|
||||
content = @Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = ResponseResult.class)
|
||||
schema = @Schema(implementation = ResponseResult.class),
|
||||
examples = @ExampleObject(
|
||||
name = "example",
|
||||
value = """
|
||||
{
|
||||
"code": 200,
|
||||
"message": "request succeed",
|
||||
"data": {
|
||||
"success": true,
|
||||
"template_id": 262
|
||||
}
|
||||
}
|
||||
""",
|
||||
description = """
|
||||
"success": 删除是否成功
|
||||
|
||||
"template_id": 删除的策略模板ID
|
||||
"""
|
||||
)
|
||||
)
|
||||
)
|
||||
},
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.realtime.protection.server.defense.template;
|
||||
|
||||
import com.realtime.protection.configuration.entity.defense.template.ProtectLevel;
|
||||
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,5 +25,9 @@ public interface TemplateMapper {
|
||||
|
||||
Template queryTemplate(@Param("template_id") Integer templateId);
|
||||
|
||||
@Delete("DELETE FROM t_strategy_template WHERE strategy_template_id = #{template_id}")
|
||||
Boolean deleteTemplate(@Param("template_id") Integer templateId);
|
||||
|
||||
@Select("SELECT COUNT(strategy_template_id) FROM t_strategy_template")
|
||||
Integer queryTemplateTotalNum();
|
||||
}
|
||||
|
||||
@@ -46,4 +46,8 @@ public class TemplateService {
|
||||
public Boolean deleteTemplate(Integer templateId) {
|
||||
return templateMapper.deleteTemplate(templateId);
|
||||
}
|
||||
|
||||
public Integer queryTemplateTotalNum() {
|
||||
return templateMapper.queryTemplateTotalNum();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user