1、错误信息改为中文
2、任务审核bug 3、指令查询不判断指令是否被删除 4、bugfix
This commit is contained in:
@@ -34,7 +34,7 @@ public class AlertMessage {
|
|||||||
private String modifyTime;
|
private String modifyTime;
|
||||||
@JsonProperty("alert_message_uuid")
|
@JsonProperty("alert_message_uuid")
|
||||||
private String alertMessageUUID;
|
private String alertMessageUUID;
|
||||||
|
//1代表防护对象命中告警信息里的是目的ip,0代表防护对象命中告警信息里的是源ip
|
||||||
@JsonProperty("protect_object_is_src_dst")
|
@JsonProperty("protect_object_is_src_dst")
|
||||||
private int protectIsSrcOrDst;
|
private int protectIsSrcOrDst;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class StaticRuleObject {
|
|||||||
private String staticRuleURL;
|
private String staticRuleURL;
|
||||||
|
|
||||||
@JsonProperty("static_rule_priority")
|
@JsonProperty("static_rule_priority")
|
||||||
@ExcelProperty("优先级")
|
@ExcelIgnore
|
||||||
@Max(value = 3)
|
@Max(value = 3)
|
||||||
@Min(value = 1)
|
@Min(value = 1)
|
||||||
@Schema(description = "优先级,1代表高2代表中3代表低", example = "1")
|
@Schema(description = "优先级,1代表高2代表中3代表低", example = "1")
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ public class DynamicTaskInfo {
|
|||||||
|
|
||||||
public void parseSql() {
|
public void parseSql() {
|
||||||
String bwSql = this.bwSql;
|
String bwSql = this.bwSql;
|
||||||
|
if (bwSql == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//解析SQL语句
|
//解析SQL语句
|
||||||
SQLStatementParser parser = new MySqlStatementParser(bwSql);
|
SQLStatementParser parser = new MySqlStatementParser(bwSql);
|
||||||
// 使用Parser解析生成AST,这里SQLStatement就是AST
|
// 使用Parser解析生成AST,这里SQLStatement就是AST
|
||||||
|
|||||||
@@ -112,10 +112,10 @@ public class TemplateService {
|
|||||||
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus) {
|
public Map<String, Object> updateAuditStatus(Integer id, Integer auditStatus) {
|
||||||
Integer originalAuditStatus = templateMapper.queryAuditStatusById(id);
|
Integer originalAuditStatus = templateMapper.queryAuditStatusById(id);
|
||||||
if (originalAuditStatus == null) {
|
if (originalAuditStatus == null) {
|
||||||
throw new IllegalArgumentException("cannot find audit status of static rule " + id + ", maybe static rule doesn't exist?");
|
throw new IllegalArgumentException("不能找到静态规则:" + id + ", 可能静态规则不存在?");
|
||||||
}
|
}
|
||||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||||
throw new IllegalArgumentException("invalid audit status");
|
throw new IllegalArgumentException("审核状态修改不合逻辑");
|
||||||
}
|
}
|
||||||
Boolean success = templateMapper.updateAuditStatusById(id, auditStatus);
|
Boolean success = templateMapper.updateAuditStatusById(id, auditStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -88,17 +88,19 @@ public class TaskService {
|
|||||||
});
|
});
|
||||||
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds());
|
taskMapper.newTaskDynamicRuleConcat(task.getTaskId(), task.getDynamicRuleIds());
|
||||||
}
|
}
|
||||||
if (task.getTaskType() != TaskTypeEnum.STATIC.getTaskType()){
|
if (task.getTaskType() != TaskTypeEnum.STATIC.getTaskType()) {
|
||||||
|
if (task.getProtectObjectIds() != null && !task.getProtectObjectIds().isEmpty()) {
|
||||||
//校验防护对象是否存在
|
//校验防护对象是否存在
|
||||||
boolean ProtectObjIdValid = task.getProtectObjectIds().stream()
|
boolean ProtectObjIdValid = task.getProtectObjectIds().stream()
|
||||||
.allMatch(dynamicRuleMapper::queryProtectObjectById);
|
.allMatch(dynamicRuleMapper::queryProtectObjectById);
|
||||||
if (!ProtectObjIdValid && !task.getProtectObjectIds().isEmpty()){
|
if (!ProtectObjIdValid) {
|
||||||
throw new IllegalArgumentException("部分防护对象不存在");
|
throw new IllegalArgumentException("部分防护对象不存在");
|
||||||
}
|
}
|
||||||
//任务和防护对象多对多关联建立
|
//任务和防护对象多对多关联建立
|
||||||
taskMapper.newTaskProtectObjectConcat(task.getTaskId(), task.getProtectObjectIds());
|
taskMapper.newTaskProtectObjectConcat(task.getTaskId(), task.getProtectObjectIds());
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return task.getTaskId();
|
return task.getTaskId();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public class WhiteListService {
|
|||||||
StaticRuleObject staticRuleObject = staticRuleMapper.queryStaticRuleById(ruleId);
|
StaticRuleObject staticRuleObject = staticRuleMapper.queryStaticRuleById(ruleId);
|
||||||
|
|
||||||
if (staticRuleObject == null) {
|
if (staticRuleObject == null) {
|
||||||
throw new IllegalArgumentException("invalid rule id");
|
throw new IllegalArgumentException("无效的静态规则");
|
||||||
}
|
}
|
||||||
// 命中的whitelist列表:每一列包含ip port url
|
// 命中的whitelist列表:每一列包含ip port url
|
||||||
return whiteListMapper.existWhiteListObject(staticRuleObject);
|
return whiteListMapper.existWhiteListObject(staticRuleObject);
|
||||||
@@ -192,11 +192,11 @@ public class WhiteListService {
|
|||||||
//查询目前curStatus
|
//查询目前curStatus
|
||||||
Integer originalAuditStatus = whiteListMapper.queryWhiteListObjectAuditStuatusById(id);
|
Integer originalAuditStatus = whiteListMapper.queryWhiteListObjectAuditStuatusById(id);
|
||||||
if (originalAuditStatus == null){
|
if (originalAuditStatus == null){
|
||||||
throw new IllegalArgumentException("cannot find audit status of whitelist " + id + ", maybe whitelist doesn't exist?");
|
throw new IllegalArgumentException("不能找到白名单 " + id + ", 可能该白名单不存在");
|
||||||
}
|
}
|
||||||
//判断是否可以修改
|
//判断是否可以修改
|
||||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||||
throw new IllegalArgumentException("invalid audit status");
|
throw new IllegalArgumentException("审核状态修改违规");
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean success = whiteListMapper.updateWhiteListObjectAuditStatus(id, auditStatus);
|
Boolean success = whiteListMapper.updateWhiteListObjectAuditStatus(id, auditStatus);
|
||||||
|
|||||||
@@ -61,6 +61,8 @@
|
|||||||
<result column="LAST_SEND_TIME" property="latestSendTime"/>
|
<result column="LAST_SEND_TIME" property="latestSendTime"/>
|
||||||
<result column="IS_VALID" property="isValid"/>
|
<result column="IS_VALID" property="isValid"/>
|
||||||
<result column="IS_JUDGED" property="isJudged"/>
|
<result column="IS_JUDGED" property="isJudged"/>
|
||||||
|
<!-- <result column="IS_DELETED" property=""/>-->
|
||||||
|
|
||||||
|
|
||||||
<association property="fiveTupleWithMask">
|
<association property="fiveTupleWithMask">
|
||||||
<result column="SRC_IP" property="sourceIP"/>
|
<result column="SRC_IP" property="sourceIP"/>
|
||||||
@@ -107,7 +109,7 @@
|
|||||||
FROM t_command
|
FROM t_command
|
||||||
<where>
|
<where>
|
||||||
AND TASK_ID = #{task_id}
|
AND TASK_ID = #{task_id}
|
||||||
AND IS_DELETED = FALSE
|
-- AND IS_DELETED = FALSE
|
||||||
<if test="src_ip != null">AND SRC_IP = #{src_ip}</if>
|
<if test="src_ip != null">AND SRC_IP = #{src_ip}</if>
|
||||||
<if test="dst_ip != null">AND DST_IP = #{dst_ip}</if>
|
<if test="dst_ip != null">AND DST_IP = #{dst_ip}</if>
|
||||||
<if test="src_port != null">AND SRC_PORT = #{src_port}</if>
|
<if test="src_port != null">AND SRC_PORT = #{src_port}</if>
|
||||||
|
|||||||
@@ -257,12 +257,11 @@
|
|||||||
</update>
|
</update>
|
||||||
<update id="changeTaskAuditStatusWithAudior">
|
<update id="changeTaskAuditStatusWithAudior">
|
||||||
UPDATE t_task
|
UPDATE t_task
|
||||||
SET task_status = #{audit_status},
|
SET task_audit_status = #{audit_status},
|
||||||
task_modify_time = NOW(),
|
task_modify_time = NOW(),
|
||||||
task_audit_username = #{auditUserName},
|
task_audit_username = #{auditUserName},
|
||||||
task_audit_userid = #{auditUserId},
|
task_audit_userid = #{auditUserId},
|
||||||
task_audit_depart = #{auditUserDepart}
|
task_audit_depart = #{auditUserDepart}
|
||||||
|
|
||||||
WHERE task_id = #{task_id}
|
WHERE task_id = #{task_id}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateAuditStatusWithAuditorByIdBatch">
|
<update id="updateAuditStatusWithAuditorByIdBatch">
|
||||||
|
|||||||
@@ -210,9 +210,11 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
|||||||
// map.put(43830, 1);
|
// map.put(43830, 1);
|
||||||
// map.put(43831, 1);
|
// map.put(43831, 1);
|
||||||
// map.put(43832, 1);
|
// map.put(43832, 1);
|
||||||
|
|
||||||
|
|
||||||
// System.out.println(taskService.updateAuditStatusBatch(map));
|
// System.out.println(taskService.updateAuditStatusBatch(map));
|
||||||
|
|
||||||
|
System.out.println(taskService.changeTaskAuditStatus(44047L, 2, null, null, null));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
void testGetDynamicTaskInfos(){
|
void testGetDynamicTaskInfos(){
|
||||||
@@ -308,7 +310,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
|||||||
object.setDynamicRulePriority(1);
|
object.setDynamicRulePriority(1);
|
||||||
object.setDynamicRuleSourceSystem("bw");
|
object.setDynamicRuleSourceSystem("bw");
|
||||||
// object.setDynamicRuleSourceSystem("bw");
|
// object.setDynamicRuleSourceSystem("bw");
|
||||||
object.setBwSql("select c_src_ipv4,c_src_port,c_dest_ipv4,c_dest_port from topic_xxxxxx where c_event_id in (11113333311,222222222222) and c_netnum = 111111111 and c_flowid=22222222" );
|
// object.setBwSql("select c_src_ipv4,c_src_port,c_dest_ipv4,c_dest_port from topic_xxxxxx where c_event_id in (11113333311,222222222222) and c_netnum = 111111111 and c_flowid=22222222" );
|
||||||
// object.setDynamicRuleRange("北京");
|
// object.setDynamicRuleRange("北京");
|
||||||
// object.setDynamicRuleProtectLevel(1);
|
// object.setDynamicRuleProtectLevel(1);
|
||||||
// object.setLogRuleId(1L);
|
// object.setLogRuleId(1L);
|
||||||
@@ -338,7 +340,7 @@ class TaskServiceTest extends ProtectionApplicationTests {
|
|||||||
task.setSourceSystem(templates.get(0).getSourceSystem());
|
task.setSourceSystem(templates.get(0).getSourceSystem());
|
||||||
task.setTemplateId(templates.get(0).getTemplateId());
|
task.setTemplateId(templates.get(0).getTemplateId());
|
||||||
|
|
||||||
task.setProtectObjectIds(List.of(new Integer[]{protectObject.get(0).getProtectObjectId()}));
|
// task.setProtectObjectIds(List.of(new Integer[]{protectObject.get(0).getProtectObjectId()}));
|
||||||
|
|
||||||
Long taskId = taskService.newTask(task);
|
Long taskId = taskService.newTask(task);
|
||||||
System.out.println(taskId);
|
System.out.println(taskId);
|
||||||
|
|||||||
Reference in New Issue
Block a user