安全组相关代码优化.

This commit is contained in:
aoshiguchen
2023-12-10 22:43:59 +08:00
parent bb96caca64
commit d3c658fa4d
26 changed files with 308 additions and 136 deletions
@@ -71,6 +71,8 @@ public enum ExceptionConstant {
// 安全组管理(17000)
SECURITY_GROUP_NOT_EXIST(17000, "安全组不存在"),
SECURITY_RULE_NOT_EXIST(17001, "安全规则不存在"),
;
private int code;
@@ -11,6 +11,6 @@ public enum SecurityRulePassTypeEnum {
NONE(-1, "none")
;
private final Integer code;
private final Integer type;
private final String desc;
}
@@ -2,20 +2,14 @@ package org.dromara.neutrinoproxy.server.controller;
import org.dromara.neutrinoproxy.server.base.page.PageInfo;
import org.dromara.neutrinoproxy.server.base.page.PageQuery;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.controller.req.system.*;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupDetailRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupListRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupUpdateEnableStatueRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleRes;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO;
import org.dromara.neutrinoproxy.server.controller.res.system.*;
import org.dromara.neutrinoproxy.server.service.PortMappingService;
import org.dromara.neutrinoproxy.server.service.SecurityGroupService;
import org.dromara.neutrinoproxy.server.util.ParamCheckUtil;
import org.noear.solon.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@Controller
@Mapping("/security")
@@ -87,11 +81,18 @@ public class SecurityController {
return groupService.updateGroupEnableStatueReq(req);
}
@Get
@Mapping("/rule/page")
public PageInfo<SecurityRuleListRes> rulePage(PageQuery pageQuery, SecurityRuleListReq req) {
ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");
return groupService.rulePage(pageQuery, req);
}
@Get
@Mapping("/rule/list")
public List<SecurityRuleRes> getRuleListByGroupId(Integer groupId) {
List<SecurityRuleDO> ruleDOList = groupService.queryRuleListByGroupId(groupId);
return ruleDOList.stream().map(SecurityRuleDO::toRes).collect(Collectors.toList());
public List<SecurityRuleListRes> getRuleListByGroupId(SecurityRuleListReq req) {
return groupService.ruleList(req);
}
@Post
@@ -114,15 +115,13 @@ public class SecurityController {
@Post
@Mapping("/rule/enable")
public void enableRule(Integer ruleId) {
groupService.setRuleStatus(ruleId, EnableStatusEnum.ENABLE);
}
@Mapping("/rule/update/enable-status")
public SecurityRuleUpdateEnableStatueRes updateRuleEnableStatueReq(SecurityRuleUpdateEnableStatueReq req) {
ParamCheckUtil.checkNotNull(req, "req");
ParamCheckUtil.checkNotNull(req.getId(), "id");
ParamCheckUtil.checkNotNull(req.getEnable(), "enable");
@Post
@Mapping("/rule/disable")
public void disableRule(Integer ruleId) {
groupService.setRuleStatus(ruleId, EnableStatusEnum.DISABLE);
return groupService.updateRuleEnableStatueReq(req);
}
}
@@ -18,6 +18,6 @@ public class SecurityGroupCreateReq {
/**
* 通过类型
*/
private SecurityRulePassTypeEnum defaultPassType;
private Integer defaultPassType;
}
@@ -17,6 +17,6 @@ public class SecurityGroupListReq {
/**
* 通过类型
*/
private SecurityRulePassTypeEnum defaultPassType;
private Integer defaultPassType;
private Integer enable;
}
@@ -47,7 +47,7 @@ public class SecurityRuleCreateReq {
* 放行类型,reject 或 allow
* {@link SecurityRulePassTypeEnum}
*/
private SecurityRulePassTypeEnum passType;
private Integer passType;
/**
* 优先级,数字越小,优先级越高
@@ -0,0 +1,16 @@
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
/**
* @author: aoshiguchen
* @date: 2023/12/10
*/
@Data
public class SecurityRuleListReq {
private String groupId;
private String name;
private String description;
private Integer passType;
private Integer enable;
}
@@ -0,0 +1,19 @@
package org.dromara.neutrinoproxy.server.controller.req.system;
import lombok.Data;
/**
* @author: aoshiguchen
* @date: 2023/12/10
*/
@Data
public class SecurityRuleUpdateEnableStatueReq {
/**
* id
*/
private Integer id;
/**
* 启用状态
*/
private Integer enable;
}
@@ -41,7 +41,7 @@ public class SecurityRuleUpdateReq {
* 放行类型,reject 或 allow
* {@link SecurityRulePassTypeEnum}
*/
private SecurityRulePassTypeEnum passType;
private Integer passType;
/**
* 优先级,数字越小,优先级越高
@@ -31,7 +31,7 @@ public class SecurityGroupDetailRes {
* 默认放行类型
* {@link SecurityRulePassTypeEnum}
*/
private String defaultPassType;
private Integer defaultPassType;
/**
* 创建时间
@@ -5,6 +5,8 @@ import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import java.util.Date;
@Data
@Accessors(chain = true)
public class SecurityGroupListRes {
@@ -31,16 +33,16 @@ public class SecurityGroupListRes {
* 默认放行类型
* {@link SecurityRulePassTypeEnum}
*/
private String defaultPassType;
private Integer defaultPassType;
/**
* 创建时间
*/
private String createTime;
private Date createTime;
/**
* 更新时间
*/
private String updateTime;
private Date updateTime;
@@ -3,7 +3,6 @@ package org.dromara.neutrinoproxy.server.controller.res.system;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import java.util.Date;
@@ -11,7 +10,7 @@ import java.util.Date;
@Data
@ToString
@Accessors(chain = true)
public class SecurityRuleRes {
public class SecurityRuleListRes {
private Integer id;
@@ -44,7 +43,7 @@ public class SecurityRuleRes {
* 放行类型reject allow
* {@link SecurityRulePassTypeEnum}
*/
private String passType;
private Integer passType;
/**
* 优先级数字越小优先级越高
@@ -59,10 +58,10 @@ public class SecurityRuleRes {
/**
* 创建时间
*/
private String createTime;
private Date createTime;
/**
* 更新时间
*/
private String updateTime;
private Date updateTime;
}
@@ -0,0 +1,8 @@
package org.dromara.neutrinoproxy.server.controller.res.system;
/**
* @author: aoshiguchen
* @date: 2023/12/10
*/
public class SecurityRuleUpdateEnableStatueRes {
}
@@ -1,7 +1,25 @@
package org.dromara.neutrinoproxy.server.dal;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityGroupListReq;
import org.dromara.neutrinoproxy.server.controller.req.system.SecurityRuleListReq;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO;
import java.util.Date;
import java.util.List;
public interface SecurityRuleMapper extends BaseMapper<SecurityRuleDO> {
List<SecurityRuleDO> selectByCondition(IPage<SecurityRuleDO> page, @Param("req") SecurityRuleListReq req);
default void updateEnableStatus(Integer id, Integer enable, Date updateTime) {
this.update(null, new LambdaUpdateWrapper<SecurityRuleDO>()
.eq(SecurityRuleDO::getId, id)
.set(SecurityRuleDO::getEnable, enable)
.set(SecurityRuleDO::getUpdateTime, updateTime)
);
}
}
@@ -49,7 +49,7 @@ public class SecurityGroupDO {
* 默认放行类型
* {@link SecurityRulePassTypeEnum}
*/
private SecurityRulePassTypeEnum defaultPassType;
private Integer defaultPassType;
/**
* 创建时间
@@ -63,18 +63,12 @@ public class SecurityGroupDO {
public SecurityGroupListRes toListRes() {
SecurityGroupListRes res = new SecurityGroupListRes();
BeanUtil.copyProperties(this, res);
res.setDefaultPassType(defaultPassType.getDesc())
.setCreateTime(DateUtil.format(this.getCreateTime(), DatePattern.NORM_DATETIME_FORMAT))
.setUpdateTime(DateUtil.format(this.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT));
return res;
}
public SecurityGroupDetailRes toDetailRes() {
SecurityGroupDetailRes res = new SecurityGroupDetailRes();
BeanUtil.copyProperties(this, res);
res.setDefaultPassType(defaultPassType.getDesc())
.setCreateTime(DateUtil.format(this.getCreateTime(), DatePattern.NORM_DATETIME_FORMAT))
.setUpdateTime(DateUtil.format(this.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT));
return res;
}
}
@@ -1,8 +1,6 @@
package org.dromara.neutrinoproxy.server.dal.entity;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.net.Ipv4Util;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
@@ -13,7 +11,7 @@ import lombok.ToString;
import lombok.experimental.Accessors;
import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityRuleListRes;
import java.util.Date;
@@ -55,7 +53,7 @@ public class SecurityRuleDO {
* 放行类型,reject 或 allow
* {@link SecurityRulePassTypeEnum}
*/
private SecurityRulePassTypeEnum passType;
private Integer passType;
/**
* 优先级,数字越小,优先级越高
@@ -113,7 +111,7 @@ public class SecurityRuleDO {
// 单个ip,ipv6在此步已处理,后面不需要额外判断ipv6的情况
if (rule.matches("(\\d+\\.){3}\\d+") || isIpv6) {
if (rule.equalsIgnoreCase(ip)) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
}
}
@@ -121,7 +119,7 @@ public class SecurityRuleDO {
if (rule.matches("(\\d+\\.){3}\\d+-(\\d+\\.){3}\\d+")) {
String[] ipRange = rule.split("-");
if (ipRange[0].compareTo(ip) <= 0 && ip.compareTo(ipRange[1]) <= 0) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
}
}
@@ -131,12 +129,12 @@ public class SecurityRuleDO {
Long beginIp = Ipv4Util.getBeginIpLong(netIp[0], Integer.parseInt(netIp[1]));
Long endIp = Ipv4Util.getEndIpLong(netIp[0], Integer.parseInt(netIp[1]));
if (beginIp <= ipLong && ipLong <= endIp) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
}
}
if (rule.equalsIgnoreCase("ALL") || rule.equals("0.0.0.0") || rule.equals("0.0.0.0/0")) {
return passType == SecurityRulePassTypeEnum.ALLOW ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
return SecurityRulePassTypeEnum.ALLOW.getType().equals(passType) ? SecurityRulePassTypeEnum.ALLOW : SecurityRulePassTypeEnum.DENY;
}
}
@@ -145,13 +143,9 @@ public class SecurityRuleDO {
return SecurityRulePassTypeEnum.NONE;
}
public SecurityRuleRes toRes() {
SecurityRuleRes res = new SecurityRuleRes();
public SecurityRuleListRes toListRes() {
SecurityRuleListRes res = new SecurityRuleListRes();
BeanUtil.copyProperties(this, res);
res.setPassType(this.passType.getDesc())
.setCreateTime(DateUtil.format(this.getCreateTime(), DatePattern.NORM_DATETIME_FORMAT))
.setUpdateTime(DateUtil.format(this.getUpdateTime(), DatePattern.NORM_DATETIME_FORMAT))
;
return res;
}
@@ -4,6 +4,7 @@ import cn.hutool.cache.Cache;
import cn.hutool.cache.CacheUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -17,9 +18,7 @@ import org.dromara.neutrinoproxy.server.constant.EnableStatusEnum;
import org.dromara.neutrinoproxy.server.constant.ExceptionConstant;
import org.dromara.neutrinoproxy.server.constant.SecurityRulePassTypeEnum;
import org.dromara.neutrinoproxy.server.controller.req.system.*;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupDetailRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupListRes;
import org.dromara.neutrinoproxy.server.controller.res.system.SecurityGroupUpdateEnableStatueRes;
import org.dromara.neutrinoproxy.server.controller.res.system.*;
import org.dromara.neutrinoproxy.server.dal.SecurityGroupMapper;
import org.dromara.neutrinoproxy.server.dal.SecurityRuleMapper;
import org.dromara.neutrinoproxy.server.dal.entity.SecurityGroupDO;
@@ -70,17 +69,17 @@ public class SecurityGroupService {
public PageInfo<SecurityGroupListRes> groupPage(PageQuery pageQuery, SecurityGroupListReq req) {
if (StringUtils.isNotEmpty(req.getName())) {
//描述字段为模糊查询,在应用层处理,否则sqlite不支持
//在应用层处理,否则sqlite不支持
req.setName("%" + req.getName() + "%");
}
if (StringUtils.isNotEmpty(req.getDescription())) {
//描述字段为模糊查询,在应用层处理,否则sqlite不支持
//在应用层处理,否则sqlite不支持
req.setDescription("%" + req.getDescription() + "%");
}
Page<SecurityGroupDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
List<SecurityGroupDO> list = securityGroupMapper.selectByCondition(page, req);
if (CollectionUtils.isEmpty(list)) {
PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
return PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
}
List<SecurityGroupListRes> respList = list.stream().map(SecurityGroupDO::toListRes).collect(Collectors.toList());
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
@@ -145,11 +144,32 @@ public class SecurityGroupService {
return new SecurityGroupUpdateEnableStatueRes();
}
public List<SecurityRuleDO> queryRuleListByGroupId(Integer groupId) {
return securityRuleMapper.selectList(Wrappers.lambdaQuery(SecurityRuleDO.class)
.eq(SecurityRuleDO::getGroupId, groupId)
.orderByAsc(SecurityRuleDO::getPriority)
public PageInfo<SecurityRuleListRes> rulePage(PageQuery pageQuery, SecurityRuleListReq req) {
if (StringUtils.isNotEmpty(req.getName())) {
//在应用层处理,否则sqlite不支持
req.setName("%" + req.getName() + "%");
}
if (StringUtils.isNotEmpty(req.getDescription())) {
//在应用层处理,否则sqlite不支持
req.setDescription("%" + req.getDescription() + "%");
}
Page<SecurityRuleDO> page = new Page<>(pageQuery.getCurrent(), pageQuery.getSize());
List<SecurityRuleDO> list = securityRuleMapper.selectByCondition(page, req);
if (CollectionUtils.isEmpty(list)) {
return PageInfo.of(null, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
}
List<SecurityRuleListRes> respList = list.stream().map(SecurityRuleDO::toListRes).collect(Collectors.toList());
return PageInfo.of(respList, page.getTotal(), pageQuery.getCurrent(), pageQuery.getSize());
}
public List<SecurityRuleListRes> ruleList(SecurityRuleListReq req) {
List<SecurityRuleDO> list = securityRuleMapper.selectList(new LambdaQueryWrapper<SecurityRuleDO>()
.eq(null != req.getGroupId(), SecurityRuleDO::getGroupId, req.getGroupId())
);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
return list.stream().map(SecurityRuleDO::toListRes).collect(Collectors.toList());
}
public void createRule(SecurityRuleCreateReq req) {
@@ -175,12 +195,13 @@ public class SecurityGroupService {
clearCache();
}
public void setRuleStatus(Integer ruleId, EnableStatusEnum statusEnum) {
SecurityRuleDO ruleDO = securityRuleMapper.selectById(ruleId);
ruleDO.setEnable(statusEnum.getStatus());
ruleDO.setUpdateTime(new Date());
securityRuleMapper.updateById(ruleDO);
public SecurityRuleUpdateEnableStatueRes updateRuleEnableStatueReq(SecurityRuleUpdateEnableStatueReq req) {
SecurityRuleDO ruleDO = securityRuleMapper.selectById(req.getId());
ParamCheckUtil.checkNotNull(ruleDO, ExceptionConstant.SECURITY_RULE_NOT_EXIST);
securityRuleMapper.updateEnableStatus(req.getId(), req.getEnable(), new Date());
clearCache();
return new SecurityRuleUpdateEnableStatueRes();
}
/**
@@ -235,7 +256,7 @@ public class SecurityGroupService {
// 当前IP没有匹配到任何一条规则,则使用安全组默认规则
if (allow == null) {
allow = groupDO.getDefaultPassType() == SecurityRulePassTypeEnum.ALLOW;
allow = SecurityRulePassTypeEnum.ALLOW.getType().equals(groupDO.getDefaultPassType());
log.debug("[SecurityGroup] ip:{} groupId{} use security group default strategy:{}", ip, groupId, allow ? "allow" : "reject");
}
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.neutrinoproxy.server.dal.SecurityRuleMapper">
<select id="selectByCondition" resultType="org.dromara.neutrinoproxy.server.dal.entity.SecurityRuleDO">
SELECT sr.* from security_rule sr
<where>
<if test="req.groupId != null">
AND sr.group_id = ${req.groupId}
</if>
<if test="req.name != null and req.name != '' ">
AND sr.name like #{req.name}
</if>
<if test="req.description != null and req.description != '' ">
AND sr.description like #{req.description}
</if>
<if test="req.passType != null">
AND sr.pass_type like #{req.passType}
</if>
<if test="req.enable != null">
AND sr.enable like #{req.enable}
</if>
</where>
order by sr.id DESC
</select>
</mapper>
@@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` VARCHAR(255),
`user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL,
`default_pass_type` VARCHAR(20) NOT NULL,
`default_pass_type` INTEGER NOT NULL,
`create_time` TIMESTAMP NOT NULL,
`update_time` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`)
@@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` VARCHAR(20) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`rule` text NOT NULL,
`pass_type` VARCHAR(20) NOT NULL,
`pass_type` INTEGER NOT NULL,
`priority` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL,
@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` VARCHAR(255),
`user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL,
`default_pass_type` VARCHAR(20) NOT NULL,
`default_pass_type` INTEGER NOT NULL,
`create_time` TIMESTAMP NOT NULL,
`update_time` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`)
@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` VARCHAR(20) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`rule` text NOT NULL,
`pass_type` VARCHAR(20) NOT NULL,
`pass_type` INTEGER NOT NULL,
`priority` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL,
`enable` INTEGER NOT NULL,
@@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` varchar(255) COMMENT '安全组描述',
`user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`default_pass_type` varchar(20) NOT NULL COMMENT '默认放行类型',
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` varchar(20) NOT NULL COMMENT '规则名称',
`description` varchar(255) NOT NULL COMMENT '规则描述',
`rule` text NOT NULL COMMENT '规则内容',
`pass_type` varchar(20) NOT NULL COMMENT '放行类型',
`pass_type` int NOT NULL COMMENT '放行类型',
`priority` int(1) NOT NULL COMMENT '优先级',
`user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
@@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` varchar(255) COMMENT '安全组描述',
`user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`default_pass_type` varchar(20) NOT NULL COMMENT '默认放行类型',
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` varchar(20) NOT NULL COMMENT '规则名称',
`description` varchar(255) NOT NULL COMMENT '规则描述',
`rule` text NOT NULL COMMENT '规则内容',
`pass_type` varchar(20) NOT NULL COMMENT '放行类型',
`pass_type` int NOT NULL COMMENT '放行类型',
`priority` int(1) NOT NULL COMMENT '优先级',
`user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS `security_group` (
`description` varchar(255) COMMENT '安全组描述',
`user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',
`default_pass_type` varchar(20) NOT NULL COMMENT '默认放行类型',
`default_pass_type` int NOT NULL COMMENT '默认放行类型',
`create_time` datetime(3) NOT NULL COMMENT '创建时间',
`update_time` datetime(3) NOT NULL COMMENT '更新时间',
PRIMARY KEY (`id`)
@@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `security_rule` (
`name` varchar(20) NOT NULL COMMENT '规则名称',
`description` varchar(255) NOT NULL COMMENT '规则描述',
`rule` text NOT NULL COMMENT '规则内容',
`pass_type` varchar(20) NOT NULL COMMENT '放行类型',
`pass_type`int NOT NULL COMMENT '放行类型',
`priority` int(1) NOT NULL COMMENT '优先级',
`user_id` int NOT NULL COMMENT '用户ID',
`enable` int NOT NULL COMMENT '是否启用(1、启用 2、禁用)',