| 1 | <template> |
| 2 | <n-spin :show="loadingDetails"> |
| 3 | <n-tabs type="line" animated :tabs-padding="24"> |
| 4 | <n-tab-pane name="Overview" tab="Overview" display-directive="show:lazy"> |
| 5 | <div class="px-6 pt-3 pb-6"> |
| 6 | <TechniqueAlertDetails v-if="techniqueDetails" :entity="techniqueDetails" /> |
| 7 | </div> |
| 8 | </n-tab-pane> |
| 9 | <n-tab-pane |
| 10 | name="Groups" |
| 11 | :tab="`Groups (${techniqueDetails?.groups?.length || 0})`" |
| 12 | display-directive="show:lazy" |
| 13 | > |
| 14 | <div class="px-6 pt-3 pb-6"> |
| 15 | <GroupsList v-if="techniqueDetails" :list="techniqueDetails.groups" /> |
| 16 | </div> |
| 17 | </n-tab-pane> |
| 18 | <n-tab-pane |
| 19 | name="Mitigations" |
| 20 | :tab="`Mitigations (${techniqueDetails?.mitigations?.length || 0})`" |
| 21 | display-directive="show:lazy" |
| 22 | > |
| 23 | <div class="px-6 pt-3 pb-6"> |
| 24 | <MitigationsList v-if="techniqueDetails" :list="techniqueDetails.mitigations" /> |
| 25 | </div> |
| 26 | </n-tab-pane> |
| 27 | <n-tab-pane |
| 28 | name="Software" |
| 29 | :tab="`Software (${techniqueDetails?.software?.length || 0})`" |
| 30 | display-directive="show:lazy" |
| 31 | > |
| 32 | <div class="px-6 pt-3 pb-6"> |
| 33 | <SoftwareList v-if="techniqueDetails" :list="techniqueDetails.software" /> |
| 34 | </div> |
| 35 | </n-tab-pane> |
| 36 | <n-tab-pane |
| 37 | name="Tactics" |
| 38 | :tab="`Tactics (${techniqueDetails?.tactics?.length || 0})`" |
| 39 | display-directive="show:lazy" |
| 40 | > |
| 41 | <div class="px-6 pt-3 pb-6"> |
| 42 | <TacticsList v-if="techniqueDetails" :list="techniqueDetails.tactics" /> |
| 43 | </div> |
| 44 | </n-tab-pane> |
| 45 | <n-tab-pane name="Alerts" tab="Alerts" display-directive="show:lazy"> |
| 46 | <div class="px-6 pt-3 pb-6"> |
| 47 | <TechniqueEventsList v-if="techniqueDetails" :external-id /> |
| 48 | </div> |
| 49 | </n-tab-pane> |
| 50 | <n-tab-pane name="Atomic test" tab="Atomic test" display-directive="show:lazy"> |
| 51 | <div class="px-6 pt-3 pb-6"> |
| 52 | <TechniqueCardContent :technique-id="externalId" /> |
| 53 | </div> |
| 54 | </n-tab-pane> |
| 55 | </n-tabs> |
| 56 | </n-spin> |
| 57 | </template> |
| 58 | |
| 59 | <script setup lang="ts"> |
| 60 | // TODO-FE: refactor |
| 61 | import type { MitreTechniqueDetails } from "@/types/mitre.d" |
| 62 | import { NSpin, NTabPane, NTabs, useMessage } from "naive-ui" |
| 63 | import { onBeforeMount, ref } from "vue" |
| 64 | import Api from "@/api" |
| 65 | import TechniqueCardContent from "../AtomicTests/TechniqueCardContent.vue" |
| 66 | import GroupsList from "../Group/GroupsList.vue" |
| 67 | import MitigationsList from "../Mitigation/MitigationsList.vue" |
| 68 | import SoftwareList from "../Software/SoftwareList.vue" |
| 69 | import TacticsList from "../Tactic/TacticsList.vue" |
| 70 | import TechniqueEventsList from "../TechniqueEvents/List.vue" |
| 71 | import TechniqueAlertDetails from "./TechniqueAlertDetails.vue" |
| 72 | |
| 73 | const { externalId } = defineProps<{ |
| 74 | externalId: string |
| 75 | }>() |
| 76 | |
| 77 | const message = useMessage() |
| 78 | const loadingDetails = ref(false) |
| 79 | const techniqueDetails = ref<MitreTechniqueDetails | undefined>(undefined) |
| 80 | |
| 81 | function getDetails(id: string) { |
| 82 | loadingDetails.value = true |
| 83 | |
| 84 | Api.wazuh.mitre |
| 85 | .getMitreTechniques({ external_id: id }) |
| 86 | .then(res => { |
| 87 | if (res.data.success) { |
| 88 | if (res.data.results?.[0]) { |
| 89 | techniqueDetails.value = res.data.results[0] |
| 90 | } |
| 91 | } else { |
| 92 | message.warning(res.data?.message || "An error occurred. Please try again later.") |
| 93 | } |
| 94 | }) |
| 95 | .catch(err => { |
| 96 | message.error(err.response?.data?.message || "An error occurred. Please try again later.") |
| 97 | }) |
| 98 | .finally(() => { |
| 99 | loadingDetails.value = false |
| 100 | }) |
| 101 | } |
| 102 | |
| 103 | onBeforeMount(() => { |
| 104 | getDetails(externalId) |
| 105 | // MOCK |
| 106 | /* |
| 107 | techniqueDetails.value = techniqueResultDetails |
| 108 | */ |
| 109 | }) |
| 110 | </script> |