1、策略模板、白名单增加display_id
2、所有对象的查询新增display_id字段
(cherry picked from commit b6061f58e1)
This commit is contained in:
@@ -77,6 +77,10 @@ public class Template {
|
|||||||
@Schema(description = "防御策略模板审核状态(0为未审核,1为已退回,2为审核通过)", example = "1", accessMode = Schema.AccessMode.READ_ONLY)
|
@Schema(description = "防御策略模板审核状态(0为未审核,1为已退回,2为审核通过)", example = "1", accessMode = Schema.AccessMode.READ_ONLY)
|
||||||
private String auditStatus;
|
private String auditStatus;
|
||||||
|
|
||||||
|
@JsonProperty("template_display_id")
|
||||||
|
@Schema(description = "策略模板展示id", accessMode = Schema.AccessMode.READ_ONLY)
|
||||||
|
private String templateDisplayId;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否含有日常/应急/紧急防护等级态字段的字段
|
* 设置是否含有日常/应急/紧急防护等级态字段的字段
|
||||||
|
|||||||
@@ -61,4 +61,10 @@ public class WhiteListObject {
|
|||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
@Schema(description = "白名单对象审核状态(0为未审核,1为已退回,2为审核通过)", example = "2")
|
@Schema(description = "白名单对象审核状态(0为未审核,1为已退回,2为审核通过)", example = "2")
|
||||||
private Integer whiteListAuditStatus;
|
private Integer whiteListAuditStatus;
|
||||||
|
|
||||||
|
@JsonProperty("white_list_display_id")
|
||||||
|
@ExcelIgnore
|
||||||
|
@Schema(description = "白名单展示id", example = "BMD-20200101-123456", accessMode = Schema.AccessMode.READ_ONLY)
|
||||||
|
private String whiteListDisplayId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.realtime.protection.server.defense.template;
|
package com.realtime.protection.server.defense.template;
|
||||||
|
|
||||||
import com.realtime.protection.configuration.entity.defense.template.Template;
|
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||||
|
import com.realtime.protection.configuration.utils.Counter;
|
||||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -14,9 +17,11 @@ import java.util.Map;
|
|||||||
public class TemplateService {
|
public class TemplateService {
|
||||||
|
|
||||||
private final TemplateMapper templateMapper;
|
private final TemplateMapper templateMapper;
|
||||||
|
private final Counter counter;
|
||||||
|
|
||||||
public TemplateService(TemplateMapper templateMapper) {
|
public TemplateService(TemplateMapper templateMapper, Counter counter) {
|
||||||
this.templateMapper = templateMapper;
|
this.templateMapper = templateMapper;
|
||||||
|
this.counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -25,6 +30,13 @@ public class TemplateService {
|
|||||||
templateMapper.newProtectLevel(template.getProtectLevelMedium());
|
templateMapper.newProtectLevel(template.getProtectLevelMedium());
|
||||||
templateMapper.newProtectLevel(template.getProtectLevelHigh());
|
templateMapper.newProtectLevel(template.getProtectLevelHigh());
|
||||||
|
|
||||||
|
template.setTemplateDisplayId(
|
||||||
|
"CLMB-"
|
||||||
|
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||||
|
+ "-"
|
||||||
|
+ String.format("%06d", counter.generateId("strategy_template"))
|
||||||
|
);
|
||||||
|
|
||||||
templateMapper.newTemplate(template);
|
templateMapper.newTemplate(template);
|
||||||
|
|
||||||
if (template.getTemplateId() == null) {
|
if (template.getTemplateId() == null) {
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class StaticRuleService {
|
|||||||
|
|
||||||
List<StaticRuleObject> StaticRuleBatch = ListUtils.newArrayListWithExpectedSize(100);
|
List<StaticRuleObject> StaticRuleBatch = ListUtils.newArrayListWithExpectedSize(100);
|
||||||
for (StaticRuleObject staticRule : list) {
|
for (StaticRuleObject staticRule : list) {
|
||||||
staticRule.setStaticRuleCreateTime(LocalDateTime.now());
|
// staticRule.setStaticRuleCreateTime(LocalDateTime.now());
|
||||||
staticRule.setStaticRuleDisplayId(
|
staticRule.setStaticRuleDisplayId(
|
||||||
"JTGZ-"
|
"JTGZ-"
|
||||||
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.alibaba.excel.util.ListUtils;
|
|||||||
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
|
||||||
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
|
||||||
import com.realtime.protection.configuration.entity.whitelist.WhiteListObject;
|
import com.realtime.protection.configuration.entity.whitelist.WhiteListObject;
|
||||||
|
import com.realtime.protection.configuration.utils.Counter;
|
||||||
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
|
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
|
||||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
|
||||||
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
|
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
|
||||||
@@ -11,6 +12,8 @@ import com.realtime.protection.server.rule.staticrule.StaticRuleMapper;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -23,18 +26,28 @@ public class WhiteListService {
|
|||||||
private final StaticRuleMapper staticRuleMapper;
|
private final StaticRuleMapper staticRuleMapper;
|
||||||
|
|
||||||
private final SqlSessionWrapper sqlSessionWrapper;
|
private final SqlSessionWrapper sqlSessionWrapper;
|
||||||
|
private final Counter counter;
|
||||||
|
|
||||||
public WhiteListService(WhiteListMapper whiteListMapper,
|
public WhiteListService(WhiteListMapper whiteListMapper,
|
||||||
StaticRuleMapper staticRuleMapper,
|
StaticRuleMapper staticRuleMapper,
|
||||||
SqlSessionWrapper sqlSessionWrapper) {
|
SqlSessionWrapper sqlSessionWrapper, Counter counter) {
|
||||||
this.whiteListMapper = whiteListMapper;
|
this.whiteListMapper = whiteListMapper;
|
||||||
this.staticRuleMapper = staticRuleMapper;
|
this.staticRuleMapper = staticRuleMapper;
|
||||||
this.sqlSessionWrapper = sqlSessionWrapper;
|
this.sqlSessionWrapper = sqlSessionWrapper;
|
||||||
|
this.counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//新建一个whitelist
|
//新建一个whitelist
|
||||||
public Integer newWhiteListObject(WhiteListObject object) {
|
public Integer newWhiteListObject(WhiteListObject object) {
|
||||||
|
|
||||||
|
object.setWhiteListDisplayId(
|
||||||
|
"BMD-"
|
||||||
|
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||||
|
+ "-"
|
||||||
|
+ String.format("%06d", counter.generateId("white_list"))
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
whiteListMapper.newWhiteListObject(object);
|
whiteListMapper.newWhiteListObject(object);
|
||||||
|
|
||||||
return object.getWhiteListId();
|
return object.getWhiteListId();
|
||||||
@@ -50,6 +63,13 @@ public class WhiteListService {
|
|||||||
|
|
||||||
List<WhiteListObject> WhiteListBatch = ListUtils.newArrayListWithExpectedSize(100);
|
List<WhiteListObject> WhiteListBatch = ListUtils.newArrayListWithExpectedSize(100);
|
||||||
for (WhiteListObject whiteListObject : whiteListObjectList) {
|
for (WhiteListObject whiteListObject : whiteListObjectList) {
|
||||||
|
whiteListObject.setWhiteListDisplayId(
|
||||||
|
"BMD-"
|
||||||
|
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
||||||
|
+ "-"
|
||||||
|
+ String.format("%06d", counter.generateId("white_list"))
|
||||||
|
|
||||||
|
);
|
||||||
WhiteListBatch.add(whiteListObject);
|
WhiteListBatch.add(whiteListObject);
|
||||||
if (WhiteListBatch.size() < 100) {
|
if (WhiteListBatch.size() < 100) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -152,6 +152,8 @@
|
|||||||
<result column="strategy_template_name" property="dynamicRuleEventType"/>
|
<result column="strategy_template_name" property="dynamicRuleEventType"/>
|
||||||
<result column="strategy_template_source_system" property="dynamicRuleSourceSystem"/>
|
<result column="strategy_template_source_system" property="dynamicRuleSourceSystem"/>
|
||||||
<result column="audit_status" property="auditStatus"/>
|
<result column="audit_status" property="auditStatus"/>
|
||||||
|
<result column="dynamic_rule_display_id" property="dynamicRuleDisplayId"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryDynamicRuleById" resultMap="dynamicRuleMap">
|
<select id="queryDynamicRuleById" resultMap="dynamicRuleMap">
|
||||||
|
|||||||
@@ -43,6 +43,8 @@
|
|||||||
<result column="protect_object_url" property="protectObjectURL"/>
|
<result column="protect_object_url" property="protectObjectURL"/>
|
||||||
<result column="protect_object_protocol" property="protectObjectProtocol"/>
|
<result column="protect_object_protocol" property="protectObjectProtocol"/>
|
||||||
<result column="protect_object_audit_status" property="protectObjectAuditStatus"/>
|
<result column="protect_object_audit_status" property="protectObjectAuditStatus"/>
|
||||||
|
<result column="protect_object_display_id" property="protectObjectDisplayId"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryProtectObjects" resultMap="protectObjectMap">
|
<select id="queryProtectObjects" resultMap="protectObjectMap">
|
||||||
@@ -50,6 +52,7 @@
|
|||||||
protect_object_id, protect_object_name, protect_object_system_name,
|
protect_object_id, protect_object_name, protect_object_system_name,
|
||||||
INET_NTOA(protect_object_ip) as protect_object_ip,
|
INET_NTOA(protect_object_ip) as protect_object_ip,
|
||||||
protect_object_port, protect_object_url, protect_object_protocol, protect_object_audit_status
|
protect_object_port, protect_object_url, protect_object_protocol, protect_object_audit_status
|
||||||
|
,protect_object_display_id
|
||||||
FROM t_protect_object
|
FROM t_protect_object
|
||||||
<where>
|
<where>
|
||||||
<if test="proobj_name != null">AND protect_object_name LIKE CONCAT('%', #{proobj_name}, '%')</if>
|
<if test="proobj_name != null">AND protect_object_name LIKE CONCAT('%', #{proobj_name}, '%')</if>
|
||||||
@@ -93,7 +96,7 @@
|
|||||||
protect_object_port,
|
protect_object_port,
|
||||||
protect_object_url,
|
protect_object_url,
|
||||||
protect_object_protocol,
|
protect_object_protocol,
|
||||||
protect_object_audit_status
|
protect_object_audit_status,protect_object_display_id
|
||||||
FROM t_protect_object
|
FROM t_protect_object
|
||||||
WHERE protect_object_id = #{proobj_id}
|
WHERE protect_object_id = #{proobj_id}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -135,6 +135,8 @@
|
|||||||
<result column="static_rule_url" property="staticRuleURL"/>
|
<result column="static_rule_url" property="staticRuleURL"/>
|
||||||
<result column="static_rule_priority" property="staticRulePriority"/>
|
<result column="static_rule_priority" property="staticRulePriority"/>
|
||||||
<result column="static_rule_frequency" property="staticRuleFrequency"/>
|
<result column="static_rule_frequency" property="staticRuleFrequency"/>
|
||||||
|
|
||||||
|
<result column="static_rule_display_id" property="staticRuleDisplayId"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryStaticRule" resultMap="staticRuleMap">
|
<select id="queryStaticRule" resultMap="staticRuleMap">
|
||||||
|
|||||||
@@ -59,6 +59,8 @@
|
|||||||
<result column="task_create_username" property="taskCreateUsername"/>
|
<result column="task_create_username" property="taskCreateUsername"/>
|
||||||
<result column="task_create_depart" property="taskCreateDepart"/>
|
<result column="task_create_depart" property="taskCreateDepart"/>
|
||||||
|
|
||||||
|
<result column="task_display_id" property="taskDisplayId"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryTasks" resultMap="taskMap">
|
<select id="queryTasks" resultMap="taskMap">
|
||||||
|
|||||||
@@ -9,12 +9,12 @@
|
|||||||
strategy_template_high_level_id,
|
strategy_template_high_level_id,
|
||||||
strategy_template_create_user_id, strategy_template_create_username,
|
strategy_template_create_user_id, strategy_template_create_username,
|
||||||
strategy_template_create_depart,
|
strategy_template_create_depart,
|
||||||
strategy_template_description)
|
strategy_template_description, strategy_template_display_id)
|
||||||
VALUE (#{template.templateName}, #{template.sourceSystem},
|
VALUE (#{template.templateName}, #{template.sourceSystem},
|
||||||
#{template.protectLevelLow.protectLevelId}, #{template.protectLevelMedium.protectLevelId},
|
#{template.protectLevelLow.protectLevelId}, #{template.protectLevelMedium.protectLevelId},
|
||||||
#{template.protectLevelHigh.protectLevelId},
|
#{template.protectLevelHigh.protectLevelId},
|
||||||
#{template.createUserId}, #{template.createUsername}, #{template.createDepart},
|
#{template.createUserId}, #{template.createUsername}, #{template.createDepart},
|
||||||
#{template.description})
|
#{template.description}, #{template.templateDisplayId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="newProtectLevel" useGeneratedKeys="true" keyProperty="protectLevelId">
|
<insert id="newProtectLevel" useGeneratedKeys="true" keyProperty="protectLevelId">
|
||||||
@@ -38,6 +38,8 @@
|
|||||||
<result column="strategy_template_description" property="description"/>
|
<result column="strategy_template_description" property="description"/>
|
||||||
<result column="audit_status" property="auditStatus"/>
|
<result column="audit_status" property="auditStatus"/>
|
||||||
|
|
||||||
|
<result column="strategy_template_display_id" property="templateDisplayId"/>
|
||||||
|
|
||||||
<association property="protectLevelLow"
|
<association property="protectLevelLow"
|
||||||
javaType="com.realtime.protection.configuration.entity.defense.template.ProtectLevel">
|
javaType="com.realtime.protection.configuration.entity.defense.template.ProtectLevel">
|
||||||
<id column="low_protect_level_id" property="protectLevelId"/>
|
<id column="low_protect_level_id" property="protectLevelId"/>
|
||||||
|
|||||||
@@ -8,24 +8,24 @@
|
|||||||
insert into t_white_list(white_list_name, white_list_system_name,
|
insert into t_white_list(white_list_name, white_list_system_name,
|
||||||
white_list_ip, white_list_port,
|
white_list_ip, white_list_port,
|
||||||
white_list_url, white_list_protocol,
|
white_list_url, white_list_protocol,
|
||||||
white_list_audit_status, create_time)
|
white_list_audit_status, create_time, white_list_display_id)
|
||||||
values (#{object.whiteListName}, #{object.whiteListSystemName},
|
values (#{object.whiteListName}, #{object.whiteListSystemName},
|
||||||
INET_ATON(#{object.whiteListIP}), #{object.whiteListPort},
|
INET_ATON(#{object.whiteListIP}), #{object.whiteListPort},
|
||||||
#{object.whiteListUrl}, #{object.whiteListProtocol},
|
#{object.whiteListUrl}, #{object.whiteListProtocol},
|
||||||
0, NOW())
|
0, NOW(), #{object.whiteListDisplayId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="newWhiteListObjects">
|
<insert id="newWhiteListObjects">
|
||||||
insert into t_white_list(white_list_name, white_list_system_name,
|
insert into t_white_list(white_list_name, white_list_system_name,
|
||||||
white_list_ip, white_list_port,
|
white_list_ip, white_list_port,
|
||||||
white_list_url, white_list_protocol,
|
white_list_url, white_list_protocol,
|
||||||
white_list_audit_status, create_time)
|
white_list_audit_status, create_time, white_list_display_id)
|
||||||
values
|
values
|
||||||
<foreach collection="whiteListObjects" item="object" separator=",">
|
<foreach collection="whiteListObjects" item="object" separator=",">
|
||||||
(#{object.whiteListName}, #{object.whiteListSystemName},
|
(#{object.whiteListName}, #{object.whiteListSystemName},
|
||||||
INET_ATON(#{object.whiteListIP}), #{object.whiteListPort},
|
INET_ATON(#{object.whiteListIP}), #{object.whiteListPort},
|
||||||
#{object.whiteListUrl}, #{object.whiteListProtocol},
|
#{object.whiteListUrl}, #{object.whiteListProtocol},
|
||||||
0, NOW())
|
0, NOW(), #{object.whiteListDisplayId})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -47,6 +47,8 @@
|
|||||||
<result column="white_list_url" property="whiteListUrl"/>
|
<result column="white_list_url" property="whiteListUrl"/>
|
||||||
<result column="white_list_protocol" property="whiteListProtocol"/>
|
<result column="white_list_protocol" property="whiteListProtocol"/>
|
||||||
<result column="white_list_audit_status" property="whiteListAuditStatus"/>
|
<result column="white_list_audit_status" property="whiteListAuditStatus"/>
|
||||||
|
<result column="white_list_display_id" property="whiteListDisplayId"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryWhiteListObject" resultMap="whiteListMap">
|
<select id="queryWhiteListObject" resultMap="whiteListMap">
|
||||||
|
|||||||
Reference in New Issue
Block a user