1、bugfix
2、
This commit is contained in:
@@ -75,46 +75,46 @@ public class StaticRuleObject {
|
|||||||
|
|
||||||
@JsonProperty("static_rule_sip")
|
@JsonProperty("static_rule_sip")
|
||||||
@ExcelProperty("源IP地址")
|
@ExcelProperty("源IP地址")
|
||||||
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "Invalid IPv4 Address")
|
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "错误 IPv4 地址")
|
||||||
@Schema(description = "源IP地址", example = "1.1.1.1")
|
@Schema(description = "源IP地址", example = "1.1.1.1")
|
||||||
private String staticRuleSip;
|
private String staticRuleSip;
|
||||||
@JsonProperty("static_rule_msip")
|
@JsonProperty("static_rule_msip")
|
||||||
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "Invalid IPv4 Address")
|
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "I错误 IPv4 地址")
|
||||||
@ExcelProperty("源IP地址掩码")
|
@ExcelProperty("源IP地址掩码")
|
||||||
@Schema(description = "源IP地址掩码", example = "255.255.255.0")
|
@Schema(description = "源IP地址掩码", example = "255.255.255.0")
|
||||||
private String staticRuleMsip;
|
private String staticRuleMsip;
|
||||||
@JsonProperty("static_rule_sport")
|
@JsonProperty("static_rule_sport")
|
||||||
@ExcelProperty("源端口")
|
@ExcelProperty("源端口")
|
||||||
@Max(value = 65535, message = "port should not be more than 65535")
|
@Max(value = 65535, message = "端口号不能大于65535")
|
||||||
@Min(value = 1, message = "port should not be less than 1")
|
@Min(value = 1, message = "端口号不能小于1")
|
||||||
@Schema(description = "源端口", example = "8080")
|
@Schema(description = "源端口", example = "8080")
|
||||||
private Integer staticRuleSport;
|
private Integer staticRuleSport;
|
||||||
@JsonProperty("static_rule_msport")
|
@JsonProperty("static_rule_msport")
|
||||||
@ExcelProperty("源端口掩码")
|
@ExcelProperty("源端口掩码")
|
||||||
@Max(value = 65535, message = "port should not be more than 65535")
|
@Max(value = 65535, message = "端口号不能大于65535")
|
||||||
@Min(value = 1, message = "port should not be less than 1")
|
@Min(value = 1, message = "端口号不能小于1")
|
||||||
@Schema(description = "源端口掩码", example = "65535")
|
@Schema(description = "源端口掩码", example = "65535")
|
||||||
private Integer staticRuleMsport;
|
private Integer staticRuleMsport;
|
||||||
@JsonProperty("static_rule_dip")
|
@JsonProperty("static_rule_dip")
|
||||||
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "Invalid IPv4 Address")
|
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "错误 IPv4 地址")
|
||||||
@ExcelProperty("目的IP地址")
|
@ExcelProperty("目的IP地址")
|
||||||
@Schema(description = "目的IP地址", example = "2.2.2.2")
|
@Schema(description = "目的IP地址", example = "2.2.2.2")
|
||||||
private String staticRuleDip;
|
private String staticRuleDip;
|
||||||
@JsonProperty("static_rule_mdip")
|
@JsonProperty("static_rule_mdip")
|
||||||
@ExcelProperty("目的IP地址掩码")
|
@ExcelProperty("目的IP地址掩码")
|
||||||
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "Invalid IPv4 Address")
|
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "错误 IPv4 地址")
|
||||||
@Schema(description = "目的IP地址掩码", example = "255.255.255.0")
|
@Schema(description = "目的IP地址掩码", example = "255.255.255.0")
|
||||||
private String staticRuleMdip;
|
private String staticRuleMdip;
|
||||||
@JsonProperty("static_rule_dport")
|
@JsonProperty("static_rule_dport")
|
||||||
@ExcelProperty("目的端口")
|
@ExcelProperty("目的端口")
|
||||||
@Max(value = 65535, message = "port should not be more than 65535")
|
@Max(value = 65535, message = "端口号不能大于65535")
|
||||||
@Min(value = 1, message = "port should not be less than 1")
|
@Min(value = 1, message = "端口号不能小于1")
|
||||||
@Schema(description = "目的端口", example = "8080")
|
@Schema(description = "目的端口", example = "8080")
|
||||||
private Integer staticRuleDport;
|
private Integer staticRuleDport;
|
||||||
@JsonProperty("static_rule_mdport")
|
@JsonProperty("static_rule_mdport")
|
||||||
@ExcelProperty("目的端口掩码")
|
@ExcelProperty("目的端口掩码")
|
||||||
@Max(value = 65535, message = "port should not be more than 65535")
|
@Max(value = 65535, message = "端口号不能大于65535")
|
||||||
@Min(value = 1, message = "port should not be less than 1")
|
@Min(value = 1, message = "端口号不能小于1")
|
||||||
@Schema(description = "目的端口掩码", example = "65535")
|
@Schema(description = "目的端口掩码", example = "65535")
|
||||||
private Integer staticRuleMdport;
|
private Integer staticRuleMdport;
|
||||||
@JsonProperty("static_rule_protocol")
|
@JsonProperty("static_rule_protocol")
|
||||||
|
|||||||
@@ -33,15 +33,15 @@ public class WhiteListObject {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty("whiteobj_ip_address")
|
@JsonProperty("whiteobj_ip_address")
|
||||||
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "Invalid IPv4 Address")
|
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "错误 IPv4 地址")
|
||||||
@ExcelProperty("IP地址")
|
@ExcelProperty("IP地址")
|
||||||
@Schema(description = "白名单对象IPv4地址", example = "1.1.1.1", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "白名单对象IPv4地址", example = "1.1.1.1", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private String whiteListIP;
|
private String whiteListIP;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@JsonProperty("whiteobj_port")
|
@JsonProperty("whiteobj_port")
|
||||||
@Max(value = 65535, message = "port should not be more than 65535")
|
@Max(value = 65535, message = "端口不应大于 65535")
|
||||||
@Min(value = 1, message = "port should not be less than 1")
|
@Min(value = 1, message = "端口不应小于 1")
|
||||||
@ExcelProperty("端口")
|
@ExcelProperty("端口")
|
||||||
@Schema(description = "白名单对象端口", maximum = "65535", minimum = "1", example = "8080", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "白名单对象端口", maximum = "65535", minimum = "1", example = "8080", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
private int whiteListPort;
|
private int whiteListPort;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.realtime.protection.configuration.utils.enums.StateEnum;
|
|||||||
import com.realtime.protection.configuration.utils.enums.TaskTypeEnum;
|
import com.realtime.protection.configuration.utils.enums.TaskTypeEnum;
|
||||||
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;
|
||||||
|
import com.realtime.protection.server.command.CommandMapper;
|
||||||
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleMapper;
|
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleMapper;
|
||||||
import com.realtime.protection.server.rule.staticrule.StaticRuleMapper;
|
import com.realtime.protection.server.rule.staticrule.StaticRuleMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -40,13 +41,15 @@ public class TaskService {
|
|||||||
private static final int BATCH_SIZE = 100;
|
private static final int BATCH_SIZE = 100;
|
||||||
private final DynamicRuleMapper dynamicRuleMapper;
|
private final DynamicRuleMapper dynamicRuleMapper;
|
||||||
private final Counter counter;
|
private final Counter counter;
|
||||||
|
private final CommandMapper commandMapper;
|
||||||
|
|
||||||
public TaskService(TaskMapper taskMapper, StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper, DynamicRuleMapper dynamicRuleMapper, Counter counter) {
|
public TaskService(TaskMapper taskMapper, StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper, DynamicRuleMapper dynamicRuleMapper, Counter counter, CommandMapper commandMapper) {
|
||||||
this.taskMapper = taskMapper;
|
this.taskMapper = taskMapper;
|
||||||
this.staticRuleMapper = staticRuleMapper;
|
this.staticRuleMapper = staticRuleMapper;
|
||||||
this.sqlSessionWrapper = sqlSessionWrapper;
|
this.sqlSessionWrapper = sqlSessionWrapper;
|
||||||
this.dynamicRuleMapper = dynamicRuleMapper;
|
this.dynamicRuleMapper = dynamicRuleMapper;
|
||||||
this.counter = counter;
|
this.counter = counter;
|
||||||
|
this.commandMapper = commandMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -350,6 +353,9 @@ public class TaskService {
|
|||||||
updateDynamicRuleAuditStatusInTask(taskId, AuditStatusEnum.AUDITED);
|
updateDynamicRuleAuditStatusInTask(taskId, AuditStatusEnum.AUDITED);
|
||||||
taskMapper.clearTaskConnectedStaticRule(task.getTaskId());
|
taskMapper.clearTaskConnectedStaticRule(task.getTaskId());
|
||||||
taskMapper.clearTaskConnectedDynamicRule(task.getTaskId());
|
taskMapper.clearTaskConnectedDynamicRule(task.getTaskId());
|
||||||
|
|
||||||
|
commandMapper.removeCommandsByTaskId(taskId);
|
||||||
|
|
||||||
return taskMapper.deleteTask(taskId);
|
return taskMapper.deleteTask(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,6 +297,8 @@
|
|||||||
<result column="dynamic_rule_used_task_id" property="dynamicRuleUsedTaskId"/>
|
<result column="dynamic_rule_used_task_id" property="dynamicRuleUsedTaskId"/>
|
||||||
<result column="used_task_name" property="usedTaskName"/>
|
<result column="used_task_name" property="usedTaskName"/>
|
||||||
|
|
||||||
|
<result column="effective_time" property="effeciveTime"/>
|
||||||
|
<result column="expire_time" property="expireTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryDynamicRuleById" resultMap="dynamicRuleMap">
|
<select id="queryDynamicRuleById" resultMap="dynamicRuleMap">
|
||||||
|
|||||||
@@ -251,6 +251,9 @@
|
|||||||
<result column="is_protect_object_dst" property="isProtectObjectDst"/>
|
<result column="is_protect_object_dst" property="isProtectObjectDst"/>
|
||||||
<result column="is_protect_object_src" property="isProtectObjectSrc"/>
|
<result column="is_protect_object_src" property="isProtectObjectSrc"/>
|
||||||
|
|
||||||
|
<result column="effective_time" property="effeciveTime"/>
|
||||||
|
<result column="expire_time" property="expireTime"/>
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryTemplates" resultMap="templateMap">
|
<select id="queryTemplates" resultMap="templateMap">
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
select
|
select
|
||||||
white_list_id,
|
white_list_id,
|
||||||
white_list_name,
|
white_list_name,
|
||||||
effective_time,expire_time,
|
NOW(),null,
|
||||||
white_list_system_name,
|
white_list_system_name,
|
||||||
white_list_ip,
|
white_list_ip,
|
||||||
white_list_url,
|
white_list_url,
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
insert into t_white_list_status_log(
|
insert into t_white_list_status_log(
|
||||||
white_list_id,
|
white_list_id,
|
||||||
white_list_name,
|
white_list_name,
|
||||||
effective_time,expire_time,
|
effective_time,expire_time,
|
||||||
white_list_system_name,
|
white_list_system_name,
|
||||||
white_list_ip,
|
white_list_ip,
|
||||||
white_list_url,
|
white_list_url,
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
select
|
select
|
||||||
white_list_id,
|
white_list_id,
|
||||||
white_list_name,
|
white_list_name,
|
||||||
effective_time,expire_time,
|
NOW(),null,
|
||||||
white_list_system_name,
|
white_list_system_name,
|
||||||
white_list_ip,
|
white_list_ip,
|
||||||
white_list_url,
|
white_list_url,
|
||||||
@@ -155,6 +155,8 @@
|
|||||||
<result column="audit_user_id" property="auditUserId"/>
|
<result column="audit_user_id" property="auditUserId"/>
|
||||||
<result column="audit_user_depart" property="auditUserDepart"/>
|
<result column="audit_user_depart" property="auditUserDepart"/>
|
||||||
|
|
||||||
|
<result column="effective_time" property="effeciveTime"/>
|
||||||
|
<result column="expire_time" property="expireTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="queryWhiteListObject" resultMap="whiteListMap">
|
<select id="queryWhiteListObject" resultMap="whiteListMap">
|
||||||
@@ -334,7 +336,11 @@
|
|||||||
(INET_ATON(#{command.sourceIP}) & INET_ATON(#{command.maskSourceIP}))
|
(INET_ATON(#{command.sourceIP}) & INET_ATON(#{command.maskSourceIP}))
|
||||||
<if test="command.sourcePort != null">
|
<if test="command.sourcePort != null">
|
||||||
and white_list_port = CAST(#{command.sourcePort} AS UNSIGNED)
|
and white_list_port = CAST(#{command.sourcePort} AS UNSIGNED)
|
||||||
</if>)
|
</if>
|
||||||
|
<if test="command.protocol != null">
|
||||||
|
and white_list_protocol = #{command.protocol}
|
||||||
|
</if>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="command.destinationIP != null and command.maskDestinationIP == null">
|
<if test="command.destinationIP != null and command.maskDestinationIP == null">
|
||||||
or (white_list_ip = INET_ATON(#{command.destinationIP})
|
or (white_list_ip = INET_ATON(#{command.destinationIP})
|
||||||
@@ -416,33 +422,52 @@
|
|||||||
from t_white_list
|
from t_white_list
|
||||||
<where>
|
<where>
|
||||||
<foreach collection="staticRuleObjects" item="staticRule" open="(" separator=" or " close=")">
|
<foreach collection="staticRuleObjects" item="staticRule" open="(" separator=" or " close=")">
|
||||||
|
()
|
||||||
<if test="staticRule.staticRuleSip != null and staticRule.staticRuleMsip == null">
|
<if test="staticRule.staticRuleSip != null and staticRule.staticRuleMsip == null">
|
||||||
(white_list_ip = INET_ATON(#{staticRule.staticRuleSip})
|
(white_list_ip = INET_ATON(#{staticRule.staticRuleSip})
|
||||||
<if test="staticRule.staticRuleSport != null">
|
<if test="staticRule.staticRuleSport != null">
|
||||||
and white_list_port = #{staticRule.staticRuleSport}
|
and white_list_port = #{staticRule.staticRuleSport}
|
||||||
</if>)
|
</if>
|
||||||
|
<if test="staticRule.staticRuleProtocol != null">
|
||||||
|
and white_list_protocol = #{staticRule.staticRuleProtocol}
|
||||||
|
</if>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="staticRule.staticRuleSip != null and staticRule.staticRuleMsip != null">
|
<if test="staticRule.staticRuleSip != null and staticRule.staticRuleMsip != null">
|
||||||
(( white_list_ip & INET_ATON(#{staticRule.staticRuleSip})) =
|
(( white_list_ip & INET_ATON(#{staticRule.staticRuleSip})) =
|
||||||
(INET_ATON(#{staticRule.staticRuleSip}) & INET_ATON(#{staticRule.staticRuleMsip}))
|
(INET_ATON(#{staticRule.staticRuleSip}) & INET_ATON(#{staticRule.staticRuleMsip}))
|
||||||
<if test="staticRule.staticRuleSport != null">
|
<if test="staticRule.staticRuleSport != null">
|
||||||
and white_list_port = #{staticRule.staticRuleSport}
|
and white_list_port = #{staticRule.staticRuleSport}
|
||||||
</if>)
|
</if>
|
||||||
|
<if test="staticRule.staticRuleProtocol != null">
|
||||||
|
and white_list_protocol = #{staticRule.staticRuleProtocol}
|
||||||
|
</if>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="staticRule.staticRuleDip != null and staticRule.staticRuleMdip == null">
|
<if test="staticRule.staticRuleDip != null and staticRule.staticRuleMdip == null">
|
||||||
or (white_list_ip = INET_ATON(#{staticRule.staticRuleDip})
|
or (
|
||||||
|
(white_list_ip = INET_ATON(#{staticRule.staticRuleDip})
|
||||||
<if test="staticRule.staticRuleDport != null">
|
<if test="staticRule.staticRuleDport != null">
|
||||||
and white_list_port = #{staticRule.staticRuleDport}
|
and white_list_port = #{staticRule.staticRuleDport}
|
||||||
</if>)
|
</if>
|
||||||
|
<if test="staticRule.staticRuleProtocol != null">
|
||||||
|
and white_list_protocol = #{staticRule.staticRuleProtocol}
|
||||||
|
</if>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="staticRule.staticRuleDip != null and staticRule.staticRuleMdip != null">
|
<if test="staticRule.staticRuleDip != null and staticRule.staticRuleMdip != null">
|
||||||
or ((white_list_ip & INET_ATON(#{staticRule.staticRuleDip})) =
|
or (
|
||||||
|
(white_list_ip & INET_ATON(#{staticRule.staticRuleDip})) =
|
||||||
(INET_ATON(#{staticRule.staticRuleDip}) & INET_ATON(#{staticRule.staticRuleMdip}))
|
(INET_ATON(#{staticRule.staticRuleDip}) & INET_ATON(#{staticRule.staticRuleMdip}))
|
||||||
<if test="staticRule.staticRuleDport != null">
|
<if test="staticRule.staticRuleDport != null">
|
||||||
and white_list_port = #{staticRule.staticRuleDport}
|
and white_list_port = #{staticRule.staticRuleDport}
|
||||||
</if>)
|
</if>
|
||||||
|
<if test="staticRule.staticRuleProtocol != null">
|
||||||
|
and white_list_protocol = #{staticRule.staticRuleProtocol}
|
||||||
|
</if>
|
||||||
|
)
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</foreach>
|
</foreach>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Reference in New Issue
Block a user