This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/views/detections/DetectionSearch.vue

193 lines
5.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="explorer-search explorer-search--show-list">
<div class="explorer-search__input-case explorer-search__input-case--question-mark-in-line">
<div class="explorer-search__input">
<advanced-search
ref="search"
:column-list="columnList[pageType]"
:operator-list="operatorList"
:connection-list="connectionList"
:full-text="false"
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'
import { humpToLine } from '@/utils/tools'
export default {
name: 'DetectionSearch',
props: {
pageType: String
},
components: {
AdvancedSearch
},
data () {
return {
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'
}
]
},
operatorList: ['=', '!=', '>', '<', '>=', '<=', 'IN', 'NOT IN', 'LIKE', 'NOT LIKE'],
connectionList: [
{
value: 'AND',
label: 'AND'
},
{
value: 'OR',
label: 'OR'
}
]
}
},
emits: ['search'],
methods: {
/* search (metaList, formatSql) {
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)
}, */
search ({ q, metaList }) {
this.$emit('search', { q, metaList })
},
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: '=',
value: params.oldValue
}
this.$refs.search.removeParams([p])
} else if (params.oldValue.length === 2 && params.newValue.length === 1) {
// 3.参数值数量从多到1operator由'in'改为'='
const oldParam = {
column: humpToLine(params.column),
operator: 'IN',
value: params.oldValue
}
const newParam = {
column: humpToLine(params.column),
operator: '=',
value: params.newValue
}
this.$refs.search.changeParams([{ newParam, oldParam }])
} else if (params.oldValue.length === 1 && params.newValue.length === 2) {
// 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
}
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 }])
}
this.$nextTick(() => {
this.emitter.emit('advanced-search')
})
}
}
}
</script>