2022-02-14 22:22:31 +08:00
|
|
|
|
<template>
|
2022-02-15 23:27:55 +08:00
|
|
|
|
<div class="explorer-search explorer-search--show-list">
|
2022-02-14 22:22:31 +08:00
|
|
|
|
<div class="explorer-search__input-case explorer-search__input-case--question-mark-in-line">
|
|
|
|
|
|
<div class="explorer-search__input">
|
|
|
|
|
|
<advanced-search
|
|
|
|
|
|
ref="search"
|
2022-05-11 17:50:40 +08:00
|
|
|
|
:column-list="columnList[pageType]"
|
2022-02-14 22:22:31 +08:00
|
|
|
|
:operator-list="operatorList"
|
|
|
|
|
|
:connection-list="connectionList"
|
2022-02-18 18:09:44 +08:00
|
|
|
|
:full-text="false"
|
2022-02-14 22:22:31 +08:00
|
|
|
|
class="advanced-search--show-list"
|
|
|
|
|
|
@search="search"
|
|
|
|
|
|
></advanced-search>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="search-symbol-inline">
|
|
|
|
|
|
<i class="cn-icon cn-icon-help"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import AdvancedSearch from '@/components/advancedSearch/Index'
|
2022-02-18 10:07:43 +08:00
|
|
|
|
import { humpToLine } from '@/utils/tools'
|
2022-02-14 22:22:31 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'DetectionSearch',
|
2022-05-11 17:50:40 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
pageType: String
|
|
|
|
|
|
},
|
2022-02-14 22:22:31 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
AdvancedSearch
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
2022-05-11 17:50:40 +08:00
|
|
|
|
columnList: {
|
|
|
|
|
|
securityEvent: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'event_severity',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Event severity'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'security_type',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Security type'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'victim_ip',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Victim IP'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'victim_location_country',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Victim location'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'offender_ip',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Offender IP'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'offender_location_country',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Offender location'
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
performanceEvent: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'event_severity',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Event severity'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'event_type',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Event type'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'app_name',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'APP name'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'domain',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'Domain'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'server_ip',
|
|
|
|
|
|
type: 'string',
|
|
|
|
|
|
label: 'IP'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
2022-02-18 10:07:43 +08:00
|
|
|
|
operatorList: ['=', '!=', '>', '<', '>=', '<=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE'],
|
2022-02-15 23:27:55 +08:00
|
|
|
|
connectionList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'AND',
|
|
|
|
|
|
label: 'AND'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'OR',
|
|
|
|
|
|
label: 'OR'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
2022-02-14 22:22:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-12-14 15:01:48 +08:00
|
|
|
|
emits: ['search'],
|
2022-02-14 22:22:31 +08:00
|
|
|
|
methods: {
|
2022-12-08 16:09:46 +08:00
|
|
|
|
/* search (metaList, formatSql) {
|
2022-05-11 17:50:40 +08:00
|
|
|
|
let sql = formatSql
|
|
|
|
|
|
// 全文搜索处理
|
|
|
|
|
|
if (metaList && this.$_.isArray(metaList)) {
|
|
|
|
|
|
const hasFullText = metaList.some(meta => {
|
|
|
|
|
|
return meta.column && meta.column.type === columnType.fullText
|
|
|
|
|
|
})
|
|
|
|
|
|
if (hasFullText) {
|
|
|
|
|
|
const parser = new SqlParser(metaList, this.columnList[this.pageType])
|
|
|
|
|
|
sql = parser.parseMetaToSql(metaList, true)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$emit('search', metaList, sql)
|
2022-12-08 16:09:46 +08:00
|
|
|
|
}, */
|
2022-06-06 17:34:55 +08:00
|
|
|
|
search ({ q, metaList }) {
|
|
|
|
|
|
this.$emit('search', { q, metaList })
|
2022-02-18 10:07:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
changeParams (params) { // params: { column: columnName, oldValue: [...], newValue: [...] }
|
|
|
|
|
|
// 向下传递时需要再转换一次param格式为[{column, operator, value}, ...]
|
|
|
|
|
|
if (params.oldValue.length === 0 && params.newValue.length === 1) {
|
|
|
|
|
|
// 1.参数值数量从0到1,直接addParams
|
|
|
|
|
|
const p = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: '=',
|
|
|
|
|
|
value: params.newValue
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.search.addParams([p])
|
|
|
|
|
|
} else if (params.oldValue.length === 1 && params.newValue.length === 0) {
|
|
|
|
|
|
// 2.参数值数量从1到0,直接removeParams
|
|
|
|
|
|
const p = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: '=',
|
2022-02-18 18:09:44 +08:00
|
|
|
|
value: params.oldValue
|
2022-02-18 10:07:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.$refs.search.removeParams([p])
|
|
|
|
|
|
} else if (params.oldValue.length === 2 && params.newValue.length === 1) {
|
|
|
|
|
|
// 3.参数值数量从多到1,operator由'in'改为'='
|
|
|
|
|
|
const oldParam = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: 'IN',
|
|
|
|
|
|
value: params.oldValue
|
|
|
|
|
|
}
|
|
|
|
|
|
const newParam = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: '=',
|
|
|
|
|
|
value: params.newValue
|
|
|
|
|
|
}
|
2022-02-18 18:09:44 +08:00
|
|
|
|
this.$refs.search.changeParams([{ newParam, oldParam }])
|
|
|
|
|
|
} else if (params.oldValue.length === 1 && params.newValue.length === 2) {
|
2022-02-18 10:07:43 +08:00
|
|
|
|
// 4.参数值数量从1到多, operator由'='改为'in'
|
|
|
|
|
|
const oldParam = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: '=',
|
|
|
|
|
|
value: params.oldValue
|
|
|
|
|
|
}
|
|
|
|
|
|
const newParam = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: 'IN',
|
|
|
|
|
|
value: params.newValue
|
|
|
|
|
|
}
|
2022-02-18 18:09:44 +08:00
|
|
|
|
this.$refs.search.changeParams([{ newParam, oldParam }])
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 5.参数值数量从多到多,加1或者减1
|
|
|
|
|
|
const oldParam = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: 'IN',
|
|
|
|
|
|
value: params.oldValue
|
|
|
|
|
|
}
|
|
|
|
|
|
const newParam = {
|
|
|
|
|
|
column: humpToLine(params.column),
|
|
|
|
|
|
operator: 'IN',
|
|
|
|
|
|
value: params.newValue
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$refs.search.changeParams([{ newParam, oldParam }])
|
2022-02-18 10:07:43 +08:00
|
|
|
|
}
|
2022-03-30 15:37:55 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.emitter.emit('advanced-search')
|
|
|
|
|
|
})
|
2022-02-14 22:22:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|