main
vue 84 lines 2.37 KB
Raw
1 <template>
2 <n-spin :show="loading" class="min-h-40">
3 <div class="flex flex-col gap-2">
4 <template v-if="iocs.length">
5 <CardEntity v-for="ioc of iocs" :key="ioc.id" size="small" embedded>
6 <template #default>
7 <CodeSource :code="ioc.ioc_value" />
8 </template>
9 <template v-if="ioc.details" #mainExtra>
10 {{ ioc.details }}
11 </template>
12 <template #footer>
13 <div class="flex flex-wrap items-center gap-3">
14 <Badge type="splitted" bright>
15 <template #label>Type</template>
16 <template #value>{{ ioc.ioc_type }}</template>
17 </Badge>
18 <Badge type="splitted" bright :color="verdictColor(ioc.vt_verdict)">
19 <template #label>VT Verdict</template>
20 <template #value>{{ ioc.vt_verdict }}</template>
21 </Badge>
22 <Badge v-if="ioc.vt_score" type="splitted">
23 <template #label>VT Score</template>
24 <template #value>{{ ioc.vt_score }}</template>
25 </Badge>
26 </div>
27 </template>
28 </CardEntity>
29 </template>
30 <n-empty v-else-if="!loading" description="No IOCs found for this alert" class="min-h-40 justify-center" />
31 </div>
32 </n-spin>
33 </template>
34
35 <script setup lang="ts">
36 import type { AiAnalystIoc } from "@/types/aiAnalyst.d"
37 import { NEmpty, NSpin, useMessage } from "naive-ui"
38 import { onBeforeMount, ref, toRefs } from "vue"
39 import Api from "@/api"
40 import Badge from "@/components/common/Badge.vue"
41 import CardEntity from "@/components/common/cards/CardEntity.vue"
42 import CodeSource from "@/components/common/CodeSource.vue"
43
44 const props = defineProps<{
45 alertId: number
46 }>()
47
48 const { alertId } = toRefs(props)
49
50 const message = useMessage()
51 const loading = ref(false)
52 const iocs = ref<AiAnalystIoc[]>([])
53
54 function verdictColor(verdict: string) {
55 if (verdict === "malicious") return "danger"
56 if (verdict === "suspicious") return "warning"
57 if (verdict === "clean") return "success"
58 return undefined
59 }
60
61 function getData() {
62 loading.value = true
63
64 Api.aiAnalyst
65 .getIocsByAlert(alertId.value)
66 .then(res => {
67 if (res.data.success) {
68 iocs.value = res.data?.iocs || []
69 } else {
70 message.warning(res.data?.message || "An error occurred. Please try again later.")
71 }
72 })
73 .catch(err => {
74 message.error(err.response?.data?.message || "An error occurred. Please try again later.")
75 })
76 .finally(() => {
77 loading.value = false
78 })
79 }
80
81 onBeforeMount(() => {
82 getData()
83 })
84 </script>