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:
@@ -1,13 +1,16 @@
|
|||||||
# SSFY系统 README
|
# SSFY系统 README
|
||||||
|
|
||||||
## 项目文件夹结构说明:
|
## 项目文件夹结构说明:
|
||||||
|
|
||||||
目前整体分为两大板块:**configuration**和**server**
|
目前整体分为两大板块:**configuration**和**server**
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
所有业务的配置,包括切面、拦截器、中间件、消息处理等配置全部放置于此处。
|
所有业务的配置,包括切面、拦截器、中间件、消息处理等配置全部放置于此处。
|
||||||
任何带@Configuration注解的配置均放置于此
|
任何带@Configuration注解的配置均放置于此
|
||||||
|
|
||||||
### server
|
### server
|
||||||
|
|
||||||
server主要存放所有的业务逻辑以及Mapper接口。业务逻辑和Mapper需要按照业务进行划分进行分开放置
|
server主要存放所有的业务逻辑以及Mapper接口。业务逻辑和Mapper需要按照业务进行划分进行分开放置
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ProtectObject {
|
|||||||
private Integer protectObjectId;
|
private Integer protectObjectId;
|
||||||
|
|
||||||
@JsonProperty("proobj_name")
|
@JsonProperty("proobj_name")
|
||||||
@NotNull(message = "proobj_name should not be empty.")
|
@NotNull(message = "proobj_name字段不能为空。")
|
||||||
@ExcelProperty("名称")
|
@ExcelProperty("名称")
|
||||||
@Schema(description = "防护对象名称", example = "静态对象测试")
|
@Schema(description = "防护对象名称", example = "静态对象测试")
|
||||||
private String protectObjectName;
|
private String protectObjectName;
|
||||||
@@ -35,21 +35,21 @@ public class ProtectObject {
|
|||||||
private String protectObjectIPAddress;
|
private String protectObjectIPAddress;
|
||||||
|
|
||||||
@JsonProperty("proobj_port")
|
@JsonProperty("proobj_port")
|
||||||
@NotNull(message = "proobj_port should not be empty.")
|
@NotNull(message = "proobj_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")
|
@Schema(description = "防护对象端口", maximum = "65535", minimum = "1", example = "8080")
|
||||||
private Integer protectObjectPort;
|
private Integer protectObjectPort;
|
||||||
|
|
||||||
@JsonProperty("proobj_url")
|
@JsonProperty("proobj_url")
|
||||||
@NotNull(message = "proobj_url should not be empty.")
|
@NotNull(message = "proobj_url字段不能为空。")
|
||||||
@ExcelProperty("URL")
|
@ExcelProperty("URL")
|
||||||
@Schema(description = "防护对象URL", example = "alice.bob.com")
|
@Schema(description = "防护对象URL", example = "alice.bob.com")
|
||||||
private String protectObjectURL;
|
private String protectObjectURL;
|
||||||
|
|
||||||
@JsonProperty("proobj_protocol")
|
@JsonProperty("proobj_protocol")
|
||||||
@NotNull(message = "proobj_protocol should not be empty.")
|
@NotNull(message = "proobj_protocol字段不能为空")
|
||||||
@ExcelProperty("协议")
|
@ExcelProperty("协议")
|
||||||
@Schema(description = "防护对象网络协议(目前仅可以填写TCP或UDP)", example = "TCP")
|
@Schema(description = "防护对象网络协议(目前仅可以填写TCP或UDP)", example = "TCP")
|
||||||
private String protectObjectProtocol;
|
private String protectObjectProtocol;
|
||||||
|
|||||||
@@ -12,27 +12,27 @@ public class Template {
|
|||||||
private Integer templateId;
|
private Integer templateId;
|
||||||
|
|
||||||
@JsonProperty("template_name")
|
@JsonProperty("template_name")
|
||||||
@NotNull(message = "template name should not be empty.")
|
@NotNull(message = "template_name字段不能为空。")
|
||||||
@Schema(description = "防御策略模板名称", example = "自定义模板")
|
@Schema(description = "防御策略模板名称", example = "自定义模板")
|
||||||
private String templateName;
|
private String templateName;
|
||||||
|
|
||||||
@JsonProperty("source_system")
|
@JsonProperty("source_system")
|
||||||
@NotNull(message = "source_system should not be empty. ")
|
@NotNull(message = "source_system字段不能为空。")
|
||||||
@Schema(description = "防御策略模板数据来源系统", example = "BW系统")
|
@Schema(description = "防御策略模板数据来源系统", example = "BW系统")
|
||||||
private String sourceSystem;
|
private String sourceSystem;
|
||||||
|
|
||||||
@JsonProperty("protect_level_low")
|
@JsonProperty("protect_level_low")
|
||||||
@NotNull(message = "protect_level_low should not be empty. ")
|
@NotNull(message = "protect_level_low字段不能为空。")
|
||||||
@Schema(description = "防御策略模板日常态字段提取选项")
|
@Schema(description = "防御策略模板日常态字段提取选项")
|
||||||
private ProtectLevel protectLevelLow;
|
private ProtectLevel protectLevelLow;
|
||||||
|
|
||||||
@JsonProperty("protect_level_medium")
|
@JsonProperty("protect_level_medium")
|
||||||
@NotNull(message = "protect_level_medium should not be empty. ")
|
@NotNull(message = "protect_level_medium字段不能为空。")
|
||||||
@Schema(description = "防御策略模板应急态字段提取选项")
|
@Schema(description = "防御策略模板应急态字段提取选项")
|
||||||
private ProtectLevel protectLevelMedium;
|
private ProtectLevel protectLevelMedium;
|
||||||
|
|
||||||
@JsonProperty("protect_level_high")
|
@JsonProperty("protect_level_high")
|
||||||
@NotNull(message = "protect_level_high should not be empty. ")
|
@NotNull(message = "protect_level_high字段不能为空。")
|
||||||
@Schema(description = "防御策略模板紧急态字段提取选项")
|
@Schema(description = "防御策略模板紧急态字段提取选项")
|
||||||
private ProtectLevel protectLevelHigh;
|
private ProtectLevel protectLevelHigh;
|
||||||
|
|
||||||
|
|||||||
@@ -17,19 +17,19 @@ public class Task {
|
|||||||
private Long taskId;
|
private Long taskId;
|
||||||
|
|
||||||
@JsonProperty("task_name")
|
@JsonProperty("task_name")
|
||||||
@NotNull(message = "task_name should not be empty. ")
|
@NotNull(message = "task_name字段不能为空。")
|
||||||
@Schema(description = "任务名称", example = "静态任务")
|
@Schema(description = "任务名称", example = "静态任务")
|
||||||
private String taskName;
|
private String taskName;
|
||||||
|
|
||||||
@JsonProperty("task_start_time")
|
@JsonProperty("task_start_time")
|
||||||
@NotNull(message = "task_start_time should not be empty. ")
|
@NotNull(message = "task_start_time字段不能为空。")
|
||||||
@Future(message = "task_start_time should be a future time")
|
@Future(message = "task_start_time必须晚于当前时间。")
|
||||||
@Schema(description = "任务开始时间,必须晚于当前时间", example = "2024-10-23T00:00:00")
|
@Schema(description = "任务开始时间,必须晚于当前时间", example = "2024-10-23T00:00:00")
|
||||||
private LocalDateTime taskStartTime;
|
private LocalDateTime taskStartTime;
|
||||||
|
|
||||||
@JsonProperty("task_end_time")
|
@JsonProperty("task_end_time")
|
||||||
@NotNull(message = "task_end_time should not be empty. ")
|
@NotNull(message = "task_end_time字段不能为空。")
|
||||||
@Future(message = "task_end_time should be a future time. ")
|
@Future(message = "task_end_time必须晚于当前时间。")
|
||||||
@Schema(description = "任务结束时间,必须晚于开始时间", example = "2024-10-24T00:00:00")
|
@Schema(description = "任务结束时间,必须晚于开始时间", example = "2024-10-24T00:00:00")
|
||||||
private LocalDateTime taskEndTime;
|
private LocalDateTime taskEndTime;
|
||||||
|
|
||||||
@@ -42,12 +42,12 @@ public class Task {
|
|||||||
private LocalDateTime taskModifyTime;
|
private LocalDateTime taskModifyTime;
|
||||||
|
|
||||||
@JsonProperty("task_type")
|
@JsonProperty("task_type")
|
||||||
@NotNull(message = "task_type should not be empty. ")
|
@NotNull(message = "task_type字段不能为空。")
|
||||||
@Schema(description = "任务类型,1为静态任务,2为实时任务,3为研判后任务", example = "1")
|
@Schema(description = "任务类型,1为静态任务,2为实时任务,3为研判后任务", example = "1")
|
||||||
private Integer taskType;
|
private Integer taskType;
|
||||||
|
|
||||||
@JsonProperty("task_act")
|
@JsonProperty("task_act")
|
||||||
@NotNull(message = "task_act should not be empty. ")
|
@NotNull(message = "task_act字段不能为空。")
|
||||||
@Schema(description = "任务行为,目前只能为【阻断】", example = "阻断")
|
@Schema(description = "任务行为,目前只能为【阻断】", example = "阻断")
|
||||||
private String taskAct;
|
private String taskAct;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class WhiteListObject {
|
|||||||
@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 = "Invalid IPv4 Address")
|
||||||
@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
|
||||||
|
|||||||
@@ -30,30 +30,23 @@ public class GlobalExceptionHandler {
|
|||||||
@Order(3)
|
@Order(3)
|
||||||
@ExceptionHandler(value = {Exception.class})
|
@ExceptionHandler(value = {Exception.class})
|
||||||
public ResponseResult handleGlobalException(Exception e) {
|
public ResponseResult handleGlobalException(Exception e) {
|
||||||
log.error("meets global exception: " + e.getMessage());
|
log.error("遭遇全局异常:" + e.getMessage());
|
||||||
return ResponseResult.error().setMessage(e.getMessage());
|
return ResponseResult.error().setMessage(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@ExceptionHandler(value = {PersistenceException.class})
|
@ExceptionHandler(value = {PersistenceException.class, DuplicateKeyException.class})
|
||||||
public ResponseResult handleSQLException(PersistenceException e) {
|
public ResponseResult handleSQLException(Exception e) {
|
||||||
log.error("meets database exception: " + e.getMessage());
|
log.info("遭遇数据库异常:" + e.getMessage());
|
||||||
return ResponseResult.invalid().setMessage(
|
return ResponseResult.invalid().setMessage(
|
||||||
"please check the integrity of the data. check if the json data exists in the database");
|
"请检查json字段的完整性,确保json字段按照文档中要求填写。");
|
||||||
}
|
|
||||||
|
|
||||||
@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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||||
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
|
public ResponseResult handleBindException(MethodArgumentNotValidException e) {
|
||||||
log.debug("meets data bind exception: " + e.getMessage());
|
log.debug("遭遇数据绑定异常:" + e.getMessage());
|
||||||
return ResponseResult.invalid().setMessage(
|
return ResponseResult.invalid().setMessage(
|
||||||
e.getBindingResult().getAllErrors().stream()
|
e.getBindingResult().getAllErrors().stream()
|
||||||
.map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining())
|
.map(DefaultMessageSourceResolvable::getDefaultMessage).collect(Collectors.joining())
|
||||||
@@ -67,14 +60,14 @@ public class GlobalExceptionHandler {
|
|||||||
IllegalStateException.class
|
IllegalStateException.class
|
||||||
})
|
})
|
||||||
public ResponseResult handleHandlerMethodValidationException(Exception e) {
|
public ResponseResult handleHandlerMethodValidationException(Exception e) {
|
||||||
log.debug("meets illegal argument exception: " + e.getMessage());
|
log.debug("遭遇非法参数异常:" + e.getMessage());
|
||||||
return ResponseResult.invalid().setMessage(e.getMessage());
|
return ResponseResult.invalid().setMessage(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@ExceptionHandler(value = NotLoginException.class)
|
@ExceptionHandler(value = NotLoginException.class)
|
||||||
public ResponseResult handleNotLoginException(NotLoginException e) {
|
public ResponseResult handleNotLoginException(NotLoginException e) {
|
||||||
log.debug("meets not login exception, login type: " + e.getLoginType());
|
log.debug("遭遇Sa-Token登录异常,登录类型为:" + e.getLoginType());
|
||||||
return new ResponseResult(
|
return new ResponseResult(
|
||||||
401,
|
401,
|
||||||
e.getMessage()
|
e.getMessage()
|
||||||
@@ -84,16 +77,16 @@ public class GlobalExceptionHandler {
|
|||||||
@Order(2)
|
@Order(2)
|
||||||
@ExceptionHandler(value = SaTokenException.class)
|
@ExceptionHandler(value = SaTokenException.class)
|
||||||
public ResponseResult handleSaTokenException(SaTokenException e) {
|
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());
|
return ResponseResult.unAuthorized().setMessage(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@ExceptionHandler(value = DorisStartException.class)
|
@ExceptionHandler(value = DorisStartException.class)
|
||||||
public ResponseResult handleDorisStartException(DorisStartException e) {
|
public ResponseResult handleDorisStartException(DorisStartException e) {
|
||||||
log.warn("doris database meets exception: " + e.getMessage());
|
log.warn("Doris数据库遭遇异常:" + e.getMessage());
|
||||||
ResponseResult responseResult = ResponseResult.error()
|
ResponseResult responseResult = ResponseResult.error()
|
||||||
.setMessage("Doris command creation meets error: " + e.getMessage());
|
.setMessage("Doris数据库指令生成遭遇异常:" + e.getMessage());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stateChangeService.changeState(StateEnum.FAILED.getStateNum(), e.taskId);
|
stateChangeService.changeState(StateEnum.FAILED.getStateNum(), e.taskId);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class CommandService {
|
|||||||
commandBatch.clear();
|
commandBatch.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(String.format("create all the commands from task(%d), rule(%d)",
|
log.debug(String.format("在task(%d)和rule(%d)中构建了全部指令",
|
||||||
info.getTaskId(), info.getRuleId()));
|
info.getTaskId(), info.getRuleId()));
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -68,6 +68,7 @@ public class CommandService {
|
|||||||
public void createCommand(TaskCommandInfo commandInfo) throws DorisStartException {
|
public void createCommand(TaskCommandInfo commandInfo) throws DorisStartException {
|
||||||
try {
|
try {
|
||||||
sqlSessionWrapper.startBatchSession(CommandMapper.class, createCommandBatchFunction, commandInfo);
|
sqlSessionWrapper.startBatchSession(CommandMapper.class, createCommandBatchFunction, commandInfo);
|
||||||
|
taskService.changeTaskStatus(commandInfo.getTaskId(), StateEnum.RUNNING.getStateNum());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DorisStartException(e, commandInfo.getTaskId());
|
throw new DorisStartException(e, commandInfo.getTaskId());
|
||||||
}
|
}
|
||||||
@@ -92,7 +93,10 @@ public class CommandService {
|
|||||||
try {
|
try {
|
||||||
sqlSessionWrapper.startBatchSession(CommandMapper.class, function, taskCommandInfos);
|
sqlSessionWrapper.startBatchSession(CommandMapper.class, function, taskCommandInfos);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TaskCommandInfo info = taskCommandInfos.get(0);
|
TaskCommandInfo info = null;
|
||||||
|
if (taskCommandInfos != null) {
|
||||||
|
info = taskCommandInfos.get(0);
|
||||||
|
}
|
||||||
Long taskId = null;
|
Long taskId = null;
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
taskId = info.getTaskId();
|
taskId = info.getTaskId();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class ProjectObjectDataListener implements ReadListener<ProtectObject> {
|
|||||||
private void saveData() {
|
private void saveData() {
|
||||||
Boolean success = protectObjectService.newProtectObjects(cachedDataList);
|
Boolean success = protectObjectService.newProtectObjects(cachedDataList);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new RuntimeException("Error reading data in /proobj/new");
|
throw new RuntimeException("在/proobj/upload中读取数据时出现了错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
|||||||
@Override
|
@Override
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public ResponseResult uploadFile(
|
public ResponseResult uploadFile(
|
||||||
@NotNull(message = "uploadFile cannot be null. ") MultipartFile uploadFile
|
@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
EasyExcel.read(uploadFile.getInputStream(), ProtectObject.class,
|
EasyExcel.read(uploadFile.getInputStream(), ProtectObject.class,
|
||||||
new ProjectObjectDataListener(protectObjectService)).sheet().doRead();
|
new ProjectObjectDataListener(protectObjectService)).sheet().doRead();
|
||||||
@@ -85,6 +85,10 @@ public class ProtectObjectController implements ProtectObjectControllerApi {
|
|||||||
@GetMapping("/{protectObjectId}/query")
|
@GetMapping("/{protectObjectId}/query")
|
||||||
public ResponseResult queryProtectObject(@PathVariable Integer protectObjectId) throws IllegalAccessException {
|
public ResponseResult queryProtectObject(@PathVariable Integer protectObjectId) throws IllegalAccessException {
|
||||||
ProtectObject protectObject = protectObjectService.queryProtectObject(protectObjectId);
|
ProtectObject protectObject = protectObjectService.queryProtectObject(protectObjectId);
|
||||||
|
if (protectObject == null) {
|
||||||
|
return ResponseResult.invalid()
|
||||||
|
.setMessage("无效的防护对象ID,也许该ID指定的防护对象不存在?");
|
||||||
|
}
|
||||||
return ResponseResult.ok()
|
return ResponseResult.ok()
|
||||||
.setDataMap(EntityUtils.entityToMap(protectObject));
|
.setDataMap(EntityUtils.entityToMap(protectObject));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public interface ProtectObjectControllerApi {
|
|||||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "上传文件")
|
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "上传文件")
|
||||||
)
|
)
|
||||||
ResponseResult uploadFile(
|
ResponseResult uploadFile(
|
||||||
@NotNull(message = "uploadFile cannot be null. ") MultipartFile uploadFile
|
@NotNull(message = "uploadFile字段不能为空") MultipartFile uploadFile
|
||||||
) throws IOException;
|
) throws IOException;
|
||||||
|
|
||||||
@GetMapping("/download")
|
@GetMapping("/download")
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class ProtectObjectService {
|
|||||||
public Map<String, Object> changeProtectObjectAuditStatus(Integer protectObjectId, Integer auditStatus) {
|
public Map<String, Object> changeProtectObjectAuditStatus(Integer protectObjectId, Integer auditStatus) {
|
||||||
Integer originalAuditStatus = protectObjectMapper.queryProtectObject(protectObjectId).getProtectObjectAuditStatus();
|
Integer originalAuditStatus = protectObjectMapper.queryProtectObject(protectObjectId).getProtectObjectAuditStatus();
|
||||||
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
if (!AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(auditStatus)) {
|
||||||
throw new IllegalArgumentException("invalid audit status");
|
throw new IllegalArgumentException("无效的审核状态");
|
||||||
}
|
}
|
||||||
Boolean success = protectObjectMapper.changeProtectObjectAuditStatus(protectObjectId, auditStatus);
|
Boolean success = protectObjectMapper.changeProtectObjectAuditStatus(protectObjectId, auditStatus);
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class TemplateController implements TemplateControllerApi {
|
|||||||
Template template = templateService.queryTemplate(templateId);
|
Template template = templateService.queryTemplate(templateId);
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
return ResponseResult.invalid()
|
return ResponseResult.invalid()
|
||||||
.setMessage("invalid templateId, maybe this template doesn't exist?");
|
.setMessage("无效的策略模板ID,也许该模板不存在?");
|
||||||
}
|
}
|
||||||
return ResponseResult.ok()
|
return ResponseResult.ok()
|
||||||
.setDataMap(EntityUtils.entityToMap(template));
|
.setDataMap(EntityUtils.entityToMap(template));
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ public class TaskController implements TaskControllerApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@GetMapping("/{taskId}/running/{stateNum}")
|
@GetMapping("/{taskId}/running/{stateNum}")
|
||||||
public ResponseResult changeTaskStatus(@PathVariable @NotNull Integer stateNum,
|
public ResponseResult changeTaskStatus(@PathVariable @NotNull @Min(0) @Max(6) Integer stateNum,
|
||||||
@PathVariable @NotNull Long taskId) throws DorisStartException {
|
@PathVariable @NotNull Long taskId) throws DorisStartException {
|
||||||
return ResponseResult.ok()
|
return ResponseResult.ok()
|
||||||
.setData("task_id", taskId)
|
.setData("task_id", taskId)
|
||||||
|
|||||||
@@ -160,6 +160,6 @@ public interface TaskControllerApi {
|
|||||||
@Parameter(name = "stateNum", description = "任务状态编号任务状态(0为未启动,1为生成中,2为运行中,3为暂停中,4为已停止,5为已结束,6为失败)")
|
@Parameter(name = "stateNum", description = "任务状态编号任务状态(0为未启动,1为生成中,2为运行中,3为暂停中,4为已停止,5为已结束,6为失败)")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult changeTaskStatus(@PathVariable @NotNull Integer stateNum,
|
ResponseResult changeTaskStatus(@PathVariable @NotNull @Min(0) @Max(6) Integer stateNum,
|
||||||
@PathVariable @NotNull Long taskId) throws DorisStartException;
|
@PathVariable @NotNull Long taskId) throws DorisStartException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class TaskService {
|
|||||||
public Boolean changeTaskAuditStatus(Long taskId, Integer taskAuditStatus) {
|
public Boolean changeTaskAuditStatus(Long taskId, Integer taskAuditStatus) {
|
||||||
Integer originalAuditStatus = taskMapper.queryTaskAuditStatus(taskId);
|
Integer originalAuditStatus = taskMapper.queryTaskAuditStatus(taskId);
|
||||||
if (originalAuditStatus == null) {
|
if (originalAuditStatus == null) {
|
||||||
throw new IllegalArgumentException("cannot find audit status of task " + taskId + ", maybe task doesn't exist?");
|
throw new IllegalArgumentException("无法找到任务ID为" + taskId + "的任务,也许任务不存在?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(taskAuditStatus))
|
if (AuditStatusValidator.setOriginal(originalAuditStatus).checkValidate(taskAuditStatus))
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import com.realtime.protection.server.task.TaskService;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class StateChangeService {
|
public class StateChangeService {
|
||||||
@@ -22,9 +24,14 @@ public class StateChangeService {
|
|||||||
|
|
||||||
@DSTransactional
|
@DSTransactional
|
||||||
public Boolean changeState(Integer stateNum, Long taskId) throws DorisStartException {
|
public Boolean changeState(Integer stateNum, Long taskId) throws DorisStartException {
|
||||||
|
if (Objects.equals(stateNum, StateEnum.GENERATING.getStateNum()) ||
|
||||||
|
Objects.equals(stateNum, StateEnum.FAILED.getStateNum())) {
|
||||||
|
throw new IllegalArgumentException("非法任务状态:" + StateEnum.getStateByNum(stateNum));
|
||||||
|
}
|
||||||
|
|
||||||
Integer originalStateNum = taskService.queryTaskStatus(taskId);
|
Integer originalStateNum = taskService.queryTaskStatus(taskId);
|
||||||
if (originalStateNum == null) {
|
if (originalStateNum == null) {
|
||||||
throw new IllegalArgumentException("cannot find status of task " + taskId + ", maybe task doesn't exist?");
|
throw new IllegalArgumentException("无法找到" + taskId + "的任务状态,也许任务ID不存在?");
|
||||||
}
|
}
|
||||||
|
|
||||||
State originalState = StateEnum.getStateByNum(originalStateNum);
|
State originalState = StateEnum.getStateByNum(originalStateNum);
|
||||||
@@ -39,7 +46,7 @@ public class StateChangeService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug(String.format("successfully let task(%d) change state from %s to %s",
|
log.debug(String.format("成功使得task(%d)从%s切换为%s",
|
||||||
taskId,
|
taskId,
|
||||||
originalState.getClass().getSimpleName(),
|
originalState.getClass().getSimpleName(),
|
||||||
newState.getClass().getSimpleName()));
|
newState.getClass().getSimpleName()));
|
||||||
|
|||||||
@@ -16,13 +16,13 @@ public class StateHandler {
|
|||||||
Task task = taskService.queryTask(taskId);
|
Task task = taskService.queryTask(taskId);
|
||||||
|
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
throw new IllegalArgumentException("invalid task id");
|
throw new IllegalArgumentException("无效task_id,因为无法找到对应任务");
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer taskAuditStatus = task.getTaskAuditStatus();
|
Integer taskAuditStatus = task.getTaskAuditStatus();
|
||||||
|
|
||||||
if (taskAuditStatus == null) {
|
if (taskAuditStatus == null) {
|
||||||
throw new IllegalArgumentException("invalid task id, because task_audit_status is null");
|
throw new IllegalArgumentException("无效的task_id,因为task_audit_status为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果审核状态不为已通过审核,则无效
|
// 如果审核状态不为已通过审核,则无效
|
||||||
@@ -74,7 +74,7 @@ public class StateHandler {
|
|||||||
// 如果未能获取staticTaskCommandInfos,需要报错
|
// 如果未能获取staticTaskCommandInfos,需要报错
|
||||||
List<TaskCommandInfo> staticTaskCommandInfos = taskService.getStaticCommandInfos(taskId);
|
List<TaskCommandInfo> staticTaskCommandInfos = taskService.getStaticCommandInfos(taskId);
|
||||||
if (staticTaskCommandInfos == null || staticTaskCommandInfos.isEmpty()) {
|
if (staticTaskCommandInfos == null || staticTaskCommandInfos.isEmpty()) {
|
||||||
throw new IllegalArgumentException("static rules are empty, need to choose at least one static rule");
|
throw new IllegalArgumentException("静态规则列表为空,请至少选择一个静态规则以启动任务");
|
||||||
}
|
}
|
||||||
|
|
||||||
commandService.createCommands(staticTaskCommandInfos);
|
commandService.createCommands(staticTaskCommandInfos);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface WhiteListControllerApi {
|
|||||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||||
description = "白名单信息")
|
description = "白名单信息")
|
||||||
)
|
)
|
||||||
ResponseResult newWhitelistObject(@RequestBody WhiteListObject object) ;
|
ResponseResult newWhitelistObject(@RequestBody WhiteListObject object);
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "批量导入白名单",
|
summary = "批量导入白名单",
|
||||||
@@ -51,7 +51,7 @@ public interface WhiteListControllerApi {
|
|||||||
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
|
||||||
description = "Excel文件")
|
description = "Excel文件")
|
||||||
)
|
)
|
||||||
ResponseResult uploadFile(MultipartFile uploadFile) throws IOException ;
|
ResponseResult uploadFile(MultipartFile uploadFile) throws IOException;
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "下载白名单模板",
|
summary = "下载白名单模板",
|
||||||
@@ -66,7 +66,7 @@ public interface WhiteListControllerApi {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
void downloadTemplate(HttpServletResponse response) throws IOException ;
|
void downloadTemplate(HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "查询白名单",
|
summary = "查询白名单",
|
||||||
@@ -90,7 +90,7 @@ public interface WhiteListControllerApi {
|
|||||||
ResponseResult queryWhiteListObject(@RequestParam(value = "whiteobj_name", required = false) String whiteListName,
|
ResponseResult queryWhiteListObject(@RequestParam(value = "whiteobj_name", required = false) String whiteListName,
|
||||||
@RequestParam(value = "whiteobj_id", required = false) Integer whiteListId,
|
@RequestParam(value = "whiteobj_id", required = false) Integer whiteListId,
|
||||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||||
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize) ;
|
@RequestParam(value = "page_size", defaultValue = "10") Integer pageSize);
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "查询单个白名单",
|
summary = "查询单个白名单",
|
||||||
@@ -108,7 +108,7 @@ public interface WhiteListControllerApi {
|
|||||||
@Parameter(name = "id", description = "白名单ID", example = "2")
|
@Parameter(name = "id", description = "白名单ID", example = "2")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult queryWhiteListObjectById(@PathVariable Integer id) ;
|
ResponseResult queryWhiteListObjectById(@PathVariable Integer id);
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "删除白名单",
|
summary = "删除白名单",
|
||||||
@@ -144,7 +144,7 @@ public interface WhiteListControllerApi {
|
|||||||
@Parameter(name = "ids", description = "白名单id数组")
|
@Parameter(name = "ids", description = "白名单id数组")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult deleteWhiteListObjects(@PathVariable List<Integer> whiteListObjIds) ;
|
ResponseResult deleteWhiteListObjects(@PathVariable List<Integer> whiteListObjIds);
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "修改白名单",
|
summary = "修改白名单",
|
||||||
@@ -166,7 +166,7 @@ public interface WhiteListControllerApi {
|
|||||||
|
|
||||||
)
|
)
|
||||||
ResponseResult updateWhiteListObject(@PathVariable Integer id,
|
ResponseResult updateWhiteListObject(@PathVariable Integer id,
|
||||||
@RequestBody WhiteListObject object) ;
|
@RequestBody WhiteListObject object);
|
||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "修改白名单审核状态",
|
summary = "修改白名单审核状态",
|
||||||
@@ -186,9 +186,7 @@ public interface WhiteListControllerApi {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
ResponseResult updateWhiteListObjectAuditStatus(@PathVariable Integer id,
|
ResponseResult updateWhiteListObjectAuditStatus(@PathVariable Integer id,
|
||||||
@PathVariable Integer auditStatus) ;
|
@PathVariable Integer auditStatus);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public interface WhiteListMapper {
|
|||||||
@Delete("delete from t_white_list where white_list_id = #{id}")
|
@Delete("delete from t_white_list where white_list_id = #{id}")
|
||||||
Integer deleteWhiteListObject(Integer id);
|
Integer deleteWhiteListObject(Integer id);
|
||||||
|
|
||||||
Integer updateWhiteListObject(@Param("id")Integer id, @Param("object") WhiteListObject object);
|
Integer updateWhiteListObject(@Param("id") Integer id, @Param("object") WhiteListObject object);
|
||||||
|
|
||||||
List<String> existWhiteListObject(@Param("staticRuleObject") StaticRuleObject staticRuleObject);
|
List<String> existWhiteListObject(@Param("staticRuleObject") StaticRuleObject staticRuleObject);
|
||||||
|
|
||||||
|
|||||||
@@ -52,3 +52,8 @@ springdoc:
|
|||||||
swagger-ui:
|
swagger-ui:
|
||||||
path: /swagger
|
path: /swagger
|
||||||
packages-to-scan: com.realtime.protection.server
|
packages-to-scan: com.realtime.protection.server
|
||||||
|
|
||||||
|
management:
|
||||||
|
endpoint:
|
||||||
|
shutdown:
|
||||||
|
enabled: true
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.realtime.protection.server.rule.dynamicrule.DynamicRuleMapper">
|
<mapper namespace="com.realtime.protection.server.rule.dynamicrule.DynamicRuleMapper">
|
||||||
|
|
||||||
<!-- useGeneratedKeys="true": 这个属性指定了是否要获取数据库生成的主键。如果设置为true,MyBatis会使用JDBC的getGeneratedKeys方法来获取由数据库自动生成的主键。-->
|
<!-- useGeneratedKeys="true": 这个属性指定了是否要获取数据库生成的主键。如果设置为true,MyBatis会使用JDBC的getGeneratedKeys方法来获取由数据库自动生成的主键。-->
|
||||||
<!-- keyProperty="id": 这个属性指定了要将生成的主键赋值给哪个属性。在这个例子中,生成的主键将被赋值给名为id的属性。-->
|
<!-- keyProperty="id": 这个属性指定了要将生成的主键赋值给哪个属性。在这个例子中,生成的主键将被赋值给名为id的属性。-->
|
||||||
<insert id="newDynamicRule" useGeneratedKeys="true" keyProperty="dynamicRuleId">
|
<insert id="newDynamicRule" useGeneratedKeys="true" keyProperty="dynamicRuleId">
|
||||||
|
|
||||||
insert into t_dynamic_rule
|
insert into t_dynamic_rule
|
||||||
@@ -14,10 +14,9 @@
|
|||||||
dynamic_rule_create_depart, template_id, dynamic_rule_protect_level,
|
dynamic_rule_create_depart, template_id, dynamic_rule_protect_level,
|
||||||
dynamic_rule_priority, dynamic_rule_range,
|
dynamic_rule_priority, dynamic_rule_range,
|
||||||
dynamic_rule_frequency, dynamic_rule_create_user_id)
|
dynamic_rule_frequency, dynamic_rule_create_user_id)
|
||||||
values
|
values (#{object.dynamicRuleName},
|
||||||
(#{object.dynamicRuleName},
|
#{object.dynamicRuleCreateTime}, #{object.dynamicRuleModifyTime},
|
||||||
#{object.dynamicRuleCreateTime},#{object.dynamicRuleModifyTime},
|
#{object.dynamicRuleCreateUsername}, #{object.dynamicRuleCreateDepart},
|
||||||
#{object.dynamicRuleCreateUsername},#{object.dynamicRuleCreateDepart},
|
|
||||||
#{object.templateId}, #{object.dynamicRuleProtectLevel},
|
#{object.templateId}, #{object.dynamicRuleProtectLevel},
|
||||||
#{object.dynamicRulePriority}, #{object.dynamicRuleRange},
|
#{object.dynamicRulePriority}, #{object.dynamicRuleRange},
|
||||||
#{object.dynamicRuleFrequency},
|
#{object.dynamicRuleFrequency},
|
||||||
@@ -26,8 +25,7 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="newDynamicRulProtectObjectConcat">
|
<insert id="newDynamicRulProtectObjectConcat">
|
||||||
insert into
|
insert into t_protect_object_dynamic_rule_conn(dynamic_rule_id, protect_object_id)
|
||||||
t_protect_object_dynamic_rule_conn(dynamic_rule_id, protect_object_id)
|
|
||||||
values (#{dynamicRuleId}, #{protectObjectId})
|
values (#{dynamicRuleId}, #{protectObjectId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@@ -61,18 +59,20 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- join删除-->
|
<!-- join删除-->
|
||||||
<!-- # delete t_dynamic_rule, t_protect_object_dynamic_rule_conn-->
|
<!-- # delete t_dynamic_rule, t_protect_object_dynamic_rule_conn-->
|
||||||
<!-- # from t_dynamic_rule-->
|
<!-- # from t_dynamic_rule-->
|
||||||
<!-- # inner join t_protect_object_dynamic_rule_conn-->
|
<!-- # inner join t_protect_object_dynamic_rule_conn-->
|
||||||
<!-- # on t_dynamic_rule.dynamic_rule_id = t_protect_object_dynamic_rule_conn.dynamic_rule_id-->
|
<!-- # on t_dynamic_rule.dynamic_rule_id = t_protect_object_dynamic_rule_conn.dynamic_rule_id-->
|
||||||
<!-- # where t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}-->
|
<!-- # where t_dynamic_rule.dynamic_rule_id = #{dynamicRuleId}-->
|
||||||
<delete id="deleteDynamicRuleObject">
|
<delete id="deleteDynamicRuleObject">
|
||||||
delete from t_dynamic_rule
|
delete
|
||||||
|
from t_dynamic_rule
|
||||||
where dynamic_rule_id = #{dynamicRuleId}
|
where dynamic_rule_id = #{dynamicRuleId}
|
||||||
</delete>
|
</delete>
|
||||||
<!-- 用于update时删去之前的关联-->
|
<!-- 用于update时删去之前的关联-->
|
||||||
<delete id="deleteDynamicRuleProtectObjectConcat">
|
<delete id="deleteDynamicRuleProtectObjectConcat">
|
||||||
delete from t_protect_object_dynamic_rule_conn
|
delete
|
||||||
|
from t_protect_object_dynamic_rule_conn
|
||||||
where dynamic_rule_id = #{dynamicRuleId}
|
where dynamic_rule_id = #{dynamicRuleId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
@@ -88,19 +88,22 @@
|
|||||||
<update id="updateDynamicRuleObject">
|
<update id="updateDynamicRuleObject">
|
||||||
update t_dynamic_rule
|
update t_dynamic_rule
|
||||||
set
|
set
|
||||||
<if test="object.dynamicRuleName != null"> dynamic_rule_name = #{object.dynamicRuleName},</if>
|
<if test="object.dynamicRuleName != null">dynamic_rule_name = #{object.dynamicRuleName},</if>
|
||||||
<if test="object.dynamicRuleModifyTime != null"> modify_time = #{object.dynamicRuleModifyTime},</if>
|
<if test="object.dynamicRuleModifyTime != null">modify_time = #{object.dynamicRuleModifyTime},</if>
|
||||||
<if test="object.templateId != null"> template_id = #{object.templateId},</if>
|
<if test="object.templateId != null">template_id = #{object.templateId},</if>
|
||||||
<if test="object.dynamicRuleProtectLevel != null"> dynamic_rule_protect_level = #{object.dynamicRuleProtectLevel},</if>
|
<if test="object.dynamicRuleProtectLevel != null">dynamic_rule_protect_level =
|
||||||
<if test="object.dynamicRulePriority != null"> dynamic_rule_priority = #{object.dynamicRulePriority},</if>
|
#{object.dynamicRuleProtectLevel},
|
||||||
<if test="object.dynamicRuleRange != null"> dynamic_rule_range = #{object.dynamicRuleRange},</if>
|
</if>
|
||||||
<if test="object.dynamicRuleFrequency != null"> dynamic_rule_frequency = #{object.dynamicRuleFrequency}</if>
|
<if test="object.dynamicRulePriority != null">dynamic_rule_priority = #{object.dynamicRulePriority},</if>
|
||||||
|
<if test="object.dynamicRuleRange != null">dynamic_rule_range = #{object.dynamicRuleRange},</if>
|
||||||
|
<if test="object.dynamicRuleFrequency != null">dynamic_rule_frequency = #{object.dynamicRuleFrequency}</if>
|
||||||
where
|
where
|
||||||
dynamic_rule_id = #{dynamicRuleId}
|
dynamic_rule_id = #{dynamicRuleId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
<resultMap id="dynamicRuleMap" type="com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject">
|
<resultMap id="dynamicRuleMap"
|
||||||
|
type="com.realtime.protection.configuration.entity.rule.dynamicrule.DynamicRuleObject">
|
||||||
<id column="dynamic_rule_id" property="dynamicRuleId"/>
|
<id column="dynamic_rule_id" property="dynamicRuleId"/>
|
||||||
<result column="dynamic_rule_name" property="dynamicRuleName"/>
|
<result column="dynamic_rule_name" property="dynamicRuleName"/>
|
||||||
<result column="create_time" property="dynamicRuleCreateTime"/>
|
<result column="create_time" property="dynamicRuleCreateTime"/>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class TemplateServiceTest {
|
|||||||
void testUpdateTemplateSuccess() {
|
void testUpdateTemplateSuccess() {
|
||||||
List<Template> templates = templateService.queryTemplates("DDOS", 1, 1);
|
List<Template> templates = templateService.queryTemplates("DDOS", 1, 1);
|
||||||
Template testTemplate = templates.get(0);
|
Template testTemplate = templates.get(0);
|
||||||
testTemplate.setTemplateName("洪泛型DDOS攻击-"+LocalDateTime.now());
|
testTemplate.setTemplateName("洪泛型DDOS攻击-" + LocalDateTime.now());
|
||||||
|
|
||||||
assertTrue(templateService.updateTemplate(testTemplate.getTemplateId(), testTemplate));
|
assertTrue(templateService.updateTemplate(testTemplate.getTemplateId(), testTemplate));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,15 @@ class TaskServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testNewTaskSuccess() {
|
void testNewTaskSuccess() {
|
||||||
for (int i = 0; i < 100; i++){
|
for (int i = 0; i < 100; i++) {
|
||||||
LocalDateTime taskStartTime = LocalDateTime.now().plusDays(i);
|
LocalDateTime taskStartTime = LocalDateTime.now().plusDays(i);
|
||||||
LocalDateTime taskEndTime = LocalDateTime.now().plusDays(i+10);
|
LocalDateTime taskEndTime = LocalDateTime.now().plusDays(i + 10);
|
||||||
task.setTaskStartTime(taskStartTime);
|
task.setTaskStartTime(taskStartTime);
|
||||||
task.setTaskEndTime(taskEndTime);
|
task.setTaskEndTime(taskEndTime);
|
||||||
assertDoesNotThrow(() -> {Long taskId = taskService.newTask(task); assertTrue(taskId > 0);});
|
assertDoesNotThrow(() -> {
|
||||||
|
Long taskId = taskService.newTask(task);
|
||||||
|
assertTrue(taskId > 0);
|
||||||
|
});
|
||||||
assertTrue(task.getTaskId() > 0);
|
assertTrue(task.getTaskId() > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,14 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class WhiteListServiceTest {
|
class WhiteListServiceTest {
|
||||||
|
|
||||||
private final WhiteListService whiteListService;
|
private final WhiteListService whiteListService;
|
||||||
private WhiteListObject whiteListObject;
|
private WhiteListObject whiteListObject;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
WhiteListServiceTest(WhiteListService whiteListService) {
|
WhiteListServiceTest(WhiteListService whiteListService) {
|
||||||
this.whiteListService = whiteListService;
|
this.whiteListService = whiteListService;
|
||||||
@@ -59,12 +60,12 @@ class WhiteListServiceTest {
|
|||||||
//object.setWhiteListId(7);
|
//object.setWhiteListId(7);
|
||||||
object.setWhiteListName("test_update");
|
object.setWhiteListName("test_update");
|
||||||
|
|
||||||
whiteListService.updateWhiteListObject(7,object);
|
whiteListService.updateWhiteListObject(7, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testExistWhiteList() {
|
void testExistWhiteList() {
|
||||||
List<Integer> ruleIds = List.of(6,7,8);
|
List<Integer> ruleIds = List.of(6, 7, 8);
|
||||||
// List<String> ip_list = whiteListService.existWhiteListObject(ruleIds);
|
// List<String> ip_list = whiteListService.existWhiteListObject(ruleIds);
|
||||||
// System.out.println(ip_list);
|
// System.out.println(ip_list);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user