fix: 修复detection问题

This commit is contained in:
chenjinsong
2022-03-03 23:21:33 +08:00
parent ed373c1c85
commit c2c4cfc482
9 changed files with 187 additions and 126 deletions

View File

@@ -170,6 +170,15 @@ export const detectionPageType = {
performanceEvent: 'performanceEvent' performanceEvent: 'performanceEvent'
} }
export const dnsServerRole = {
RTDNS: 'RTDNS',
TLDNS: 'TLDNS',
OPRDNS: 'OPRDNS',
ADNS: 'ADNS',
SBDNS: 'SBDNS',
RTDNSM: 'RTDNSM'
}
export const chartColor = ['#5370C6', '#90CC74', '#FAC858', '#EE6666', export const chartColor = ['#5370C6', '#90CC74', '#FAC858', '#EE6666',
'#73BFDE', '#3BA172', '#FC8452', '#9960B4', '#73BFDE', '#3BA172', '#FC8452', '#9960B4',
'#E97CCC', '#FEA69E', '#0F8AB2', '#57CBAC', '#E97CCC', '#FEA69E', '#0F8AB2', '#57CBAC',

View File

@@ -46,6 +46,7 @@
import ChartHeader from './ChartHeader' import ChartHeader from './ChartHeader'
import Chart from '@/views/charts/Chart' import Chart from '@/views/charts/Chart'
import testData from './charts/testData' import testData from './charts/testData'
import { dnsServerRole } from '@/utils/constants'
import { import {
isEcharts, isEcharts,
isSingleValue, isSingleValue,
@@ -189,7 +190,11 @@ export default {
...this.entity, ...this.entity,
...extraParams ...extraParams
} }
// 默认参数特殊处理
const requestUrl = url || (chartParams && chartParams.url) const requestUrl = url || (chartParams && chartParams.url)
if (requestUrl && requestUrl.indexOf('dnsServerRole') > -1) {
this.queryParams.dnsServerRole = dnsServerRole.RTDNS
}
if (requestUrl) { if (requestUrl) {
get(replaceUrlPlaceholder(requestUrl, this.queryParams)).then(response => { get(replaceUrlPlaceholder(requestUrl, this.queryParams)).then(response => {
// if (this.chartInfo.type === 23 && testData) { // if (this.chartInfo.type === 23 && testData) {
@@ -197,6 +202,27 @@ export default {
// } else if (this.chartInfo.type === 24 && testData) { // } else if (this.chartInfo.type === 24 && testData) {
// response = testData.data2 // response = testData.data2
// } // }
if (this.chartInfo.type === 3) {
response = {
code: 200,
data: {
result: [
{
"dnsServerRole":"TLDNS",
"ipLocationCountry":"China",
"ipLocationId":"CN",
"count":161
},
{
"dnsServerRole":"RTDNS",
"ipLocationCountry":"Japan",
"ipLocationId":"JP",
"count":222
}
]
}
}
}
if (response.code === 200) { if (response.code === 200) {
if (Array.isArray(response.data.result)) { if (Array.isArray(response.data.result)) {
response.data.result.forEach(item => { response.data.result.forEach(item => {

View File

@@ -6,10 +6,9 @@
<script> <script>
import * as am4Core from '@amcharts/amcharts4/core' import * as am4Core from '@amcharts/amcharts4/core'
import * as am4Maps from '@amcharts/amcharts4/maps' import * as am4Maps from '@amcharts/amcharts4/maps'
import { getGeoData, replaceUrlPlaceholder } from '@/utils/tools' import { getGeoData, replaceUrlPlaceholder, getCapitalGeo } from '@/utils/tools'
import { storageKey } from '@/utils/constants' import { storageKey, dnsServerRole } from '@/utils/constants'
import { isMapBlock, isMapPoint } from './tools'
import { isMapBlock } from './tools'
import unitConvert, { valueToRangeValue } from '@/utils/unit-convert' import unitConvert, { valueToRangeValue } from '@/utils/unit-convert'
import { HeatLegend } from '@/components/amcharts/heatLegend' import { HeatLegend } from '@/components/amcharts/heatLegend'
import { getData } from '@/utils/api' import { getData } from '@/utils/api'
@@ -72,6 +71,7 @@ export default {
}) })
}, },
loadAm4ChartMap (polygonSeries, country, chartData) { loadAm4ChartMap (polygonSeries, country, chartData) {
// chartData不为空是下钻
if (chartData) { if (chartData) {
this.$emit('showLoading', true) this.$emit('showLoading', true)
} }
@@ -111,8 +111,9 @@ export default {
showValue: (r.value || r.value === 0) ? valueToRangeValue(r.value, chartParams.unitType).join(' ') : '' showValue: (r.value || r.value === 0) ? valueToRangeValue(r.value, chartParams.unitType).join(' ') : ''
})) }))
!this.$_.isEmpty(seriesData) && (polygonSeries.data = [...seriesData]) !this.$_.isEmpty(seriesData) && (polygonSeries.data = [...seriesData])
// 数据全为0的情况legend只显示1个颜色
const sorted = seriesData.sort((a, b) => b.value - a.value) const sorted = seriesData.sort((a, b) => b.value - a.value)
const allZero = this.$_.isEmpty(sorted) || Number(sorted[0].value) === 0 // 数据全为0的情况legend只显示1个颜色 const allZero = this.$_.isEmpty(sorted) || Number(sorted[0].value) === 0
polygonSeries.heatRules.push({ polygonSeries.heatRules.push({
property: 'fill', property: 'fill',
@@ -142,6 +143,56 @@ export default {
heatLegend.valueAxis.renderer.labels.template.adapter.add('text', function (labelText) { heatLegend.valueAxis.renderer.labels.template.adapter.add('text', function (labelText) {
return '' return ''
}) })
} else if (data && this.isMapPoint) {
const seriesData = []
data.forEach(d => {
seriesData.push({
id: d.ipLocationId,
count: d.count,
dnsServerRole: d.dnsServerRole,
location: d.ipLocationCity || d.ipLocationProvince || d.ipLocationCountry,
desc: this.$t(this.dnsTypeI18n(d.dnsServerRole)),
color: this.circleColor[d.dnsServerRole].background,
border: this.circleColor[d.dnsServerRole].border
})
})
console.info(seriesData)
const imageSeries = this.myChart.series.push(new am4Maps.MapImageSeries())
imageSeries.data = seriesData
imageSeries.dataFields.value = 'count'
const imageTemplate = imageSeries.mapImages.template
imageTemplate.nonScaling = true
imageTemplate.adapter.add('latitude', function (latitude, target) {
const polygon = polygonSeries.getPolygonById(target.dataItem.dataContext.id)
if (polygon) {
return polygon.visualLatitude
}
return latitude
})
imageTemplate.adapter.add('longitude', function (longitude, target) {
const polygon = polygonSeries.getPolygonById(target.dataItem.dataContext.id)
if (polygon) {
return polygon.visualLongitude
}
return longitude
})
const circle = imageTemplate.createChild(am4Core.Circle)
circle.propertyFields.fill = 'color'
circle.propertyFields.stroke = 'border'
circle.strokeWidth = 1
circle.tooltipText = '[bold]{location}[/]\n{desc}: {count}'
imageSeries.heatRules.push({
target: circle,
property: 'radius',
min: 4,
max: 30,
dataField: 'value'
})
} }
} catch (e) { } catch (e) {
console.error(e) console.error(e)
@@ -161,6 +212,37 @@ export default {
this.myChart.goHome() this.myChart.goHome()
}) })
}, },
dnsTypeI18n (role) {
let i18n = ''
switch (role) {
case dnsServerRole.RTDNS: {
i18n = 'dns.rootDomainServers'
break
}
case dnsServerRole.TLDNS: {
i18n = 'dns.topLevelDomainServers'
break
}
case dnsServerRole.OPRDNS: {
i18n = 'dns.publicRecursiveDomainServers'
break
}
case dnsServerRole.ADNS: {
i18n = 'dns.authoritativeDomainServers'
break
}
case dnsServerRole.SBDNS: {
i18n = 'dns.selfBuiltDomainServers'
break
}
case dnsServerRole.RTDNSM: {
i18n = 'RTDNSM'
break
}
default: break
}
return i18n
},
generateTooltipHTML () { generateTooltipHTML () {
return ` return `
<div class="map-tooltip" style="padding-bottom: 10px;"> <div class="map-tooltip" style="padding-bottom: 10px;">
@@ -206,8 +288,35 @@ export default {
} }
}, },
setup (props) { setup (props) {
const circleColor = {}
circleColor[dnsServerRole.RTDNS] = {
background: '#C0DEFE',
border: '#478AD5'
}
circleColor[dnsServerRole.TLDNS] = {
background: '#DBCFFA',
border: '#AA8CF2'
}
circleColor[dnsServerRole.ADNS] = {
background: '#A0E8E0',
border: '#1CC9B5'
}
circleColor[dnsServerRole.OPRDNS] = {
background: '#FFE1B5',
border: '#FFB84E'
}
circleColor[dnsServerRole.SBDNS] = {
background: '#FDC6C6',
border: '#FA7777'
}
circleColor[dnsServerRole.RTDNSM] = {
background: '#ECC6F7',
border: '#BF49DF'
}
return { return {
isMapBlock: isMapBlock(props.chartInfo.type) circleColor,
isMapBlock: isMapBlock(props.chartInfo.type),
isMapPoint: isMapPoint(props.chartInfo.type)
} }
} }
} }

View File

@@ -63,6 +63,10 @@ export function isMapLine (type) {
export function isMapBlock (type) { export function isMapBlock (type) {
return type === 2 return type === 2
} }
/* 散点地图 */
export function isMapPoint (type) {
return type === 3
}
/* 普通折线图 */ /* 普通折线图 */
export function isEchartsLine (type) { export function isEchartsLine (type) {
return type === 11 return type === 11

View File

@@ -402,82 +402,6 @@ export default {
]*/ ]*/
this.statisticsSeverityData = data this.statisticsSeverityData = data
//this.isStatisticsSeverityNoData = true //this.isStatisticsSeverityNoData = true
this.filterData = {
securityEvent: [
{
title: this.$t('detections.eventSeverity'),
column: 'eventSeverity',
collapse: false,
value: [], // value之间是or的关系
data: [] // 从接口动态获取,本项在获得数据后需要特殊处理左边框颜色
},
{
title: this.$t('detections.securityType'),
column: 'securityType',
collapse: false,
value: [],
data: [] // 从接口动态获取
},
{
title: this.$t('detections.victimIp'),
column: 'victimIp',
collapse: false,
value: [],
showMore: true,
showIndex: 9,
data: [] // 从接口动态获取
},
{
title: this.$t('detections.victimLocation'),
column: 'victimLocationCountry',
collapse: false,
value: [],
showMore: false,
showIndex: 9,
data: [
{
label: 'China',
value: 'china',
count: 50
}
] // 从接口动态获取
},
{
title: this.$t('detections.offenderIp'),
column: 'offenderIp',
collapse: false,
value: [],
showMore: false,
showIndex: 9,
data: [] // 从接口动态获取
},
{
title: this.$t('detections.offenderLocation'),
column: 'offenderLocationCountry',
collapse: false,
value: [],
showMore: false,
showIndex: 9,
data: [] // 从接口动态获取
}
],
performanceEvent: [
{
title: this.$t('detections.eventSeverity'),
column: 'eventSeverity',
collapse: false,
value: [], // value之间是or的关系
data: [] // 从接口动态获取,本项在获得数据后需要特殊处理左边框颜色
},
{
title: this.$t('detections.securityType'),
column: 'securityType',
collapse: false,
value: [],
data: [] // 从接口动态获取
}
]
}
if (!this.$_.isEmpty(data)) { if (!this.$_.isEmpty(data)) {
this.filterData[this.pageType][0].data = data.map(r => ({ label: r.eventSeverity, value: r.eventSeverity, count: r.count })) this.filterData[this.pageType][0].data = data.map(r => ({ label: r.eventSeverity, value: r.eventSeverity, count: r.count }))
const eventSeverityOption = this.$_.cloneDeep(pieForSeverity) const eventSeverityOption = this.$_.cloneDeep(pieForSeverity)
@@ -788,7 +712,9 @@ export default {
const params = { const params = {
startTime: getSecond(this.timeFilter.startTime), startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime), endTime: getSecond(this.timeFilter.endTime),
q: this.q q: this.q,
pageSize: this.pageObj.pageSize,
pageNo: this.pageObj.pageNo
} }
getData(api.detection[this.pageType].listBasic, params).then(data => { getData(api.detection[this.pageType].listBasic, params).then(data => {
if (this.pageType === detectionPageType.securityEvent) { if (this.pageType === detectionPageType.securityEvent) {
@@ -1126,7 +1052,16 @@ export default {
this.queryList() this.queryList()
this.queryListTotal() this.queryListTotal()
}, },
resetFilterData () {
this.filterData.securityEvent.forEach(d => {
d.data = []
})
this.filterData.performanceEvent.forEach(d => {
d.data = []
})
},
queryFilter () { queryFilter () {
this.resetFilterData()
const params = { const params = {
startTime: getSecond(this.timeFilter.startTime), startTime: getSecond(this.timeFilter.startTime),
endTime: getSecond(this.timeFilter.endTime), endTime: getSecond(this.timeFilter.endTime),

View File

@@ -8,7 +8,7 @@
<div class="overview__title">Fields</div> <div class="overview__title">Fields</div>
<div class="overview__row"> <div class="overview__row">
<div class="row__label">{{$t('entities.category')}}</div> <div class="row__label">{{$t('entities.category')}}</div>
<div class="row__content">{{basicInfo.appCategory}}</div> <div class="row__content">{{basicInfo.appCategory || '-'}}</div>
</div> </div>
<div class="overview__row"> <div class="overview__row">
<div class="row__label">{{$t('entities.subcategory')}}</div> <div class="row__label">{{$t('entities.subcategory')}}</div>
@@ -35,8 +35,7 @@
</template> </template>
<script> <script>
import { get } from '@/utils/http' import { api, getData } from '@/utils/api'
import { api } from '@/utils/api'
import { eventSeverityColor } from '@/utils/constants' import { eventSeverityColor } from '@/utils/constants'
export default { export default {
name: 'DetectionPerformanceEventAppOverview', name: 'DetectionPerformanceEventAppOverview',
@@ -74,21 +73,17 @@ export default {
}, },
methods: { methods: {
query () { query () {
this.basicInfo = {
}
this.queryBasic().then(responses => { this.queryBasic().then(responses => {
responses && (this.basicInfo = responses)
}) })
}, },
queryBasic () { queryBasic () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
get(api.detection.performanceEvent.overviewBasic, { serverIp: this.detection.appName }).then(response => { getData(api.detection.performanceEvent.overviewBasic, { serverIp: this.detection.appName }).then(data => {
if (response.code === 200) { resolve(data[0])
this.basicInfo = response.data.result[0] }).catch(error => {
resolve(response.data.result) reject(error)
} else {
reject(response)
}
}) })
} catch (e) { } catch (e) {
reject(e) reject(e)

View File

@@ -8,7 +8,7 @@
<div class="overview__title">Fields</div> <div class="overview__title">Fields</div>
<div class="overview__row"> <div class="overview__row">
<div class="row__label">{{$t('entities.category')}}</div> <div class="row__label">{{$t('entities.category')}}</div>
<div class="row__content">{{basicInfo.domainCategoryName}}</div> <div class="row__content">{{basicInfo.domainCategoryName || '-'}}</div>
</div> </div>
<div class="overview__row"> <div class="overview__row">
<div class="row__label">{{$t('entities.group')}}</div> <div class="row__label">{{$t('entities.group')}}</div>
@@ -39,8 +39,7 @@
</template> </template>
<script> <script>
import { get } from '@/utils/http' import { api, getData } from '@/utils/api'
import { api } from '@/utils/api'
import { eventSeverityColor } from '@/utils/constants' import { eventSeverityColor } from '@/utils/constants'
export default { export default {
name: 'DetectionPerformanceEventDomainOverview', name: 'DetectionPerformanceEventDomainOverview',
@@ -78,21 +77,17 @@ export default {
}, },
methods: { methods: {
query () { query () {
this.basicInfo = {
}
this.queryBasic().then(responses => { this.queryBasic().then(responses => {
responses && (this.basicInfo = responses)
}) })
}, },
queryBasic () { queryBasic () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
get(api.detection.performanceEvent.overviewBasic, { serverIp: this.detection.appName }).then(response => { getData(api.detection.performanceEvent.overviewBasic, { serverIp: this.detection.appName }).then(data => {
if (response.code === 200) { resolve(data[0])
this.basicInfo = response.data.result[0] }).catch(error => {
resolve(response.data.result) reject(error)
} else {
reject(response)
}
}) })
} catch (e) { } catch (e) {
reject(e) reject(e)

View File

@@ -65,17 +65,15 @@ export default {
}, },
methods: { methods: {
query () { query () {
this.basicInfo = {
}
this.queryBasic().then(responses => { this.queryBasic().then(responses => {
responses && (this.basicInfo = responses)
}) })
}, },
queryBasic () { queryBasic () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
getData(api.detection.performanceEvent.overviewBasic, { serverIp: this.detection.serverIp }).then(data => { getData(api.detection.performanceEvent.overviewBasic, { serverIp: this.detection.serverIp }).then(data => {
this.basicInfo = data[0] resolve(data[0])
resolve(data)
}).catch(error => { }).catch(error => {
reject(error) reject(error)
}) })

View File

@@ -3,7 +3,7 @@
<div class="overview__left"> <div class="overview__left">
<div class="overview__title">{{$t('overall.remark')}}</div> <div class="overview__title">{{$t('overall.remark')}}</div>
<div class="overview__row"> <div class="overview__row">
<div class="row__content">{{basicInfo.malwareDescription || '-'}}</div> <div class="row__content">Description</div>
</div> </div>
<div class="overview__title">Fields</div> <div class="overview__title">Fields</div>
<div class="overview__row"> <div class="overview__row">
@@ -178,11 +178,9 @@ export default {
methods: { methods: {
getMillisecond, getMillisecond,
query () { query () {
this.basicInfo = {
}
this.events = [
]
Promise.all([this.queryBasic(), this.queryEvent()]).then(responses => { Promise.all([this.queryBasic(), this.queryEvent()]).then(responses => {
responses[0] && (this.basicInfo = responses[0])
responses[1] && (this.events = responses[1])
}) })
}, },
queryBasic () { queryBasic () {
@@ -190,11 +188,7 @@ export default {
try { try {
get(api.detection.securityEvent.overviewBasic, { eventId: this.detection.eventId }).then(response => { get(api.detection.securityEvent.overviewBasic, { eventId: this.detection.eventId }).then(response => {
if (response.code === 200) { if (response.code === 200) {
let data = response.data.result[0] resolve(response.data.result[0])
if (!this.$_.isEmpty(data)) {
this.basicInfo = data
}
resolve(response.data.result)
} else { } else {
reject(response) reject(response)
} }
@@ -207,12 +201,8 @@ export default {
queryEvent () { queryEvent () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
get(api.detection.securityEvent.overviewEvent, { eventId: this.detection.eventId }).then(response => { get(api.detection.securityEvent.overviewEvent, { eventId: this.detection.eventId, offenderIp: this.detection.offenderIp, victimIp: this.detection.victimIp }).then(response => {
if (response.code === 200) { if (response.code === 200) {
let data = response.data.result
if (!this.$_.isEmpty(data)) {
this.events = response.data.result
}
resolve(response.data.result) resolve(response.data.result)
} else { } else {
reject(response) reject(response)