1、规则删去策略模板、防护对象。增加sdl字段

2、任务增加策略模板、防护对象
3、相应地方修改
This commit is contained in:
PushM
2024-05-28 02:21:58 +08:00
parent df19bef4fa
commit 388201a97f
22 changed files with 428 additions and 359 deletions

View File

@@ -1,8 +1,6 @@
package com.realtime.protection.configuration.entity.rule.dynamicrule;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -46,19 +44,7 @@ public class DynamicRuleObject {
@Schema(description = "动态规则创建用户所属部门", accessMode = Schema.AccessMode.READ_ONLY)
private String dynamicRuleCreateDepart;
//动态规则选择的防护对象ids
@NotNull(message = "防护对象不能为NULL")
@NotEmpty(message = "防护对象不能为空")
@JsonProperty("protect_object_ids")
@Schema(description = "请求时发送防护对象ID", accessMode = Schema.AccessMode.WRITE_ONLY, requiredMode = Schema.RequiredMode.REQUIRED)
private List<Integer> protectObjectIds;
@JsonProperty("protect_objects")
@Schema(description = "响应时回复防护对象完整信息", accessMode = Schema.AccessMode.READ_ONLY)
private List<ProtectObject> protectObjects;
@JsonProperty("strategy_template_name")
@Schema(description = "动态规则选择的策略模板", accessMode = Schema.AccessMode.READ_ONLY)
private String templateName;
//还没有建立外键
@@ -73,40 +59,23 @@ public class DynamicRuleObject {
@JsonProperty("dynamic_rule_source_system")
@Schema(description = "动态规则数据来源系统", example = "bw系统", requiredMode = Schema.RequiredMode.REQUIRED)
private String dynamicRuleSourceSystem;
@JsonProperty("dynamic_rule_event_type")
@Schema(description = "动态规则事件类型", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private String dynamicRuleEventType;
@NotNull
@JsonProperty("template_id")
@Schema(description = "策略模板id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer templateId;
// @NotNull
@JsonProperty("dynamic_rule_protect_level")
@Max(value = 3)
@Min(value = 1)
@Schema(description = "防护等级1代表日常态、2代表应急态、3代表紧急态", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer dynamicRuleProtectLevel;
@NotNull
// @NotNull
@JsonProperty("dynamic_rule_priority")
@Schema(description = "优先级", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
// @Schema(description = "优先级", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer dynamicRulePriority;
@NotNull
// @NotNull
// @JsonProperty("dynamic_rule_range")
// @Schema(description = "范围", example = "北京", requiredMode = Schema.RequiredMode.REQUIRED)
// private String dynamicRuleRange;
// @NotNull
@JsonProperty("dynamic_rule_frequency")
@Schema(description = "频率", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
// @Schema(description = "频率", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer dynamicRuleFrequency;
@NotNull
@JsonProperty("log_rule_id")
@Schema(description = "筛选条件-日志规则id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Long logRuleId;
// @NotNull
@JsonProperty("dynamic_rule_audit_status")
@ExcelIgnore
@Schema(description = "动态规则审核状态0为未审核1为已退回2为审核通过", example = "2", accessMode = Schema.AccessMode.READ_ONLY)
private Integer auditStatus;
@@ -120,6 +89,14 @@ public class DynamicRuleObject {
@Schema(description = "审核用户部门", example = "部门1")
private String auditUserDepart;
@JsonProperty("bw_sql")
@Schema(description = "BW系统所需sql", example = "select * from table1 where rule_id=12222")
private String bwSql;
@JsonProperty("description")
@Schema(description = "动态规则描述", example = "动态规则描述")
private String description;
public void checkAuditStatusValidate(AuditStatusEnum newAuditStatus) {
if (!List.of(AuditStatusEnum.AUDITED.getNum(), AuditStatusEnum.USING.getNum()).contains(this.getAuditStatus())) {
throw new IllegalArgumentException("规则《" + this.getDynamicRuleName() + "》原审批状态非法");

View File

@@ -138,8 +138,8 @@ public class StaticRuleObject {
@ExcelProperty("优先级")
@Max(value = 3)
@Min(value = 1)
@Schema(description = "优先级,1代表高2代表中3代表低", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Integer staticRulePriority;
@Schema(description = "优先级,1代表高2代表中3代表低", example = "1")
private Integer staticRulePriority = 1;
// @JsonProperty("static_rule_range")
// @ExcelProperty("范围")
// @Schema(description = "范围", example = "北京", requiredMode = Schema.RequiredMode.REQUIRED)
@@ -147,7 +147,7 @@ public class StaticRuleObject {
@JsonProperty("static_rule_frequency")
@ExcelIgnore
@Min(value = 1)
@Schema(description = "频率最低为1", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
@Schema(description = "频率最低为1", example = "1")
private Integer staticRuleFrequency = 2;
@JsonProperty("audit_user_name")

View File

@@ -1,6 +1,7 @@
package com.realtime.protection.configuration.entity.task;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Future;
import jakarta.validation.constraints.NotNull;
@@ -101,4 +102,40 @@ public class Task {
@JsonProperty("audit_user_depart")
@Schema(description = "审核用户部门", example = "部门1")
private String auditUserDepart;
/*
策略模板(事件类型、防护等级)都移动到任务表中
*/
@JsonProperty("event_type")
@Schema(description = "事件类型", example = "反射型ddos")
private String eventType;
@JsonProperty("protect_level")
@Schema(description = "防护等级", example = "低=1中=2高=3")
private Integer protectLevel;
@JsonProperty("template_id")
@Schema(description = "策略模板ID", example = "1")
private Integer templateId;
@JsonProperty("template_name")
@Schema(description = "策略模板名称", example = "策略模板1")
private String templateName;
@JsonProperty("source_system")
@Schema(description = "数据来源系统", example = "bw系统")
private String sourceSystem;
@JsonProperty("protect_object_ids")
@Schema(description = "防护对象ID列表", example = "[1, 2, 3]")
private List<Integer> protectObjectIds;
@JsonProperty("protect_objects")
@Schema(description = "完整防护对象列表", example = "[{protect_object_id: 1, protect_object_name: '北京'}, {protect_object_id: 2, protect_object_name: '上海'}]",
accessMode = Schema.AccessMode.READ_ONLY)
private List<ProtectObject> protectObjects;
}

View File

@@ -61,9 +61,9 @@ public class TaskCommandInfo {
private String eventType;
@Schema(description = "指令下发频率", example = "30")
@NotNull(message = "指令下发频率不能为空。")
// @NotNull(message = "指令下发频率不能为空。")
@JsonProperty("frequency")
private Integer frequency;
private Integer frequency = 3;
@Schema(description = "任务开始时间", example = "2025-10-14T10:23:33")
@NotNull(message = "任务开始时间不能为空。")