| 1 | <template> |
| 2 | <div class="flex flex-col gap-3"> |
| 3 | <n-input v-model:value="textFilter" placeholder="Search..." clearable> |
| 4 | <template #prefix> |
| 5 | <Icon :name="SearchIcon" /> |
| 6 | </template> |
| 7 | </n-input> |
| 8 | |
| 9 | <div class="grid-auto-fit-200 grid gap-2"> |
| 10 | <CardKV v-for="{ value, key } of contextFiltered" :key> |
| 11 | <template #key> |
| 12 | {{ key }} |
| 13 | </template> |
| 14 | <template #value> |
| 15 | <template v-if="key === 'process_name'"> |
| 16 | <template v-if="value && value !== '-' && value.toString() && processNameList.length"> |
| 17 | <div class="flex flex-wrap gap-2"> |
| 18 | <ThreatIntelProcessEvaluationBadge |
| 19 | v-for="pn of processNameList" |
| 20 | :key="pn" |
| 21 | :process-name="pn" |
| 22 | /> |
| 23 | </div> |
| 24 | </template> |
| 25 | <template v-else>-</template> |
| 26 | </template> |
| 27 | <template v-else> |
| 28 | <ExpandableText :text="value?.toString() ?? '-'" :max-length="100" /> |
| 29 | </template> |
| 30 | </template> |
| 31 | </CardKV> |
| 32 | </div> |
| 33 | </div> |
| 34 | </template> |
| 35 | |
| 36 | <script setup lang="ts"> |
| 37 | import type { SocAlert } from "@/types/soc/alert.d" |
| 38 | import _compact from "lodash/compact" |
| 39 | import _split from "lodash/split" |
| 40 | import _uniq from "lodash/uniq" |
| 41 | import { NInput } from "naive-ui" |
| 42 | import { computed, defineAsyncComponent, ref } from "vue" |
| 43 | import CardKV from "@/components/common/cards/CardKV.vue" |
| 44 | import Icon from "@/components/common/Icon.vue" |
| 45 | |
| 46 | const { alert } = defineProps<{ |
| 47 | alert: SocAlert |
| 48 | }>() |
| 49 | const ThreatIntelProcessEvaluationBadge = defineAsyncComponent( |
| 50 | () => import("@/components/threatIntel/ThreatIntelProcessEvaluationBadge.vue") |
| 51 | ) |
| 52 | const ExpandableText = defineAsyncComponent(() => import("@/components/common/ExpandableText.vue")) |
| 53 | |
| 54 | const SearchIcon = "carbon:search" |
| 55 | |
| 56 | const textFilter = ref("") |
| 57 | const processNameList = computed(() => |
| 58 | _uniq( |
| 59 | _compact( |
| 60 | _split(alert.alert_context?.process_name || "", ",").filter( |
| 61 | p => p.toLowerCase() !== "no process name found" |
| 62 | ) |
| 63 | ) |
| 64 | ) |
| 65 | ) |
| 66 | const contextNormalized = computed(() => { |
| 67 | const list = [] |
| 68 | for (const key in alert.alert_context) { |
| 69 | list.push({ |
| 70 | key, |
| 71 | value: alert.alert_context[key] |
| 72 | }) |
| 73 | } |
| 74 | |
| 75 | return list |
| 76 | }) |
| 77 | |
| 78 | const contextFiltered = computed(() => |
| 79 | contextNormalized.value.filter(o => o.key.toLowerCase().includes(textFilter.value.toLowerCase())) |
| 80 | ) |
| 81 | </script> |