CN-1016 Filter更好统计接口并增加filter字典数据

This commit is contained in:
hyx
2023-06-05 16:40:25 +08:00
parent 2c227c7685
commit f5cb5c94a9
4 changed files with 96 additions and 173 deletions

View File

@@ -38,6 +38,7 @@ export const api = {
knowledgeBase: BASE_CONFIG.apiVersion + '/knowledgeBase', knowledgeBase: BASE_CONFIG.apiVersion + '/knowledgeBase',
knowledgeBaseList: BASE_CONFIG.apiVersion + '/knowledgeBase/list', knowledgeBaseList: BASE_CONFIG.apiVersion + '/knowledgeBase/list',
knowledgeBaseEnable: BASE_CONFIG.apiVersion + '/knowledgeBase/status', knowledgeBaseEnable: BASE_CONFIG.apiVersion + '/knowledgeBase/status',
knowledgeBaseStatistics: BASE_CONFIG.apiVersion + '/knowledgeBase/statistics',
// 报告相关 // 报告相关
reportJob: '/report/job', reportJob: '/report/job',

View File

@@ -375,6 +375,34 @@ export const knowledgeBaseSource = [
name: 'ASN', name: 'ASN',
value: 'cn_ip_asn_built_in' value: 'cn_ip_asn_built_in'
}, },
{
name: 'FQDN Whois',
value: 'cn_fqdn_who_is_built_in'
},
{
name: 'FQDN ICP',
value: 'cn_fqdn_icp_built_in'
},
{
name: 'APP Category',
value: 'cn_app_category_built_in'
},
{
name: 'DNS Server Info',
value: 'cn_dns_server_info_built_in'
},
{
name: 'Link Direction',
value: 'cn_link_direction_built_in'
},
{
name: 'Internal IP',
value: 'cn_internal_ip_built_in'
},
{
name: 'IDC Renter',
value: 'cn_idc_renter_built_in'
},
{ {
name: 'Psiphon3', name: 'Psiphon3',
value: 'cn_psiphon3_ip' value: 'cn_psiphon3_ip'

View File

@@ -171,7 +171,7 @@ export default {
} }
this.clearList() this.clearList()
this.search(params) this.search(params)
this.$refs.knowledgeFilter.reloadFilter(params) this.$refs.knowledgeFilter.reloadFilter()
}, },
handleClose () { handleClose () {
this.showConfirmDialog = false this.showConfirmDialog = false

View File

@@ -4,20 +4,18 @@
{{ $t('knowledge.filters') }} {{ $t('knowledge.filters') }}
</div> </div>
<div class="knowledge-filter"> <div class="knowledge-filter">
<div class="filter__header" @click="filterTypeData.collapse = !filterTypeData.collapse"> <div class="filter__header" @click="filterCategoryData.collapse = !filterCategoryData.collapse">
<span class="new-knowledge-filter-header-title">{{filterTypeData.title}}</span> <span class="new-knowledge-filter-header-title">{{filterCategoryData.title}}</span>
<i class="el-icon-arrow-right new-knowledge-filter-icon" :class="{ 'arrow-rotate': !filterTypeData.collapse }"></i> <i class="el-icon-arrow-right new-knowledge-filter-icon" :class="{ 'arrow-rotate': !filterCategoryData.collapse }"></i>
</div> </div>
<el-collapse-transition> <el-collapse-transition>
<div class="filter__body"> <div class="filter__body" v-if="!filterCategoryData.collapse">
<el-tree <el-tree
ref="knowledgeTreeTypeFilter" ref="knowledgeTreeTypeFilter"
v-if="!filterTypeData.collapse" :data="filterCategoryData.data"
:data="filterTypeData.data"
show-checkbox show-checkbox
node-key="id" node-key="id"
default-expand-all default-expand-all
:default-checked-keys="[1,2,3]"
:render-content="renderContent" :render-content="renderContent"
@check="(data,checkinfo)=>handleCheckedItemChange(data,checkinfo)" @check="(data,checkinfo)=>handleCheckedItemChange(data,checkinfo)"
> >
@@ -31,15 +29,13 @@
<i class="el-icon-arrow-right new-knowledge-filter-icon" :class="{ 'arrow-rotate': !filterStatusData.collapse }"></i> <i class="el-icon-arrow-right new-knowledge-filter-icon" :class="{ 'arrow-rotate': !filterStatusData.collapse }"></i>
</div> </div>
<el-collapse-transition> <el-collapse-transition>
<div class="filter__body"> <div class="filter__body" v-if="!filterStatusData.collapse">
<el-tree <el-tree
ref="knowledgeTreeStatusFilter" ref="knowledgeTreeStatusFilter"
v-if="!filterStatusData.collapse"
:data="filterStatusData.data" :data="filterStatusData.data"
show-checkbox show-checkbox
node-key="id" node-key="id"
default-expand-all default-expand-all
:default-checked-keys="[1,2,3]"
:render-content="renderContent" :render-content="renderContent"
@check="(data,checkinfo)=>handleCheckedItemChange(data,checkinfo)" @check="(data,checkinfo)=>handleCheckedItemChange(data,checkinfo)"
> >
@@ -53,7 +49,7 @@
<script> <script>
import { api } from '@/utils/api' import { api } from '@/utils/api'
import { get } from '@/utils/http' import { get } from '@/utils/http'
import { knowledgeCategoryValue, knowledgeSourceValue } from '@/utils/constants' import { knowledgeBaseCategory, knowledgeBaseSource } from '@/utils/constants'
export default { export default {
name: 'KnowledgeFilter', name: 'KnowledgeFilter',
@@ -62,28 +58,28 @@ export default {
}, },
data () { data () {
return { return {
url: api.knowledgeBaseList, url: api.knowledgeBaseStatistics,
checkAll: true, checkAll: true,
isIndeterminateModel: false, isIndeterminateModel: false,
filterTypeData: { filterCategoryData: {
id: 0, id: 0,
title: this.$t('knowledge.type'), title: this.$t('knowledge.type'),
collapse: false, collapse: false,
value: [],
data: [] data: []
}, },
filterStatusData: { filterStatusData: {
id: 1, id: 1,
title: this.$t('knowledge.status'), title: this.$t('knowledge.status'),
collapse: false, collapse: false,
value: [],
data: [] data: []
}, },
defaultProps: { defaultProps: {
children: 'children', children: 'children',
label: 'label' label: 'label'
}, },
allTableData: [] typeData: [],
statusData: [],
defaultCheckedCategory: []
} }
}, },
watch: { watch: {
@@ -102,7 +98,7 @@ export default {
} else { } else {
typeCheckedNodes = this.$refs.knowledgeTreeTypeFilter.getCheckedNodes() typeCheckedNodes = this.$refs.knowledgeTreeTypeFilter.getCheckedNodes()
} }
let typeHalfCheckedNodes = checkinfo.halfCheckedNodes const typeHalfCheckedNodes = checkinfo.halfCheckedNodes
typeCheckedNodes = typeCheckedNodes.concat(typeHalfCheckedNodes) typeCheckedNodes = typeCheckedNodes.concat(typeHalfCheckedNodes)
let statusCheckedNodes = [] let statusCheckedNodes = []
if (this.$refs.knowledgeTreeStatusFilter instanceof Array) { if (this.$refs.knowledgeTreeStatusFilter instanceof Array) {
@@ -114,7 +110,7 @@ export default {
const statusCheckedLen = statusCheckedNodes.length const statusCheckedLen = statusCheckedNodes.length
let params = {} let params = {}
let allSourceNum = 0 let allSourceNum = 0
this.filterTypeData.data.forEach(item => { this.filterCategoryData.data.forEach(item => {
allSourceNum = allSourceNum + item.children.length allSourceNum = allSourceNum + item.children.length
}) })
if (typeCheckedLen === 0 || statusCheckedLen === 0) { if (typeCheckedLen === 0 || statusCheckedLen === 0) {
@@ -129,7 +125,7 @@ export default {
sources.push(val.value) sources.push(val.value)
} }
}) })
if (!(categorys.length === this.filterTypeData.data.length && sources.length === allSourceNum)) { if (!(categorys.length === this.filterCategoryData.data.length && sources.length === allSourceNum)) {
params = { params = {
category: categorys.toString(), category: categorys.toString(),
source: sources.toString() source: sources.toString()
@@ -151,172 +147,70 @@ export default {
} }
get(this.url, searchParams).then(response => { get(this.url, searchParams).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.allTableData = response.data.list this.typeData = response.data.categoryList
this.statusData = response.data.statusList
} else { } else {
console.error(response) console.error(response)
} }
}).finally(() => { }).finally(() => {
this.initAllData() this.initTypeData()
this.initStatusData() this.initStatusData()
const self = this
this.$nextTick(() => {
self.$refs.knowledgeTreeTypeFilter.setCheckedKeys(this.defaultCheckedCategory)
})
this.$nextTick(() => {
self.$refs.knowledgeTreeStatusFilter.setCheckedKeys([0, 1])
})
}) })
}, },
initAllData () { initTypeData () {
let webSketchCount = 0 this.typeData.forEach((type, typeIndex) => {
let fqdnCategoryCount = 0 const categoryLabel = knowledgeBaseCategory.find(t => t.value === type.name)
let iocMalwareCount = 0 const categoryId = typeIndex
let iocDarkwebCount = 0 const category = {
let ipLocationCount = 0 id: categoryId,
let asnCount = 0 label: categoryLabel ? categoryLabel.name : type.name,
value: type.name,
let aiTaggingCount = 0 count: type.count,
let psiphon3Count = 0 type: 0,
children: []
let userDefinedCount = 0
let ipCount = 0
let domainCount = 0
let appCount = 0
const builtInCount = 0
this.allTableData.forEach(data => {
if (data.category === knowledgeCategoryValue.webSketch) {
webSketchCount++
} else if (data.category === knowledgeCategoryValue.aiTagging) {
aiTaggingCount++
} else if (data.category === knowledgeCategoryValue.userDefined) {
userDefinedCount++
} }
this.defaultCheckedCategory.push(categoryId)
if (data.source === knowledgeSourceValue.fqdnCategory) { this.filterCategoryData.data.push(category)
fqdnCategoryCount++ const sourceList = type.sourceList
} else if (data.source === knowledgeSourceValue.iocMalware) { sourceList.forEach((item, sourceIndex) => {
iocMalwareCount++ const sourceLabel = knowledgeBaseSource.find(t => t.value === item.name)
} else if (data.source === knowledgeSourceValue.iocDarkweb) { const source = {
iocDarkwebCount++ id: Number(typeIndex + '' + sourceIndex),
} else if (data.source === knowledgeSourceValue.ipLocation) { label: sourceLabel ? sourceLabel.name : item.name,
ipLocationCount++ value: item.name,
} else if (data.source === knowledgeSourceValue.asn) { count: item.count,
asnCount++ type: 1
} else if (data.source === knowledgeSourceValue.psiphon3) {
psiphon3Count++
} else if (data.source === knowledgeSourceValue.ipTag) {
ipCount++
} else if (data.source === knowledgeSourceValue.domainTag) {
domainCount++
} else if (data.source === knowledgeSourceValue.appTag) {
appCount++
} }
category.children.push(source)
})
}) })
this.filterTypeData.data = [
{
id: 1,
label: 'WebSketch',
value: knowledgeCategoryValue.webSketch,
count: webSketchCount,
type: 0,
children: [{
id: 11,
label: 'FQDN Category',
value: knowledgeSourceValue.fqdnCategory,
count: fqdnCategoryCount,
type: 1
}, {
id: 12,
label: 'Ioc Malware',
value: knowledgeSourceValue.iocMalware,
count: iocMalwareCount,
type: 1
}, {
id: 13,
label: 'Ioc Darkweb',
value: knowledgeSourceValue.iocDarkweb,
count: iocDarkwebCount,
type: 1
}, {
id: 14,
label: 'IP Location',
value: knowledgeSourceValue.ipLocation,
count: ipLocationCount,
type: 1
}, {
id: 15,
label: 'ASN',
value: knowledgeSourceValue.asn,
count: asnCount,
type: 1
}
]
},
{
id: 2,
label: 'AI Tagging',
value: knowledgeCategoryValue.aiTagging,
count: aiTaggingCount,
type: 0,
children: [
{
id: 21,
label: 'Psiphon3',
value: knowledgeSourceValue.psiphon3,
count: psiphon3Count,
type: 1
}
]
},
{
id: 3,
label: 'User-defined',
value: knowledgeCategoryValue.userDefined,
count: userDefinedCount,
type: 0,
children: [
{
id: 31,
label: 'IP Tag',
value: knowledgeSourceValue.ipTag,
count: ipCount,
type: 1
}, {
id: 32,
label: 'Domain Tag',
value: knowledgeSourceValue.domainTag,
count: domainCount,
type: 1
}, {
id: 33,
label: 'APP Tag',
value: knowledgeSourceValue.appTag,
count: appCount,
type: 1
}
]
}
]
}, },
initStatusData () { initStatusData () {
let enableCount = 0 const enableCount = 0
let disableCount = 0 const disableCount = 0
this.allTableData.forEach(data => { this.statusData.forEach((data, index) => {
if (data.status === 0) { this.filterStatusData.data.push({
disableCount++ id: index,
} else { label: data.status === 1 ? 'enabled' : 'disable',
enableCount++ value: data.status,
} count: data.count,
type: 0
})
}) })
this.filterStatusData.data = [
{ id: 1, label: 'enabled', value: 1, count: enableCount, type: 0 },
{ id: 2, label: 'disable', value: 0, count: disableCount, type: 0 }
]
}, },
reloadFilter (params) { reloadFilter (params) {
this.getAllTableData(params) this.getAllTableData(params)
} }
}, },
mounted () { mounted () {
let params = {} this.getAllTableData()
params = {
name: this.keyWord
}
this.getAllTableData(params)
}, },
computed: { computed: {
} }