Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/realtime/protection/server/rule/dynamicrule/DynamicRuleControllerApi.java # src/main/java/com/realtime/protection/server/rule/dynamicrule/DynamicRuleService.java # src/main/java/com/realtime/protection/server/rule/staticrule/StaticRuleControllerApi.java # src/main/resources/mappers/StaticRuleMapper.xml # src/test/java/com/realtime/protection/server/rule/dynamic/DynamicRuleServiceTest.java # src/test/java/com/realtime/protection/server/rule/staticrule/StaticRuleServiceTest.java
This commit is contained in:
@@ -18,7 +18,7 @@ public class ProtectObject {
|
||||
private Integer protectObjectId;
|
||||
|
||||
@JsonProperty("proobj_name")
|
||||
@NotNull(message = "proobj_name should not be empty.")
|
||||
@NotNull(message = "proobj_name字段不能为空。")
|
||||
@ExcelProperty("名称")
|
||||
@Schema(description = "防护对象名称", example = "静态对象测试")
|
||||
private String protectObjectName;
|
||||
@@ -35,21 +35,21 @@ public class ProtectObject {
|
||||
private String protectObjectIPAddress;
|
||||
|
||||
@JsonProperty("proobj_port")
|
||||
@NotNull(message = "proobj_port should not be empty.")
|
||||
@Max(value = 65535, message = "port should not be more than 65535")
|
||||
@Min(value = 1, message = "port should not be less than 1")
|
||||
@NotNull(message = "proobj_port字段不能为空。")
|
||||
@Max(value = 65535, message = "端口号不能大于65535。")
|
||||
@Min(value = 1, message = "端口号不能小于1。")
|
||||
@ExcelProperty("端口")
|
||||
@Schema(description = "防护对象端口", maximum = "65535", minimum = "1", example = "8080")
|
||||
private Integer protectObjectPort;
|
||||
|
||||
@JsonProperty("proobj_url")
|
||||
@NotNull(message = "proobj_url should not be empty.")
|
||||
@NotNull(message = "proobj_url字段不能为空。")
|
||||
@ExcelProperty("URL")
|
||||
@Schema(description = "防护对象URL", example = "alice.bob.com")
|
||||
private String protectObjectURL;
|
||||
|
||||
@JsonProperty("proobj_protocol")
|
||||
@NotNull(message = "proobj_protocol should not be empty.")
|
||||
@NotNull(message = "proobj_protocol字段不能为空")
|
||||
@ExcelProperty("协议")
|
||||
@Schema(description = "防护对象网络协议(目前仅可以填写TCP或UDP)", example = "TCP")
|
||||
private String protectObjectProtocol;
|
||||
|
||||
@@ -12,27 +12,27 @@ public class Template {
|
||||
private Integer templateId;
|
||||
|
||||
@JsonProperty("template_name")
|
||||
@NotNull(message = "template name should not be empty.")
|
||||
@NotNull(message = "template_name字段不能为空。")
|
||||
@Schema(description = "防御策略模板名称", example = "自定义模板")
|
||||
private String templateName;
|
||||
|
||||
@JsonProperty("source_system")
|
||||
@NotNull(message = "source_system should not be empty. ")
|
||||
@NotNull(message = "source_system字段不能为空。")
|
||||
@Schema(description = "防御策略模板数据来源系统", example = "BW系统")
|
||||
private String sourceSystem;
|
||||
|
||||
@JsonProperty("protect_level_low")
|
||||
@NotNull(message = "protect_level_low should not be empty. ")
|
||||
@NotNull(message = "protect_level_low字段不能为空。")
|
||||
@Schema(description = "防御策略模板日常态字段提取选项")
|
||||
private ProtectLevel protectLevelLow;
|
||||
|
||||
@JsonProperty("protect_level_medium")
|
||||
@NotNull(message = "protect_level_medium should not be empty. ")
|
||||
@NotNull(message = "protect_level_medium字段不能为空。")
|
||||
@Schema(description = "防御策略模板应急态字段提取选项")
|
||||
private ProtectLevel protectLevelMedium;
|
||||
|
||||
@JsonProperty("protect_level_high")
|
||||
@NotNull(message = "protect_level_high should not be empty. ")
|
||||
@NotNull(message = "protect_level_high字段不能为空。")
|
||||
@Schema(description = "防御策略模板紧急态字段提取选项")
|
||||
private ProtectLevel protectLevelHigh;
|
||||
|
||||
|
||||
@@ -17,19 +17,19 @@ public class Task {
|
||||
private Long taskId;
|
||||
|
||||
@JsonProperty("task_name")
|
||||
@NotNull(message = "task_name should not be empty. ")
|
||||
@NotNull(message = "task_name字段不能为空。")
|
||||
@Schema(description = "任务名称", example = "静态任务")
|
||||
private String taskName;
|
||||
|
||||
@JsonProperty("task_start_time")
|
||||
@NotNull(message = "task_start_time should not be empty. ")
|
||||
@Future(message = "task_start_time should be a future time")
|
||||
@NotNull(message = "task_start_time字段不能为空。")
|
||||
@Future(message = "task_start_time必须晚于当前时间。")
|
||||
@Schema(description = "任务开始时间,必须晚于当前时间", example = "2024-10-23T00:00:00")
|
||||
private LocalDateTime taskStartTime;
|
||||
|
||||
@JsonProperty("task_end_time")
|
||||
@NotNull(message = "task_end_time should not be empty. ")
|
||||
@Future(message = "task_end_time should be a future time. ")
|
||||
@NotNull(message = "task_end_time字段不能为空。")
|
||||
@Future(message = "task_end_time必须晚于当前时间。")
|
||||
@Schema(description = "任务结束时间,必须晚于开始时间", example = "2024-10-24T00:00:00")
|
||||
private LocalDateTime taskEndTime;
|
||||
|
||||
@@ -42,12 +42,12 @@ public class Task {
|
||||
private LocalDateTime taskModifyTime;
|
||||
|
||||
@JsonProperty("task_type")
|
||||
@NotNull(message = "task_type should not be empty. ")
|
||||
@NotNull(message = "task_type字段不能为空。")
|
||||
@Schema(description = "任务类型,1为静态任务,2为实时任务,3为研判后任务", example = "1")
|
||||
private Integer taskType;
|
||||
|
||||
@JsonProperty("task_act")
|
||||
@NotNull(message = "task_act should not be empty. ")
|
||||
@NotNull(message = "task_act字段不能为空。")
|
||||
@Schema(description = "任务行为,目前只能为【阻断】", example = "阻断")
|
||||
private String taskAct;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class WhiteListObject {
|
||||
@JsonProperty("whiteobj_ip_address")
|
||||
@Pattern(regexp = "^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$", message = "Invalid IPv4 Address")
|
||||
@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;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -30,30 +30,23 @@ public class GlobalExceptionHandler {
|
||||
@Order(3)
|
||||
@ExceptionHandler(value = {Exception.class})
|
||||
public ResponseResult handleGlobalException(Exception e) {
|
||||
log.error("meets global exception: " + e.getMessage());
|
||||
log.error("遭遇全局异常:" + e.getMessage());
|
||||
return ResponseResult.error().setMessage(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = {PersistenceException.class})
|
||||
public ResponseResult handleSQLException(PersistenceException e) {
|
||||
log.error("meets database exception: " + e.getMessage());
|
||||
@ExceptionHandler(value = {PersistenceException.class, DuplicateKeyException.class})
|
||||
public ResponseResult handleSQLException(Exception e) {
|
||||
log.info("遭遇数据库异常:" + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage(
|
||||
"please check the integrity of the data. check if the json data exists in the database");
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = DuplicateKeyException.class)
|
||||
public ResponseResult handleDuplicateKeyException(DuplicateKeyException e) {
|
||||
log.debug("meets duplicate key exception: " + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage("duplicate key in json data");
|
||||
"请检查json字段的完整性,确保json字段按照文档中要求填写。");
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
|
||||
log.debug("meets data bind exception: " + e.getMessage());
|
||||
log.debug("遭遇数据绑定异常:" + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage(
|
||||
e.getBindingResult().getAllErrors().stream()
|
||||
.map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining())
|
||||
@@ -67,14 +60,14 @@ public class GlobalExceptionHandler {
|
||||
IllegalStateException.class
|
||||
})
|
||||
public ResponseResult handleHandlerMethodValidationException(Exception e) {
|
||||
log.debug("meets illegal argument exception: " + e.getMessage());
|
||||
log.debug("遭遇非法参数异常:" + e.getMessage());
|
||||
return ResponseResult.invalid().setMessage(e.getMessage());
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = NotLoginException.class)
|
||||
public ResponseResult handleNotLoginException(NotLoginException e) {
|
||||
log.debug("meets not login exception, login type: " + e.getLoginType());
|
||||
log.debug("遭遇Sa-Token登录异常,登录类型为:" + e.getLoginType());
|
||||
return new ResponseResult(
|
||||
401,
|
||||
e.getMessage()
|
||||
@@ -84,16 +77,16 @@ public class GlobalExceptionHandler {
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = SaTokenException.class)
|
||||
public ResponseResult handleSaTokenException(SaTokenException e) {
|
||||
log.debug("sa-token meets exception: " + e.getMessage());
|
||||
log.debug("Sa-token模块遭遇异常:" + e.getMessage());
|
||||
return ResponseResult.unAuthorized().setMessage(e.getMessage());
|
||||
}
|
||||
|
||||
@Order(2)
|
||||
@ExceptionHandler(value = DorisStartException.class)
|
||||
public ResponseResult handleDorisStartException(DorisStartException e) {
|
||||
log.warn("doris database meets exception: " + e.getMessage());
|
||||
log.warn("Doris数据库遭遇异常:" + e.getMessage());
|
||||
ResponseResult responseResult = ResponseResult.error()
|
||||
.setMessage("Doris command creation meets error: " + e.getMessage());
|
||||
.setMessage("Doris数据库指令生成遭遇异常:" + e.getMessage());
|
||||
|
||||
try {
|
||||
stateChangeService.changeState(StateEnum.FAILED.getStateNum(), e.taskId);
|
||||
|
||||
Reference in New Issue
Block a user