Merge remote-tracking branch 'origin/master'

This commit is contained in:
EnderByEndera
2024-04-08 16:27:33 +08:00
12 changed files with 271 additions and 69 deletions

View File

@@ -0,0 +1,22 @@
package com.realtime.protection.configuration.auth;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author Yixiang Zhao (@seriouszyx)
**/
@SpringBootApplication
@EnableCaching
public class Application implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// InterceptorRegistration ir = registry.addInterceptor(new LoginInterceptor());
// ir.addPathPatterns("/**");
// ir.excludePathPatterns("/js/**", "/html/**", "/image/**", "/css/**", "/api/**");
}
}

View File

@@ -0,0 +1,31 @@
package com.realtime.protection.configuration.auth;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequestInterceptor;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter;
import com.realtime.protection.configuration.entity.user.User;
import com.realtime.protection.configuration.response.ResponseResult;
/**
* @author Yixiang Zhao
**/
@Component
public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
if (user != null) {
return true;
}
// 未登录
throw new Exception("not login");
}
}

View File

@@ -35,4 +35,6 @@ public class AlertMessage {
@JsonProperty("alert_message_uuid")
private String alertMessageUUID;
@JsonProperty("protect_object_is_src_dst")
private int protectIsSrcOrDst;
}

View File

@@ -28,4 +28,7 @@ public class ProtectLevel {
@Schema(description = "该防护等级是否需要提取DNS")
private Boolean hasDNS = false;
@Schema(description = "该防护等级是处置防护对象的全流量or单向流量")
private Boolean isFullFlow = false;
}

View File

@@ -13,7 +13,7 @@ public class Template {
@JsonProperty("template_name")
@NotNull(message = "template_name字段不能为空。")
@Schema(description = "防御策略模板名称", example = "自定义模板")
@Schema(description = "防御策略模板名称(事件类型)", example = "APT攻击事件")
private String templateName;
@JsonProperty("source_system")
@@ -21,6 +21,10 @@ public class Template {
@Schema(description = "防御策略模板数据来源系统", example = "BW系统")
private String sourceSystem;
@JsonProperty("description")
@Schema(description = "对策略模板的文字描述。方便用户使用", example = "zd防护对象的全流量")
private String description;
@JsonProperty("protect_level_low")
@NotNull(message = "protect_level_low字段不能为空。")
@Schema(description = "防御策略模板日常态字段提取选项")

View File

@@ -97,10 +97,37 @@ public class TaskCommandInfo {
@Schema(description = "防御策略模板ID", accessMode = Schema.AccessMode.READ_ONLY)
private Integer templateId;
@Schema(description = "防护等级", accessMode = Schema.AccessMode.READ_ONLY)
@Schema(description = "防护等级,1代表low、2代表medium、3代表high", accessMode = Schema.AccessMode.READ_ONLY)
private Integer protectLevel;
@Schema(description = "指令所属任务的运行状态", accessMode = Schema.AccessMode.READ_ONLY)
private Integer taskStatus;
// 复制构造函数
public void copyTaskCommandInfo(TaskCommandInfo original) {
this.UUID = original.UUID;
this.taskId = original.taskId;
this.ruleId = original.ruleId;
this.taskCreateUsername = original.taskCreateUsername;
this.taskCreateDepart = original.taskCreateDepart;
this.taskCreateUserId = original.taskCreateUserId;
this.taskName = original.taskName;
this.taskType = original.taskType;
this.taskAct = original.taskAct;
this.frequency = original.frequency;
this.startTime = original.startTime;
this.endTime = original.endTime;
this.isValid = original.isValid;
this.isJudged = original.isJudged;
this.fiveTupleWithMask = original.fiveTupleWithMask;
this.commandSentTimes = original.commandSentTimes;
this.commandSuccessTimes = original.commandSuccessTimes;
this.earliestSendTime = original.earliestSendTime;
this.latestSendTime = original.latestSendTime;
this.templateId = original.templateId;
this.protectLevel = original.protectLevel;
this.taskStatus = original.taskStatus;
}
}