feat: 限制 WAF 空值提交

This commit is contained in:
zhengkunwang223 2023-03-08 15:21:36 +08:00 committed by zhengkunwang223
parent 0d22ae6dc3
commit d72bb22db7
3 changed files with 19 additions and 7 deletions

View file

@ -1068,7 +1068,7 @@ export default {
notSecurity: '(not safe)',
encryptHelper:
"Let's Encrypt has a frequency limit for issuing certificates, but it is sufficient to meet normal needs. Too frequent operations will cause issuance failure. For specific restrictions, please see <a target='_blank' href='https://letsencrypt.org/zh-cn/docs /rate-limits/'>official document</a> ",
ipValue: 'IP value',
ipValue: 'Value',
ext: 'file extension',
wafInputHelper: 'Input data by line, one line',
data: 'data',

View file

@ -1072,7 +1072,7 @@ export default {
notSecurity: '不安全',
encryptHelper:
"Let's Encrypt 签发证书有频率限制,但足以满足正常需求,过于频繁操作会导致签发失败。具体限制请看 <a target=“_blank” href='https://letsencrypt.org/zh-cn/docs/rate-limits/'>官方文档</a> ",
ipValue: 'IP值',
ipValue: '值',
ext: '文件扩展名',
wafInputHelper: '按行输入数据一行一个',
data: '数据',

View file

@ -18,7 +18,7 @@
{{ $t('commons.button.add') }}
</el-button>
</template>
<el-table-column label="IP" prop="ip"></el-table-column>
<el-table-column :label="$t('website.ipValue')" prop="ip"></el-table-column>
<el-table-column :label="$t('commons.table.operate')">
<template #default="{ $index }">
<el-button link type="primary" @click="removeIp($index)">
@ -116,18 +116,30 @@ const openCreate = () => {
if (ipArray.length == 0) {
return;
}
let newIpArray = [];
ipArray.forEach((ip: string) => {
const newIp = ip.replace(/(^\s*)|(\s*$)/g, '');
if (newIp != '') {
newIpArray.push(newIp);
}
});
if (newIpArray.length == 0) {
return;
}
if (req.value.rule.indexOf('ip') > -1) {
for (const id in ipArray) {
if (checkIp(ipArray[id])) {
for (const id in newIpArray) {
if (checkIp(newIpArray[id])) {
MsgError(i18n.global.t('commons.rule.ipErr', [ipArray[id]]));
return;
}
}
}
data.value.forEach((d) => {
ipArray.push(d.ip);
newIpArray.push(d.ip);
});
submit(ipArray);
if (newIpArray.length > 0) {
submit(newIpArray);
}
};
const submit = async (ipList: string[]) => {