1. 添加“显示ID”字段,用来给前端展示任务/规则/防护对象的自定义ID(非主键ID)

2. 新增Counter类,新增Redis相关以来
This commit is contained in:
EnderByEndera
2024-04-29 15:33:09 +08:00
parent 7086af3832
commit 4c30c719d9
22 changed files with 214 additions and 38 deletions

View File

@@ -30,7 +30,7 @@ dependencies {
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.kafka:spring-kafka'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

View File

@@ -8,14 +8,16 @@ COPY realtime_protection realtime_protection
# MYSQL_URL="10.58.72.140:3306" \
# DORIS_USERNAME="root" \
# DORIS_PASSWD="" \
# DORIS_URL="10.58.72.135:9030"
# DORIS_URL="10.58.72.135:9030" \
# REDIS_URL="10.58.72.140"
ENV MYSQL_USERNAME="root" \
MYSQL_PASSWD="aiihhbfcsy123!@#" \
MYSQL_URL="192.168.107.89:3306" \
DORIS_USERNAME="root" \
DORIS_PASSWD="" \
DORIS_URL="10.26.22.133:9030"
DORIS_URL="10.26.22.133:9030" \
REDIS_URL="192.168.107.89"
EXPOSE 8081

View File

@@ -17,6 +17,11 @@ public class ProtectObject {
@Schema(description = "防护对象ID", accessMode = Schema.AccessMode.READ_ONLY)
private Integer protectObjectId;
@JsonProperty("proobj_display_id")
@ExcelProperty("ID")
@Schema(description = "防护对象显示ID", accessMode = Schema.AccessMode.READ_ONLY)
private String protectObjectDisplayId;
@JsonProperty("proobj_name")
@NotNull(message = "proobj_name字段不能为空。")
@ExcelProperty("名称")

View File

@@ -22,6 +22,10 @@ public class DynamicRuleObject {
@Schema(description = "动态规则ID", accessMode = Schema.AccessMode.READ_ONLY)
private Integer dynamicRuleId;
@JsonProperty("dynamic_rule_display_id")
@Schema(description = "动态规则显示ID", accessMode = Schema.AccessMode.READ_ONLY)
private String dynamicRuleDisplayId;
@NotNull
@JsonProperty("dynamic_rule_name")
@Schema(description = "动态规则名称", example = "动态规则测试", requiredMode = Schema.RequiredMode.REQUIRED)
@@ -38,8 +42,6 @@ public class DynamicRuleObject {
@Schema(description = "动态规则创建用户名称", accessMode = Schema.AccessMode.READ_ONLY)
private String dynamicRuleCreateUsername;
// @JsonProperty("dynamic_rule_audit_status")
// private Integer dynamicRuleAuditStatus;
@JsonProperty("dynamic_rule_create_depart")
@Schema(description = "动态规则创建用户所属部门", accessMode = Schema.AccessMode.READ_ONLY)
private String dynamicRuleCreateDepart;
@@ -99,7 +101,6 @@ public class DynamicRuleObject {
@Schema(description = "筛选条件-日志规则id", example = "1", requiredMode = Schema.RequiredMode.REQUIRED)
private Long logRuleId;
@JsonProperty("dynamic_rule_audit_status")
@ExcelIgnore
@Schema(description = "动态规则审核状态0为未审核1为已退回2为审核通过", example = "2", accessMode = Schema.AccessMode.READ_ONLY)

View File

@@ -28,6 +28,11 @@ public class StaticRuleObject {
@Schema(description = "静态规则ID", accessMode = Schema.AccessMode.READ_ONLY)
private Integer staticRuleId;
@JsonProperty("static_rule_display_id")
@ExcelProperty("ID")
@Schema(description = "静态规则显示ID", accessMode = Schema.AccessMode.READ_ONLY)
private String staticRuleDisplayId;
@NotNull
@JsonProperty("static_rule_name")
@ExcelProperty("名称")

View File

@@ -16,6 +16,10 @@ public class Task {
@Schema(description = "任务ID", accessMode = Schema.AccessMode.READ_ONLY)
private Long taskId;
@JsonProperty("task_display_id")
@Schema(description = "任务显示ID", accessMode = Schema.AccessMode.READ_ONLY)
private String taskDisplayId;
@JsonProperty("task_name")
@NotNull(message = "task_name字段不能为空。")
@Schema(description = "任务名称", example = "静态任务")

View File

@@ -17,6 +17,10 @@ public class TaskCommandInfo {
@JsonProperty("task_id")
private Long taskId;
@Schema(description = "任务显示ID", accessMode = Schema.AccessMode.READ_ONLY)
@JsonProperty("task_display_id")
private String taskDisplayId;
@Schema(description = "规则ID", hidden = true)
@JsonProperty("rule_id")
private Long ruleId;

View File

@@ -0,0 +1,37 @@
package com.realtime.protection.configuration.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class Counter {
private final StringRedisTemplate stringRedisTemplate;
public Counter(StringRedisTemplate stringRedisTemplate) {
this.stringRedisTemplate = stringRedisTemplate;
}
public Long generateId(String typeName) {
String key = String.format("counter::%s", typeName.toLowerCase());
BoundValueOperations<String, String> op = stringRedisTemplate.boundValueOps(key);
return op.increment();
}
@Scheduled(cron = "0 0 0 * * ?")
public void resetId() {
Cursor<String> cursor = stringRedisTemplate.scan(ScanOptions.scanOptions().build());
while (cursor.hasNext()) {
String key = cursor.next();
if (key.startsWith("counter::")) {
stringRedisTemplate.delete(key);
log.debug("删除计时器key: {}", key);
}
}
}
}

View File

@@ -3,12 +3,15 @@ package com.realtime.protection.server.defense.object;
import com.alibaba.excel.util.ListUtils;
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
import com.realtime.protection.configuration.response.ResponseResult;
import com.realtime.protection.configuration.utils.Counter;
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -19,13 +22,22 @@ public class ProtectObjectService {
private final ProtectObjectMapper protectObjectMapper;
private final SqlSessionWrapper sqlSessionWrapper;
private static final Integer batchSize = 100;
private final Counter counter;
public ProtectObjectService(ProtectObjectMapper protectObjectMapper, SqlSessionWrapper sqlSessionWrapper) {
public ProtectObjectService(ProtectObjectMapper protectObjectMapper, SqlSessionWrapper sqlSessionWrapper, Counter counter) {
this.protectObjectMapper = protectObjectMapper;
this.sqlSessionWrapper = sqlSessionWrapper;
this.counter = counter;
}
public Integer newProtectObject(ProtectObject protectObject) {
protectObject.setProtectObjectDisplayId(
"FHDX-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("protect_object"))
);
protectObjectMapper.newProtectObject(protectObject);
if (protectObject.getProtectObjectId() == null) {
@@ -42,6 +54,13 @@ public class ProtectObjectService {
List<ProtectObject> protectObjectBatch = ListUtils.newArrayListWithExpectedSize(batchSize);
for (ProtectObject protectObject : list) {
protectObject.setProtectObjectDisplayId(
"FHDX-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("protect_object"))
);
protectObjectBatch.add(protectObject);
if (protectObjectBatch.size() < batchSize) {
continue;

View File

@@ -3,6 +3,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.rule.dynamicrule.DynamicRuleObject;
import com.realtime.protection.configuration.utils.Counter;
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
import com.realtime.protection.configuration.utils.enums.StateEnum;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValidator;
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -19,11 +21,12 @@ import java.util.function.Function;
public class DynamicRuleService {
private final DynamicRuleMapper dynamicRuleMapper;
private final SqlSessionWrapper sqlSessionWrapper;
private final Counter counter;
public DynamicRuleService(DynamicRuleMapper dynamicRuleMapper, SqlSessionWrapper sqlSessionWrapper) {
public DynamicRuleService(DynamicRuleMapper dynamicRuleMapper, SqlSessionWrapper sqlSessionWrapper, Counter counter) {
this.sqlSessionWrapper = sqlSessionWrapper;
this.dynamicRuleMapper = dynamicRuleMapper;
this.counter = counter;
}
@Transactional
@@ -36,6 +39,13 @@ public class DynamicRuleService {
throw new IllegalArgumentException("protect object id is invalid");
}
dynamicRule.setDynamicRuleDisplayId(
"DTGZ-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("dynamic_rule"))
);
dynamicRuleMapper.newDynamicRule(dynamicRule);
Integer dynamicRuleId = dynamicRule.getDynamicRuleId();
dynamicRule.getProtectObjectIds().forEach(
@@ -55,6 +65,12 @@ public class DynamicRuleService {
List<DynamicRuleObject> DynamicRuleIdBatch = ListUtils.newArrayListWithExpectedSize(100);
for (DynamicRuleObject dynamicRule : DynamicRuleList) {
dynamicRule.setDynamicRuleCreateTime(LocalDateTime.now());
dynamicRule.setDynamicRuleDisplayId(
"DTGZ-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("dynamic_rule"))
);
DynamicRuleIdBatch.add(dynamicRule);
if (DynamicRuleIdBatch.size() < 100) {
continue;

View File

@@ -2,6 +2,7 @@ package com.realtime.protection.server.rule.staticrule;
import com.alibaba.excel.util.ListUtils;
import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject;
import com.realtime.protection.configuration.utils.Counter;
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
import com.realtime.protection.configuration.utils.enums.RuleEnum;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
@@ -14,6 +15,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -25,11 +27,12 @@ public class StaticRuleService {
private final StaticRuleMapper staticRuleMapper;
private final SqlSessionWrapper sqlSessionWrapper;
private final Counter counter;
public StaticRuleService(StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper) {
public StaticRuleService(StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper, Counter counter) {
this.staticRuleMapper = staticRuleMapper;
this.sqlSessionWrapper = sqlSessionWrapper;
this.counter = counter;
}
private static int ipToInt(String ip) {
@@ -69,6 +72,14 @@ public class StaticRuleService {
if (!RuleEnum.checkValidate(object)) {
throw new IllegalArgumentException("静态规则不符合指定的配置方法,请参考规则模板以配置静态规则");
}
object.setStaticRuleDisplayId(
"JTGZ-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("static_rule"))
);
staticRuleMapper.newStaticRuleObject(object);
return object.getStaticRuleId();
@@ -157,6 +168,12 @@ public class StaticRuleService {
List<StaticRuleObject> StaticRuleBatch = ListUtils.newArrayListWithExpectedSize(100);
for (StaticRuleObject staticRule : list) {
staticRule.setStaticRuleCreateTime(LocalDateTime.now());
staticRule.setStaticRuleDisplayId(
"JTGZ-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("static_rule"))
);
StaticRuleBatch.add(staticRule);
if (StaticRuleBatch.size() < 100) {
continue;

View File

@@ -7,6 +7,8 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -61,7 +63,8 @@ public interface TaskMapper {
Integer queryTaskTotalNum(@Param("task_status") Integer taskStatus, @Param("task_type") Integer task_type,
@Param("task_name") String taskName, @Param("task_creator") String taskCreator,
@Param("audit_status") Integer auditStatus);
@Param("audit_status") Integer auditStatus,
@Param("task_create_time") LocalDateTime taskCreateTime);
void updateAuditStatusByIdBatch(@Param("idWithAuditStatusBatch") Map<Integer, Integer> idWithAuditStatusBatch);

View File

@@ -7,6 +7,7 @@ import com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleOb
import com.realtime.protection.configuration.entity.task.DynamicTaskInfo;
import com.realtime.protection.configuration.entity.task.Task;
import com.realtime.protection.configuration.entity.task.TaskCommandInfo;
import com.realtime.protection.configuration.utils.Counter;
import com.realtime.protection.configuration.utils.SqlSessionWrapper;
import com.realtime.protection.configuration.utils.enums.StateEnum;
import com.realtime.protection.configuration.utils.enums.audit.AuditStatusEnum;
@@ -14,9 +15,14 @@ import com.realtime.protection.configuration.utils.enums.audit.AuditStatusValida
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleMapper;
import com.realtime.protection.server.rule.staticrule.StaticRuleMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Isolation;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -33,20 +39,29 @@ public class TaskService {
private final SqlSessionWrapper sqlSessionWrapper;
private static final int BATCH_SIZE = 100;
private final DynamicRuleMapper dynamicRuleMapper;
private final Counter counter;
public TaskService(TaskMapper taskMapper, StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper, DynamicRuleMapper dynamicRuleMapper) {
public TaskService(TaskMapper taskMapper, StaticRuleMapper staticRuleMapper, SqlSessionWrapper sqlSessionWrapper, DynamicRuleMapper dynamicRuleMapper, Counter counter) {
this.taskMapper = taskMapper;
this.staticRuleMapper = staticRuleMapper;
this.sqlSessionWrapper = sqlSessionWrapper;
this.dynamicRuleMapper = dynamicRuleMapper;
this.counter = counter;
}
@Transactional
public Long newTask(Task task) {
// todo: 目前获取方式还不确定,以后再确定
task.setTaskCreateUserId(1);
task.setTaskCreateUsername("xxx");
task.setTaskCreateDepart("xxx");
task.setTaskDisplayId(
"RW-"
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
+ "-"
+ String.format("%06d", counter.generateId("task")));
taskMapper.newTask(task);
if (task.getStaticRuleIds() != null && !task.getStaticRuleIds().isEmpty()) {
@@ -320,7 +335,7 @@ public class TaskService {
}
public Integer queryTaskTotalNum(Integer taskStatus, Integer taskType, String taskName, String taskCreator, Integer auditStatus) {
return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus);
return taskMapper.queryTaskTotalNum(taskStatus, taskType, taskName, taskCreator, auditStatus, null);
}
public Object updateAuditStatusBatch(Map<Integer, Integer> idsWithAuditStatusMap) {

View File

@@ -132,7 +132,7 @@ public class StateHandler {
SimpleResponse response = mono.block(Duration.ofSeconds(5));
if (response == null || response.getSuccess() == null) {
if (response == null || response.getCode() != 200 || response.getSuccess() == null) {
return false;
}

View File

@@ -33,6 +33,18 @@ spring:
grace-destroy: true
jackson:
default-property-inclusion: non_null
data:
redis:
host: 192.168.107.89
port: 6379
database: 1
jedis:
pool:
enabled: true
max-active: 10
max-idle: 5
min-idle: 1
connect-timeout: 1000
mybatis:

View File

@@ -34,6 +34,18 @@ spring:
grace-destroy: true
jackson:
default-property-inclusion: non_null
data:
redis:
host: ${REDIS_URL}
port: 6379
database: 1
jedis:
pool:
enabled: true
max-active: 10
max-idle: 5
min-idle: 1
connect-timeout: 1000
mybatis:
mapper-locations: classpath:mappers/*

View File

@@ -33,6 +33,18 @@ spring:
grace-destroy: true
jackson:
default-property-inclusion: non_null
data:
redis:
host: 192.168.107.89
port: 6379
database: 1
jedis:
pool:
enabled: true
max-active: 10
max-idle: 5
min-idle: 1
connect-timeout: 1000
mybatis:
mapper-locations: classpath:mappers/*

View File

@@ -13,14 +13,14 @@
create_time, modify_time, dynamic_rule_create_username,
dynamic_rule_create_depart, template_id, dynamic_rule_protect_level,
dynamic_rule_priority, dynamic_rule_range,
dynamic_rule_frequency, dynamic_rule_create_user_id, log_rule_id)
dynamic_rule_frequency, dynamic_rule_create_user_id, log_rule_id, dynamic_rule_display_id)
values (#{object.dynamicRuleName},
NOW(), #{object.dynamicRuleModifyTime},
#{object.dynamicRuleCreateUsername}, #{object.dynamicRuleCreateDepart},
#{object.templateId}, #{object.dynamicRuleProtectLevel},
#{object.dynamicRulePriority}, #{object.dynamicRuleRange},
#{object.dynamicRuleFrequency},
#{object.dynamicRuleCreateUserId},#{object.logRuleId})
#{object.dynamicRuleCreateUserId}, #{object.logRuleId}, #{object.dynamicRuleDisplayId})
</insert>
@@ -35,7 +35,7 @@
create_time, modify_time, dynamic_rule_create_username,
dynamic_rule_create_depart, template_id, dynamic_rule_protect_level,
dynamic_rule_priority, dynamic_rule_range,
dynamic_rule_frequency, dynamic_rule_create_user_id,log_rule_id
dynamic_rule_frequency, dynamic_rule_create_user_id, log_rule_id, dynamic_rule_display_id
)
values
<foreach collection="dynamicRuleObjects" item="object" separator=",">
@@ -45,7 +45,7 @@
#{object.templateId}, #{object.dynamicRuleProtectLevel},
#{object.dynamicRulePriority}, #{object.dynamicRuleRange},
#{object.dynamicRuleFrequency},
#{object.dynamicRuleCreateUserId},#{object.logRuleId})
#{object.dynamicRuleCreateUserId}, #{object.logRuleId}, #{object.dynamicRuleDisplayId})
</foreach>
</insert>
<insert id="newDynamicRulProtectObjectsConcat">

View File

@@ -10,12 +10,12 @@
protect_object_ip, protect_object_port, protect_object_url,
protect_object_protocol,
protect_object_create_username, protect_object_create_depart,
protect_object_create_user_id)
protect_object_create_user_id, protect_object_display_id)
VALUE (#{proobj.protectObjectId}, #{proobj.protectObjectName}, #{proobj.protectObjectSystemName},
INET_ATON(#{proobj.protectObjectIPAddress}), #{proobj.protectObjectPort}, #{proobj.protectObjectURL},
#{proobj.protectObjectProtocol},
#{proobj.protectObjectCreateUsername}, #{proobj.protectObjectCreateDepart},
#{proobj.protectObjectCreateUserId})
#{proobj.protectObjectCreateUserId}, #{proobj.protectObjectDisplayId})
</insert>
<insert id="newProtectObjects" parameterType="List">
@@ -23,14 +23,14 @@
protect_object_ip, protect_object_port, protect_object_url,
protect_object_protocol,
protect_object_create_username, protect_object_create_depart,
protect_object_create_user_id)
protect_object_create_user_id, protect_object_display_id)
VALUES
<foreach collection="proobjs" item="proobj" separator=",">
(#{proobj.protectObjectId}, #{proobj.protectObjectName}, #{proobj.protectObjectSystemName},
INET_ATON(#{proobj.protectObjectIPAddress}), #{proobj.protectObjectPort}, #{proobj.protectObjectURL},
#{proobj.protectObjectProtocol},
#{proobj.protectObjectCreateUsername}, #{proobj.protectObjectCreateDepart},
#{proobj.protectObjectCreateUserId})
#{proobj.protectObjectCreateUserId}, #{proobj.protectObjectDisplayId})
</foreach>
</insert>

View File

@@ -6,7 +6,6 @@
<insert id="newStaticRuleObject" useGeneratedKeys="true" keyProperty="staticRuleId"
parameterType="com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject">
insert into t_static_rule(static_rule_name, static_rule_create_time,
static_rule_create_username, static_rule_create_depart,
static_rule_create_user_id, static_rule_sip, static_rule_msip,
@@ -14,7 +13,8 @@
static_rule_dip, static_rule_mdip, static_rule_dport, static_rule_mdport,
static_rule_protocol, static_rule_mprotocol, static_rule_dns,
static_rule_url, static_rule_priority, static_rule_range,
static_rule_frequency, static_rule_audit_status)
static_rule_frequency, static_rule_audit_status,
static_rule_display_id)
values (#{object.staticRuleName}, #{object.staticRuleCreateTime}, #{object.staticRuleCreateUsername},
#{object.staticRuleCreateDepart}, #{object.staticRuleCreateUserId}, INET_ATON(#{object.staticRuleSip}),
INET_ATON(#{object.staticRuleMsip}), #{object.staticRuleSport}, #{object.staticRuleMsport},
@@ -22,7 +22,8 @@
#{object.staticRuleMdport}, #{object.staticRuleProtocol}, #{object.staticRuleMprotocol},
#{object.staticRuleDns}, #{object.staticRuleURL}, #{object.staticRulePriority},
#{object.staticRuleRange}, #{object.staticRuleFrequency},
#{object.auditStatus})
#{object.auditStatus},
#{object.staticRuleDisplayId})
</insert>
<insert id="newStaticRules">
insert into t_static_rule(static_rule_name, static_rule_create_time,
@@ -32,7 +33,8 @@
static_rule_dip, static_rule_mdip, static_rule_dport, static_rule_mdport,
static_rule_protocol, static_rule_mprotocol, static_rule_dns,
static_rule_url, static_rule_priority, static_rule_range,
static_rule_frequency, static_rule_audit_status)
static_rule_frequency, static_rule_audit_status,
static_rule_display_id)
values
<foreach collection="staticRuleBatch" item="object" separator=",">
(#{object.staticRuleName}, NOW(), #{object.staticRuleCreateUsername},
@@ -41,8 +43,8 @@
INET_ATON(#{object.staticRuleDip}), INET_ATON(#{object.staticRuleMdip}), #{object.staticRuleDport},
#{object.staticRuleMdport}, #{object.staticRuleProtocol}, #{object.staticRuleMprotocol},
#{object.staticRuleDns}, #{object.staticRuleURL}, #{object.staticRulePriority},
#{object.staticRuleRange}, #{object.staticRuleFrequency},
0)
#{object.staticRuleRange}, #{object.staticRuleFrequency}, 0,
#{object.staticRuleDisplayId})
</foreach>
</insert>

View File

@@ -8,11 +8,14 @@
INSERT INTO t_task(task_name, task_start_time, task_end_time,
task_act, task_type,
task_create_time, task_modify_time,
task_create_userid, task_create_username, task_create_depart)
VALUE (#{task.taskName}, #{task.taskStartTime}, #{task.taskEndTime},
#{task.taskAct}, #{task.taskType},
NOW(), NOW(),
#{task.taskCreateUserId}, #{task.taskCreateUsername}, #{task.taskCreateDepart})
task_create_userid, task_create_username, task_create_depart,
task_display_id)
VALUE (#{task.taskName}, #{task.taskStartTime}, #{task.taskEndTime},
#{task.taskAct}, #{task.taskType},
NOW(), NOW(),
#{task.taskCreateUserId}, #{task.taskCreateUsername}, #{task.taskCreateDepart},
#{task.taskDisplayId}
)
</insert>
<update id="newTaskStaticRuleConcat">
@@ -226,12 +229,13 @@
<insert id="newTaskUsingCommandInfo" useGeneratedKeys="true" keyProperty="taskId"
parameterType="com.realtime.protection.configuration.entity.task.TaskCommandInfo">
INSERT INTO t_task(task_name, task_start_time, task_end_time, task_create_time, task_modify_time, task_type,
task_act, task_create_username, task_create_depart, task_create_userid)
task_act, task_create_username, task_create_depart, task_create_userid, task_display_id)
VALUE
(
#{info.taskName}, #{info.startTime}, #{info.endTime}, NOW(), NOW(), #{info.taskType},
#{info.taskAct}, #{info.taskCreateUsername}, #{info.taskCreateDepart}, #{info.taskCreateUserId}
);
#{info.taskName}, #{info.startTime}, #{info.endTime}, NOW(), NOW(), #{info.taskType},
#{info.taskAct}, #{info.taskCreateUsername}, #{info.taskCreateDepart}, #{info.taskCreateUserId},
#{info.taskDisplayId}
);
</insert>
<select id="getStaticCommandInfos" resultMap="staticCommandMap">
@@ -325,6 +329,9 @@
<if test="audit_status != null">
AND task_audit_status = #{audit_status}
</if>
<if test="task_create_time != null">
AND DATE(#{task_create_time}) = CURRENT_DATE
</if>
</where>
</select>

View File

@@ -39,4 +39,7 @@ server {
proxy_pass http://server_list/api/v1/;
}
# 允许iframe跨域嵌套
add_header X-Frame-Options ALLOW-FROM ${iframe_url};
}