201 lines
8.1 KiB
XML
201 lines
8.1 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.realtime.protection.server.alertmessage.AlertMessageMapper">
|
|
|
|
<resultMap id="dynamicCommmandMap" type="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
|
|
<result column="task_name" property="taskName"/>
|
|
<result column="task_create_username" property="taskCreateUsername"/>
|
|
<result column="task_create_depart" property="taskCreateDepart"/>
|
|
<result column="task_create_userid" property="taskCreateUserId"/>
|
|
|
|
<result column="task_id" property="taskId"/>
|
|
<result column="dynamic_rule_id" property="ruleId"/>
|
|
|
|
<result column="task_act" property="taskAct"/>
|
|
<result column="task_type" property="taskType"/>
|
|
<result column="dynamic_rule_frequency" property="frequency"/>
|
|
<result column="task_start_time" property="startTime"/>
|
|
<result column="task_end_time" property="endTime"/>
|
|
|
|
<result column="template_id" property="templateId"/>
|
|
|
|
<result column="task_range" property="distributePoint"/>
|
|
<result column="strategy_template_name" property="eventType"/>
|
|
|
|
<result column="dynamic_rule_protect_level" property="protectLevel"/>
|
|
<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"/>
|
|
<result column="has_protect_object_ip" property="hasProtectObjectIP"/>
|
|
<result column="has_protect_object_port" property="hasProtectObjectPort"/>
|
|
<result column="has_peer_ip" property="hasPeerIP"/>
|
|
<result column="has_peer_port" property="hasPeerPort"/>
|
|
<result column="has_protocol" property="hasProtocol"/>
|
|
<result column="has_url" property="hasURL"/>
|
|
<result column="has_dns" property="hasDNS"/>
|
|
<result column="is_full_flow" property="isFullFlow"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="alertMessageMap" type="com.realtime.protection.configuration.entity.alert.AlertMessage">
|
|
<id column="ALERT_MESSAGE_ID" property="alertMessageUUID"/>
|
|
<result column="TASK_ID" property="taskId"/>
|
|
<result column="DYNAMIC_RULE_ID" property="dynamicRuleId"/>
|
|
|
|
<result column="COMMAND_UUID" property="commandUUID"/>
|
|
|
|
<result column="CREATE_TIME" property="createTime"/>
|
|
<result column="LAST_UPDATE" property="modifyTime"/>
|
|
<result column="CONTENT" property="content"/>
|
|
|
|
<association property="fiveTupleWithMask">
|
|
<result column="ADDR_TYPE" property="addrType"/>
|
|
<result column="SRC_IP" property="sourceIP"/>
|
|
<result column="SRC_PORT" property="sourcePort"/>
|
|
<result column="DST_IP" property="destinationIP"/>
|
|
<result column="DST_PORT" property="destinationPort"/>
|
|
<result column="PROTOCOL" property="protocol"/>
|
|
<result column="MASK_SRC_IP" property="maskSourceIP"/>
|
|
<result column="MASK_SRC_PORT" property="maskSourcePort"/>
|
|
<result column="MASK_DST_IP" property="maskDestinationIP"/>
|
|
<result column="MASK_DST_PORT" property="maskDestinationPort"/>
|
|
<result column="MASK_PROTOCOL" property="maskProtocol"/>
|
|
|
|
</association>
|
|
|
|
</resultMap>
|
|
|
|
<insert id="insertAlertMessage">
|
|
insert
|
|
into t_alertmessage(TASK_ID,
|
|
DYNAMIC_RULE_ID,
|
|
ADDR_TYPE,
|
|
SRC_IP,
|
|
SRC_PORT,
|
|
DST_IP,
|
|
DST_PORT,
|
|
PROTOCOL,
|
|
MASK_SRC_IP,
|
|
MASK_SRC_PORT,
|
|
MASK_DST_IP,
|
|
MASK_DST_PORT,
|
|
MASK_PROTOCOL,
|
|
COMMAND_UUID,
|
|
CREATE_TIME,
|
|
LAST_UPDATE,
|
|
ALERT_MESSAGE_ID,
|
|
CONTENT)
|
|
values (
|
|
#{taskId},
|
|
#{dynamicRuleId},
|
|
#{fiveTupleWithMask.addrType},
|
|
#{fiveTupleWithMask.sourceIP},
|
|
#{fiveTupleWithMask.sourcePort},
|
|
#{fiveTupleWithMask.destinationIP},
|
|
#{fiveTupleWithMask.destinationPort},
|
|
#{fiveTupleWithMask.protocol},
|
|
#{fiveTupleWithMask.maskSourceIP},
|
|
#{fiveTupleWithMask.maskSourcePort},
|
|
#{fiveTupleWithMask.maskDestinationIP},
|
|
#{fiveTupleWithMask.maskDestinationPort},
|
|
#{fiveTupleWithMask.maskProtocol},
|
|
#{commandUUID},
|
|
NOW(),
|
|
NOW(),
|
|
UUID(),
|
|
#{content})
|
|
|
|
</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="getDynamicTaskInfos"
|
|
resultMap="dynamicCommmandMap" >
|
|
select
|
|
t_task.task_name,
|
|
|
|
t_task.task_id,
|
|
t_dr.dynamic_rule_id,
|
|
|
|
t_task.task_create_username,
|
|
t_task.task_create_depart,
|
|
t_task.task_create_userid,
|
|
|
|
t_task.task_type,
|
|
t_task.task_act,
|
|
t_dr.dynamic_rule_frequency,
|
|
|
|
t_task.task_start_time,
|
|
t_task.task_end_time,
|
|
|
|
t_dr.template_id,
|
|
t_task.task_range,
|
|
t_dr.dynamic_rule_protect_level,
|
|
t_task.task_status,
|
|
|
|
t_tmplate.strategy_template_name
|
|
|
|
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
|
|
( t_dr.template_id = t_tmplate.strategy_template_id )
|
|
where
|
|
t_task.task_id = #{taskId}
|
|
</select>
|
|
|
|
<select id="queryAlermsByCommandId"
|
|
resultMap="alertMessageMap">
|
|
select
|
|
t_alertmessage.ALERT_MESSAGE_ID,
|
|
t_alertmessage.TASK_ID,
|
|
t_alertmessage.DYNAMIC_RULE_ID,
|
|
|
|
t_alertmessage.ADDR_TYPE,
|
|
t_alertmessage.SRC_IP,
|
|
t_alertmessage.SRC_PORT,
|
|
t_alertmessage.DST_IP,
|
|
t_alertmessage.DST_PORT,
|
|
t_alertmessage.PROTOCOL,
|
|
t_alertmessage.MASK_SRC_IP,
|
|
t_alertmessage.MASK_SRC_PORT,
|
|
t_alertmessage.MASK_DST_IP,
|
|
t_alertmessage.MASK_DST_PORT,
|
|
t_alertmessage.MASK_PROTOCOL,
|
|
|
|
t_alertmessage.COMMAND_UUID,
|
|
|
|
t_alertmessage.CREATE_TIME,
|
|
t_alertmessage.LAST_UPDATE,
|
|
t_alertmessage.CONTENT
|
|
|
|
from t_alertmessage
|
|
where
|
|
t_alertmessage.COMMAND_UUID = #{commandId}
|
|
AND IS_DELETE = FALSE
|
|
</select>
|
|
</mapper> |