1、重构Template,其他模块使用之前Template的也相应修改为新的Template
This commit is contained in:
@@ -76,7 +76,7 @@ public class DynamicRuleObject {
|
||||
@JsonProperty("template_id")
|
||||
@Schema(description = "策略模板id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer templateId;
|
||||
@NotNull
|
||||
// @NotNull
|
||||
@JsonProperty("dynamic_rule_protect_level")
|
||||
@Max(value = 3)
|
||||
@Min(value = 1)
|
||||
@@ -91,7 +91,7 @@ public class DynamicRuleObject {
|
||||
// @JsonProperty("dynamic_rule_range")
|
||||
// @Schema(description = "范围", example = "北京", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// private String dynamicRuleRange;
|
||||
@NotNull
|
||||
// @NotNull
|
||||
@JsonProperty("dynamic_rule_frequency")
|
||||
@Schema(description = "频率", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer dynamicRuleFrequency;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.realtime.protection.server.rule.dynamicrule;
|
||||
|
||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
||||
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||
import com.realtime.protection.configuration.entity.defense.template.TemplateNew;
|
||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -37,7 +37,7 @@ public interface DynamicRuleMapper {
|
||||
|
||||
void deleteDynamicRuleProtectObjectConcat(Integer dynamicRuleId);
|
||||
|
||||
Template queryTemplateByRuleId(Integer dynamicRuleId);
|
||||
TemplateNew queryTemplateByRuleId(Integer dynamicRuleId);
|
||||
|
||||
boolean newDynamicRulProtectObjectsConcat(Integer dynamicRuleId, List<Integer> protectObjectIds);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.realtime.protection.server.rule.dynamicrule;
|
||||
|
||||
import com.alibaba.excel.util.ListUtils;
|
||||
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||
import com.realtime.protection.configuration.entity.defense.template.TemplateNew;
|
||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||
import com.realtime.protection.configuration.utils.Counter;
|
||||
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
|
||||
@@ -122,7 +123,7 @@ public class DynamicRuleService {
|
||||
//查询DynamicRule关联的ProtectObject
|
||||
dynamicRuleObject.setProtectObjects(dynamicRuleMapper.queryProtectObjectByRuleId(dynamicRuleId));
|
||||
//查询DynamicRule关联的template详细信息
|
||||
Template template = dynamicRuleMapper.queryTemplateByRuleId(dynamicRuleId);
|
||||
TemplateNew template = dynamicRuleMapper.queryTemplateByRuleId(dynamicRuleId);
|
||||
if (template == null){
|
||||
//template在表中删除了,需要重新设置template(感觉这种情况不多见)
|
||||
dynamicRuleObject.setDynamicRuleSourceSystem(null);
|
||||
@@ -130,6 +131,7 @@ public class DynamicRuleService {
|
||||
}else{
|
||||
dynamicRuleObject.setDynamicRuleSourceSystem(template.getSourceSystem());
|
||||
dynamicRuleObject.setDynamicRuleEventType(template.getTemplateName());
|
||||
dynamicRuleObject.setDynamicRuleProtectLevel(Integer.valueOf(template.getProtectLevel()));
|
||||
}
|
||||
|
||||
return dynamicRuleObject;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<result column="task_status" property="taskStatus"/>
|
||||
</resultMap>
|
||||
<resultMap id="protectLevelMap" type="com.realtime.protection.configuration.entity.defense.template.ProtectLevel">
|
||||
<id column="protect_level_id" property="protectLevelId"/>
|
||||
<!-- <id column="protect_level_id" property="protectLevelId"/>-->
|
||||
<result column="has_protect_object_ip" property="hasProtectObjectIP"/>
|
||||
<result column="has_protect_object_port" property="hasProtectObjectPort"/>
|
||||
<result column="has_peer_ip" property="hasPeerIP"/>
|
||||
@@ -37,6 +37,7 @@
|
||||
<result column="has_url" property="hasURL"/>
|
||||
<result column="has_dns" property="hasDNS"/>
|
||||
<result column="is_full_flow" property="isFullFlow"/>
|
||||
<result column="is_protect_object_src" property="isProtectObjectIPSrc"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="alertMessageMap" type="com.realtime.protection.configuration.entity.alert.AlertMessage">
|
||||
@@ -109,28 +110,43 @@
|
||||
|
||||
</insert>
|
||||
|
||||
<!-- <select id="queryTemplateProtectLevel" resultMap="protectLevelMap">-->
|
||||
<!-- SELECT-->
|
||||
<!-- t_protect_level.protect_level_id,-->
|
||||
<!-- t_protect_level.has_protect_object_ip,-->
|
||||
<!-- t_protect_level.has_protect_object_port,-->
|
||||
<!-- t_protect_level.has_peer_ip,-->
|
||||
<!-- t_protect_level.has_peer_port,-->
|
||||
<!-- t_protect_level.has_protocol,-->
|
||||
<!-- t_protect_level.has_url,-->
|
||||
<!-- t_protect_level.has_dns,-->
|
||||
<!-- t_protect_level.is_full_flow-->
|
||||
<!-- FROM t_strategy_template-->
|
||||
<!-- <if test="protectLevel == 1">-->
|
||||
<!-- left join t_protect_level on t_strategy_template.strategy_template_low_level_id = t_protect_level.protect_level_id-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="protectLevel == 2">-->
|
||||
<!-- left join t_protect_level on t_strategy_template.strategy_template_medium_level_id = t_protect_level.protect_level_id-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="protectLevel == 3">-->
|
||||
<!-- left join t_protect_level on t_strategy_template.strategy_template_high_level_id = t_protect_level.protect_level_id-->
|
||||
<!-- </if>-->
|
||||
<!-- WHERE t_strategy_template.strategy_template_id = #{templateId}-->
|
||||
<!-- </select>-->
|
||||
|
||||
<select id="queryTemplateProtectLevel" resultMap="protectLevelMap">
|
||||
SELECT
|
||||
t_protect_level.protect_level_id,
|
||||
t_protect_level.has_protect_object_ip,
|
||||
t_protect_level.has_protect_object_port,
|
||||
t_protect_level.has_peer_ip,
|
||||
t_protect_level.has_peer_port,
|
||||
t_protect_level.has_protocol,
|
||||
t_protect_level.has_url,
|
||||
t_protect_level.has_dns,
|
||||
t_protect_level.is_full_flow
|
||||
FROM t_strategy_template
|
||||
<if test="protectLevel == 1">
|
||||
left join t_protect_level on t_strategy_template.strategy_template_low_level_id = t_protect_level.protect_level_id
|
||||
</if>
|
||||
<if test="protectLevel == 2">
|
||||
left join t_protect_level on t_strategy_template.strategy_template_medium_level_id = t_protect_level.protect_level_id
|
||||
</if>
|
||||
<if test="protectLevel == 3">
|
||||
left join t_protect_level on t_strategy_template.strategy_template_high_level_id = t_protect_level.protect_level_id
|
||||
</if>
|
||||
WHERE t_strategy_template.strategy_template_id = #{templateId}
|
||||
has_protect_object_ip,
|
||||
has_protect_object_port,
|
||||
has_peer_ip,
|
||||
has_peer_port,
|
||||
has_protocol,
|
||||
has_url,
|
||||
has_dns,
|
||||
is_full_flow,
|
||||
is_protect_object_src
|
||||
FROM t_strategy_template_new
|
||||
WHERE strategy_template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
<select id="getDynamicTaskInfos"
|
||||
@@ -162,7 +178,7 @@
|
||||
from t_task
|
||||
left join realtime_protection.t_dynamic_rule t_dr on
|
||||
(t_task.task_id = t_dr.dynamic_rule_used_task_id and t_dr.dynamic_rule_id = #{dynamicRuleId})
|
||||
left join realtime_protection.t_strategy_template t_tmplate on
|
||||
left join realtime_protection.t_strategy_template_new t_tmplate on
|
||||
( t_dr.template_id = t_tmplate.strategy_template_id )
|
||||
where
|
||||
t_task.task_id = #{taskId}
|
||||
|
||||
@@ -174,13 +174,16 @@
|
||||
<result column="dynamic_rule_create_username" property="dynamicRuleCreateUsername"/>
|
||||
<result column="dynamic_rule_create_depart" property="dynamicRuleCreateDepart"/>
|
||||
<result column="template_id" property="templateId"/>
|
||||
<result column="dynamic_rule_protect_level" property="dynamicRuleProtectLevel"/>
|
||||
<!-- <result column="dynamic_rule_protect_level" property="dynamicRuleProtectLevel"/>-->
|
||||
<result column="dynamic_rule_priority" property="dynamicRulePriority"/>
|
||||
<result column="dynamic_rule_frequency" property="dynamicRuleFrequency"/>
|
||||
<result column="audit_status" property="auditStatus"/>
|
||||
<!-- <result column="protect_object_id" property="protectObjectIds"/>-->
|
||||
<result column="strategy_template_name" property="dynamicRuleEventType"/>
|
||||
<result column="strategy_template_source_system" property="dynamicRuleSourceSystem"/>
|
||||
<result column="event_type" property="dynamicRuleSourceSystem"/>
|
||||
<result column="protect_level" property="dynamicRuleProtectLevel"/>
|
||||
|
||||
<result column="audit_status" property="auditStatus"/>
|
||||
<result column="dynamic_rule_display_id" property="dynamicRuleDisplayId"/>
|
||||
<result column="audit_user_name" property="auditUserName"/>
|
||||
@@ -222,8 +225,8 @@
|
||||
from t_dynamic_rule
|
||||
# left join t_protect_object_dynamic_rule_conn
|
||||
# on t_dynamic_rule.dynamic_rule_id = t_protect_object_dynamic_rule_conn.dynamic_rule_id
|
||||
left join t_strategy_template
|
||||
on t_dynamic_rule.template_id = t_strategy_template.strategy_template_id
|
||||
left join t_strategy_template_new
|
||||
on t_dynamic_rule.template_id = t_strategy_template_new.strategy_template_id
|
||||
<where>
|
||||
<if test="dynamicRuleName != null and dynamicRuleName !=''" >
|
||||
t_dynamic_rule.dynamic_rule_name like concat('%', #{dynamicRuleName}, '%')
|
||||
@@ -232,7 +235,7 @@
|
||||
and t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}
|
||||
</if>
|
||||
<if test="sourceSystem != null and sourceSystem !=''">
|
||||
and t_strategy_template.strategy_template_source_system = #{sourceSystem}
|
||||
and t_strategy_template_new.strategy_template_source_system = #{sourceSystem}
|
||||
</if>
|
||||
<if test="creator != null and creator !=''">
|
||||
and t_dynamic_rule.dynamic_rule_create_username = #{creator}
|
||||
@@ -241,10 +244,10 @@
|
||||
and t_dynamic_rule.audit_status = #{auditStatus}
|
||||
</if>
|
||||
<if test="eventType != null and eventType !=''">
|
||||
and t_strategy_template.strategy_template_name = #{eventType}
|
||||
and t_strategy_template_new.event_type = #{eventType}
|
||||
</if>
|
||||
<if test="protectLevel != null">
|
||||
and t_dynamic_rule.dynamic_rule_protect_level = #{protectLevel}
|
||||
and t_strategy_template_new.protect_level = #{protectLevel}
|
||||
</if>
|
||||
|
||||
</where>
|
||||
@@ -252,17 +255,31 @@
|
||||
</select>
|
||||
|
||||
|
||||
<resultMap id="templateMap" type="com.realtime.protection.configuration.entity.defense.template.Template">
|
||||
<resultMap id="templateMap" type="com.realtime.protection.configuration.entity.defense.template.TemplateNew">
|
||||
<id column="strategy_template_id" property="templateId"/>
|
||||
<result column="strategy_template_name" property="templateName"/>
|
||||
<result column="strategy_template_display_id" property="templateDisplayId"/>
|
||||
<result column="strategy_template_source_system" property="sourceSystem"/>
|
||||
<result column="event_type" property="eventType"/>
|
||||
<result column="protect_level" property="protectLevel"/>
|
||||
<result column="strategy_template_description" property="description"/>
|
||||
<result column="has_protect_object_ip" property="hasProtectObjectIP"/>
|
||||
<result column="has_protect_object_port" property="hasProtectObjectPort"/>
|
||||
<result column="has_protocol" property="hasProtocol"/>
|
||||
<result column="has_url" property="hasURL"/>
|
||||
<result column="has_dns" property="hasDNS"/>
|
||||
<result column="has_peer_ip" property="hasPeerIP"/>
|
||||
<result column="has_peer_port" property="hasPeerPort"/>
|
||||
<result column="is_full_flow" property="isFullFlow"/>
|
||||
<result column="is_protect_object_src" property="isProtectObjectIPSrc"/>
|
||||
|
||||
</resultMap>
|
||||
|
||||
<select id="queryTemplateByRuleId" resultMap="templateMap">
|
||||
select *
|
||||
from t_strategy_template
|
||||
from t_strategy_template_new
|
||||
inner join t_dynamic_rule
|
||||
on t_strategy_template.strategy_template_id = t_dynamic_rule.template_id
|
||||
on t_strategy_template_new.strategy_template_id = t_dynamic_rule.template_id
|
||||
where t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}
|
||||
</select>
|
||||
<select id="queryProtectObjectById" resultType="java.lang.Boolean">
|
||||
@@ -274,8 +291,8 @@
|
||||
<select id="queryDynamicRuleTotalNum" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM t_dynamic_rule
|
||||
left join t_strategy_template
|
||||
on t_dynamic_rule.template_id = t_strategy_template.strategy_template_id
|
||||
left join t_strategy_template_new
|
||||
on t_dynamic_rule.template_id = t_strategy_template_new.strategy_template_id
|
||||
<where>
|
||||
<if test="dynamicRuleName != null">
|
||||
t_dynamic_rule.dynamic_rule_name like concat('%', #{dynamicRuleName}, '%')
|
||||
@@ -284,7 +301,7 @@
|
||||
and t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}
|
||||
</if>
|
||||
<if test="sourceSystem != null">
|
||||
and t_strategy_template.strategy_template_source_system = #{sourceSystem}
|
||||
and t_strategy_template_new.strategy_template_source_system = #{sourceSystem}
|
||||
</if>
|
||||
<if test="creator != null">
|
||||
and t_dynamic_rule.dynamic_rule_create_username = #{creator}
|
||||
@@ -293,10 +310,10 @@
|
||||
and t_dynamic_rule.audit_status = #{auditStatus}
|
||||
</if>
|
||||
<if test="eventType != null and eventType !=''">
|
||||
and t_strategy_template.strategy_template_name = #{eventType}
|
||||
and t_strategy_template_new.strategy_template_name = #{eventType}
|
||||
</if>
|
||||
<if test="protectLevel != null">
|
||||
and t_dynamic_rule.dynamic_rule_protect_level = #{protectLevel}
|
||||
and t_strategy_template_new.protect_level = #{protectLevel}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
@@ -305,8 +322,8 @@
|
||||
resultMap="dynamicRulePageQueryMap">
|
||||
select *
|
||||
from t_dynamic_rule
|
||||
left join t_strategy_template
|
||||
on t_dynamic_rule.template_id = t_strategy_template.strategy_template_id
|
||||
left join t_strategy_template_new
|
||||
on t_dynamic_rule.template_id = t_strategy_template_new.strategy_template_id
|
||||
where dynamic_rule_id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
|
||||
@@ -354,8 +354,8 @@
|
||||
task_start_time,
|
||||
task_end_time,
|
||||
tdr.dynamic_rule_id as rule_id,
|
||||
strategy_template_source_system as source_system,
|
||||
strategy_template_name as event_type,
|
||||
tst.strategy_template_source_system as source_system,
|
||||
tst.event_type as event_type,
|
||||
tdr.log_rule_id,
|
||||
INET_NTOA(protect_object_ip) as protect_object_ip,
|
||||
protect_object_port,
|
||||
@@ -366,7 +366,7 @@
|
||||
LEFT JOIN realtime_protection.t_protect_object_dynamic_rule_conn tpodrc
|
||||
on tdr.dynamic_rule_id = tpodrc.dynamic_rule_id
|
||||
LEFT JOIN realtime_protection.t_protect_object tpo on tpo.protect_object_id = tpodrc.protect_object_id
|
||||
LEFT JOIN realtime_protection.t_strategy_template tst on tdr.template_id = tst.strategy_template_id
|
||||
LEFT JOIN realtime_protection.t_strategy_template_new tst on tdr.template_id = tst.strategy_template_id
|
||||
WHERE task_id = #{task_id}
|
||||
</select>
|
||||
<select id="queryTaskTotalNum" resultType="java.lang.Integer">
|
||||
|
||||
Reference in New Issue
Block a user