feat: 增加cookie校验等

pull/67/head
zhengkunwang223 2022-12-06 17:20:27 +08:00 committed by zhengkunwang223
parent 3f52c079af
commit a323f87ba0
4 changed files with 52 additions and 12 deletions

View File

@ -850,7 +850,6 @@ export default {
default: '', default: '',
deleteHelper: '', deleteHelper: '',
toApp: '', toApp: '',
enableCC: 'CC',
cycle: '', cycle: '',
frequency: '', frequency: '',
ccHelper: '{0} URL {1} ,CC,IP', ccHelper: '{0} URL {1} ,CC,IP',
@ -859,6 +858,8 @@ export default {
mustSave: '', mustSave: '',
fileExt: '', fileExt: '',
fileExtBlock: '', fileExtBlock: '',
value: '值',
enable: '',
}, },
nginx: { nginx: {
serverNamesHashBucketSizeHelper: 'hash', serverNamesHashBucketSizeHelper: 'hash',

View File

@ -9,7 +9,7 @@
:rules="rules" :rules="rules"
:loading="loading" :loading="loading"
> >
<el-form-item prop="enable" :label="$t('website.enableCC')"> <el-form-item prop="enable" :label="$t('website.enable')">
<el-switch v-model="form.enable" @change="updateEnable"></el-switch> <el-switch v-model="form.enable" @change="updateEnable"></el-switch>
</el-form-item> </el-form-item>
<el-form-item prop="cycle" :label="$t('website.cycle')"> <el-form-item prop="cycle" :label="$t('website.cycle')">

View File

@ -12,13 +12,21 @@
<el-tab-pane :label="'文件扩展名黑名单'" name="FileBlockList"> <el-tab-pane :label="'文件扩展名黑名单'" name="FileBlockList">
<FileBlockList :id="id" v-if="index == 'FileBlockList'"></FileBlockList> <FileBlockList :id="id" v-if="index == 'FileBlockList'"></FileBlockList>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'URL黑名单'" name="urlBlockList">
<UrlList :id="id" :rule="'url'" v-if="index == 'urlBlockList'"></UrlList>
</el-tab-pane>
<el-tab-pane :label="'URL白名单'" name="urlWhiteList"> <el-tab-pane :label="'URL白名单'" name="urlWhiteList">
<UrlList :id="id" :rule="'whiteurl'" v-if="index == 'urlWhiteList'"></UrlList> <ValueList :id="id" :rule="'whiteurl'" v-if="index == 'urlWhiteList'"></ValueList>
</el-tab-pane>
<el-tab-pane :label="'URL黑名单'" name="urlBlockList">
<ValueList :id="id" :rule="'url'" v-if="index == 'urlBlockList'"></ValueList>
</el-tab-pane>
<el-tab-pane :label="'GET参数(args)校验'" name="args">
<ValueList :id="id" :rule="'args'" v-if="index == 'args'"></ValueList>
</el-tab-pane>
<el-tab-pane :label="'POST参数校验'" name="post">
<ValueList :id="id" :rule="'post'" v-if="index == 'post'"></ValueList>
</el-tab-pane>
<el-tab-pane :label="'Cookie黑名单'" name="cookie">
<ValueList :id="id" :rule="'cookie'" v-if="index == 'cookie'"></ValueList>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="'禁止爬虫'"></el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -26,7 +34,7 @@ import { computed, ref } from 'vue';
import CCDeny from './ccdeny/index.vue'; import CCDeny from './ccdeny/index.vue';
import IpList from './ip-list/index.vue'; import IpList from './ip-list/index.vue';
import FileBlockList from './file-block-list/index.vue'; import FileBlockList from './file-block-list/index.vue';
import UrlList from './url-list/index.vue'; import ValueList from './value-list/index.vue';
const props = defineProps({ const props = defineProps({
id: { id: {

View File

@ -1,13 +1,16 @@
<template> <template>
<el-row> <el-row>
<el-col :span="10" :offset="2"> <el-col :span="10" :offset="2">
<el-form-item prop="enable" :label="$t('website.enable')">
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch>
</el-form-item>
<ComplexTable :data="data" v-loading="loading"> <ComplexTable :data="data" v-loading="loading">
<template #toolbar> <template #toolbar>
<el-button type="primary" icon="Plus" @click="openCreate"> <el-button type="primary" icon="Plus" @click="openCreate">
{{ $t('commons.button.add') }} {{ $t('commons.button.add') }}
</el-button> </el-button>
</template> </template>
<el-table-column :label="'URL'"> <el-table-column :label="$t('website.value')">
<template #default="{ row }"> <template #default="{ row }">
<fu-read-write-switch :data="row.value" v-model="row.edit" write-trigger="onDblclick"> <fu-read-write-switch :data="row.value" v-model="row.edit" write-trigger="onDblclick">
<el-form-item :error="row.error"> <el-form-item :error="row.error">
@ -21,7 +24,7 @@
</fu-read-write-switch> </fu-read-write-switch>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('commons.table.operate')"> <el-table-column :label="$t('commons.table.operate')" width="100px">
<template #default="{ $index }"> <template #default="{ $index }">
<el-button link type="primary" @click="remove($index)"> <el-button link type="primary" @click="remove($index)">
{{ $t('commons.button.delete') }} {{ $t('commons.button.delete') }}
@ -40,7 +43,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { WebSite } from '@/api/interface/website'; import { WebSite } from '@/api/interface/website';
import { GetWafConfig } from '@/api/modules/website'; import { GetWafConfig, UpdateWafEnable } from '@/api/modules/website';
import { computed, onMounted, reactive, ref } from 'vue'; import { computed, onMounted, reactive, ref } from 'vue';
import ComplexTable from '@/components/complex-table/index.vue'; import ComplexTable from '@/components/complex-table/index.vue';
import { SaveFileContent } from '@/api/modules/files'; import { SaveFileContent } from '@/api/modules/files';
@ -75,13 +78,18 @@ let fileUpdate = reactive({
path: '', path: '',
content: '', content: '',
}); });
let enableUpdate = ref<WebSite.WafUpdate>({
websiteId: 0,
key: '$UrlDeny',
enable: false,
});
const get = async () => { const get = async () => {
data.value = []; data.value = [];
loading.value = true; loading.value = true;
const res = await GetWafConfig(req.value); const res = await GetWafConfig(req.value);
loading.value = false; loading.value = false;
enableUpdate.value.enable = res.data.enable;
if (res.data.content != '') { if (res.data.content != '') {
const urlList = res.data.content.split('\n'); const urlList = res.data.content.split('\n');
urlList.forEach((value) => { urlList.forEach((value) => {
@ -106,6 +114,13 @@ const openCreate = () => {
data.value.unshift({ value: '', edit: true, error: '' }); data.value.unshift({ value: '', edit: true, error: '' });
}; };
const updateEnable = async (enable: boolean) => {
enableUpdate.value.enable = enable;
loading.value = true;
await UpdateWafEnable(enableUpdate.value);
loading.value = false;
};
const submit = async () => { const submit = async () => {
let urlList = ''; let urlList = '';
data.value.forEach((row) => { data.value.forEach((row) => {
@ -126,9 +141,25 @@ const submit = async () => {
}); });
}; };
const getKey = (rule: string) => {
switch (rule) {
case 'url':
return '$UrlDeny';
case 'whiteurl':
return '$whiteModule';
case 'post':
return '$postMatch';
case 'url':
return '$UrlDeny';
case 'url':
return '$UrlDeny';
}
};
onMounted(() => { onMounted(() => {
req.value.websiteId = id.value; req.value.websiteId = id.value;
req.value.rule = rule.value; req.value.rule = rule.value;
enableUpdate.value.key = getKey(rule.value);
get(); get();
}); });
</script> </script>