1、修复bug
This commit is contained in:
@@ -60,7 +60,7 @@ public class AuditAdvice implements ResponseBodyAdvice<ResponseResult> {
|
|||||||
public ResponseResult beforeBodyWrite(ResponseResult body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
public ResponseResult beforeBodyWrite(ResponseResult body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||||
|
|
||||||
AuditData auditData = getAuditData(body, request);
|
AuditData auditData = getAuditData(body, request);
|
||||||
// System.out.println("auditData-----------:"+auditData);
|
log.info("auditData-----------:"+auditData);
|
||||||
|
|
||||||
Mono<String> mono = webClient
|
Mono<String> mono = webClient
|
||||||
.post()
|
.post()
|
||||||
@@ -68,9 +68,10 @@ public class AuditAdvice implements ResponseBodyAdvice<ResponseResult> {
|
|||||||
.bodyValue(auditData)
|
.bodyValue(auditData)
|
||||||
.exchangeToMono(res -> {
|
.exchangeToMono(res -> {
|
||||||
if (res.statusCode().equals(HttpStatus.OK)) {
|
if (res.statusCode().equals(HttpStatus.OK)) {
|
||||||
|
log.info("发送审计日志成功:{}",res.statusCode());
|
||||||
return res.bodyToMono(String.class);
|
return res.bodyToMono(String.class);
|
||||||
}
|
}
|
||||||
// log.info("发送审计日志成功:{}",res);
|
log.info("发送审计日志失败:{}",res.statusCode());
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.doOnError(WebClientRequestException.class, err ->
|
.doOnError(WebClientRequestException.class, err ->
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public interface CommandMapper {
|
|||||||
|
|
||||||
Boolean stopCommandsByTaskId(@Param("task_id") Long taskId);
|
Boolean stopCommandsByTaskId(@Param("task_id") Long taskId);
|
||||||
|
|
||||||
|
@DS("doris")
|
||||||
Boolean removeCommandsByTaskId(@Param("task_id") Long taskId);
|
Boolean removeCommandsByTaskId(@Param("task_id") Long taskId);
|
||||||
|
|
||||||
Boolean startCommandsByTaskId(@Param("task_id") Long taskId);
|
Boolean startCommandsByTaskId(@Param("task_id") Long taskId);
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ public class WhiteListService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer updateWhiteListObject(Integer id, WhiteListObject object) {
|
public Integer updateWhiteListObject(Integer id, WhiteListObject object) {
|
||||||
|
Integer auditStatus = whiteListMapper.queryWhiteListObjectAuditStuatusById(id);
|
||||||
|
if (auditStatus == null) {
|
||||||
|
throw new IllegalArgumentException("无法找到白名单 " + id + ", 可能该白名单不存在");
|
||||||
|
}
|
||||||
if (!whiteListMapper.queryWhiteListObjectAuditStuatusById(id).equals(AuditStatusEnum.AUDITED.getNum())) {
|
if (!whiteListMapper.queryWhiteListObjectAuditStuatusById(id).equals(AuditStatusEnum.AUDITED.getNum())) {
|
||||||
throw new IllegalStateException("无法修改白名单信息,因为其并未处于" + AuditStatusEnum.AUDITED + "状态");
|
throw new IllegalStateException("无法修改白名单信息,因为其并未处于" + AuditStatusEnum.AUDITED + "状态");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
#{object.auditStatus},
|
#{object.auditStatus},
|
||||||
#{object.staticRuleDisplayId},#{object.eventType},NOW())
|
#{object.staticRuleDisplayId},#{object.eventType},NOW())
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="newStaticRules" useGeneratedKeys="true" keyProperty="staticRuleId"
|
<insert id="newStaticRules" >
|
||||||
keyColumn="static_rule_id" parameterType="com.realtime.protection.configuration.entity.rule.staticrule.StaticRuleObject">
|
|
||||||
insert into t_static_rule(static_rule_name, static_rule_create_time,
|
insert into t_static_rule(static_rule_name, static_rule_create_time,
|
||||||
static_rule_create_username, static_rule_create_depart,
|
static_rule_create_username, static_rule_create_depart,
|
||||||
static_rule_create_user_id, static_rule_sip, static_rule_msip,
|
static_rule_create_user_id, static_rule_sip, static_rule_msip,
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
audit_user_name,
|
audit_user_name,
|
||||||
audit_user_id,
|
audit_user_id,
|
||||||
audit_user_depart
|
audit_user_depart
|
||||||
)
|
|
||||||
from t_strategy_template_new
|
from t_strategy_template_new
|
||||||
where strategy_template_id = #{id}
|
where strategy_template_id = #{id}
|
||||||
</insert>
|
</insert>
|
||||||
@@ -181,7 +181,7 @@
|
|||||||
modify_time = NOW(),
|
modify_time = NOW(),
|
||||||
audit_status = #{auditStatus},
|
audit_status = #{auditStatus},
|
||||||
audit_user_name = #{auditUserName},
|
audit_user_name = #{auditUserName},
|
||||||
audit_user_depart = #{auditUserDepart}
|
audit_user_depart = #{auditUserDepart},
|
||||||
audit_user_id = #{auditUserId}
|
audit_user_id = #{auditUserId}
|
||||||
WHERE strategy_template_id = #{id}
|
WHERE strategy_template_id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#{object.whiteListUrl}, #{object.whiteListProtocol},
|
#{object.whiteListUrl}, #{object.whiteListProtocol},
|
||||||
0, NOW(), #{object.whiteListDisplayId},
|
0, NOW(), #{object.whiteListDisplayId},
|
||||||
#{object.createUserName}, #{object.createUserDepartment},
|
#{object.createUserName}, #{object.createUserDepartment},
|
||||||
#{object.createUserId}
|
#{object.createUserId})
|
||||||
</foreach>
|
</foreach>
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertStatusLog">
|
<insert id="insertStatusLog">
|
||||||
@@ -284,6 +284,15 @@
|
|||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateWhiteListObjectAuditStatusWithUser">
|
||||||
|
update t_white_list
|
||||||
|
set white_list_audit_status = #{status},
|
||||||
|
audit_user_name = #{auditUserName},
|
||||||
|
audit_user_id = #{auditUserId},
|
||||||
|
audit_user_depart = #{auditUserDepart},
|
||||||
|
modify_time = NOW()
|
||||||
|
where white_list_id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="existWhiteListObject" resultType="java.lang.String">
|
<select id="existWhiteListObject" resultType="java.lang.String">
|
||||||
select CONCAT(INET_NTOA(white_list_ip)," ", CAST(white_list_port)," ", white_list_url)
|
select CONCAT(INET_NTOA(white_list_ip)," ", CAST(white_list_port)," ", white_list_url)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.realtime.protection.server.defense.templatenew;
|
package com.realtime.protection.server.defense.templatenew;
|
||||||
|
|
||||||
|
import com.realtime.protection.configuration.entity.defense.template.Template;
|
||||||
import com.realtime.protection.configuration.entity.defense.template.TemplateNew;
|
import com.realtime.protection.configuration.entity.defense.template.TemplateNew;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@@ -9,6 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import org.springframework.dao.DuplicateKeyException;
|
import org.springframework.dao.DuplicateKeyException;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@@ -68,5 +70,14 @@ public class NewTemplateServiceTest {
|
|||||||
assertTrue(templateId > 0);
|
assertTrue(templateId > 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
void testUpdateTemplateAuditStatus(){
|
||||||
|
List<TemplateNew> templates = templateService.queryTemplates(
|
||||||
|
null, null, null, null, null,null, null,1,3);
|
||||||
|
TemplateNew testTemplate = templates.get(0);
|
||||||
|
templateService.updateAuditStatus(testTemplate.getTemplateId(), 2, null,null,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ package com.realtime.protection.server.rule.dynamic;
|
|||||||
import com.realtime.protection.ProtectionApplicationTests;
|
import com.realtime.protection.ProtectionApplicationTests;
|
||||||
import com.realtime.protection.configuration.entity.defense.object.ProtectObject;
|
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.Template;
|
||||||
|
import com.realtime.protection.configuration.entity.defense.template.TemplateNew;
|
||||||
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
import com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject;
|
||||||
import com.realtime.protection.configuration.entity.task.DynamicTaskInfo;
|
import com.realtime.protection.configuration.entity.task.DynamicTaskInfo;
|
||||||
import com.realtime.protection.configuration.entity.task.Task;
|
import com.realtime.protection.configuration.entity.task.Task;
|
||||||
import com.realtime.protection.server.defense.object.ProtectObjectService;
|
import com.realtime.protection.server.defense.object.ProtectObjectService;
|
||||||
import com.realtime.protection.server.defense.template.TemplateService;
|
import com.realtime.protection.server.defense.templatenew.TemplateService;
|
||||||
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleService;
|
import com.realtime.protection.server.rule.dynamicrule.DynamicRuleService;
|
||||||
import com.realtime.protection.server.task.TaskService;
|
import com.realtime.protection.server.task.TaskService;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -71,8 +72,8 @@ public class DynamicRuleServiceTest extends ProtectionApplicationTests {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
1, 1);
|
1, 1);
|
||||||
List<Template> templates = templateService.queryTemplates(
|
List<TemplateNew> templates = templateService.queryTemplates(
|
||||||
null, null,null, null, null,1, 1);
|
null, null,null, null, null,null,null,1, 1);
|
||||||
|
|
||||||
DynamicRuleObject object = new DynamicRuleObject();
|
DynamicRuleObject object = new DynamicRuleObject();
|
||||||
object.setDynamicRuleName("UpdateDynamicRule2");
|
object.setDynamicRuleName("UpdateDynamicRule2");
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateWhiteListAuditStatus() {
|
void testUpdateWhiteListAuditStatus() {
|
||||||
//whiteListService.updateWhiteListObjectAuditStatus(7, 1);
|
whiteListService.updateWhiteListObjectAuditStatus(7222, 2, "mh", 1, "mmeess");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -144,7 +144,7 @@ class WhiteListServiceTest extends ProtectionApplicationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testUpdateAuditStatusByIdBatch() {
|
void testUpdateAuditStatusByIdBatch() {
|
||||||
Map<Integer, Integer> idsWithAuditStatusMap = Map.of(7189, 2, 7192, 2);
|
Map<Integer, Integer> idsWithAuditStatusMap = Map.of(7220, 2, 7222, 2);
|
||||||
|
|
||||||
whiteListService.updateAuditStatusBatch(idsWithAuditStatusMap);
|
whiteListService.updateAuditStatusBatch(idsWithAuditStatusMap);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user