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)', notSecurity: '(not safe)',
encryptHelper: 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> ", "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', ext: 'file extension',
wafInputHelper: 'Input data by line, one line', wafInputHelper: 'Input data by line, one line',
data: 'data', data: 'data',

View file

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

View file

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