fix the cve detail display issue

This commit is contained in:
Hu Gang 2024-12-10 14:24:35 +08:00
parent 7d8598558a
commit aa1ba9a5b9
2 changed files with 155 additions and 1 deletions

View File

@ -0,0 +1,150 @@
From 66ca10539e70e6e5f81c50a80cf3402de764a3bf Mon Sep 17 00:00:00 2001
From: Hu Gang <18768366022@163.com>
Date: Tue, 10 Dec 2024 14:09:34 +0800
Subject: [PATCH] fix cve detail display issue
---
src/locales/lang/zh-cn.json | 2 +-
src/views/execution/Scripts.vue | 1 +
src/views/vulnerability/CveDetail.vue | 40 +++++++++++++++------------
3 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/src/locales/lang/zh-cn.json b/src/locales/lang/zh-cn.json
index 207110f..59c8841 100644
--- a/src/locales/lang/zh-cn.json
+++ b/src/locales/lang/zh-cn.json
@@ -626,7 +626,7 @@
"searchBy": "按主机名搜索"
},
"product": "产品",
- "publishTime": "发布时间:",
+ "publishTime": "发布时间",
"severity": "严重性:",
"unfixed": {
"rpms": {
diff --git a/src/views/execution/Scripts.vue b/src/views/execution/Scripts.vue
index 00959f7..97f906b 100644
--- a/src/views/execution/Scripts.vue
+++ b/src/views/execution/Scripts.vue
@@ -91,6 +91,7 @@ const isModalVisible = ref(false)
function handleSuccess() {
isModalVisible.value = false
+ tableState.selectedScriptId = ''
getScripts()
}
diff --git a/src/views/vulnerability/CveDetail.vue b/src/views/vulnerability/CveDetail.vue
index 6d1843e..632e7d1 100644
--- a/src/views/vulnerability/CveDetail.vue
+++ b/src/views/vulnerability/CveDetail.vue
@@ -1,6 +1,6 @@
<script lang="ts" setup>
-import { onBeforeRouteUpdate, useRoute } from 'vue-router'
-import { computed, onMounted, ref } from 'vue'
+import { useRoute } from 'vue-router'
+import { computed, onMounted, ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { severityColorMap } from './config'
import HostTable from './components/HostTable.vue'
@@ -13,7 +13,7 @@ const route = useRoute()
const isSpanning = ref(false)
// #region ----------------------------------------< detail >----------------------------------------
-
+const cveId = ref()
const affectTableColumns = computed(() => [
{
dataIndex: 'os_version',
@@ -40,16 +40,14 @@ const cveInfo = ref<CveDetail>({
async function queryCveDetail(cveId: string) {
isSpanning.value = true
const [, res] = await api.getCveInfos(cveId)
- if (res)
- cveInfo.value = res.result
+ if (res) cveInfo.value = res.result
isSpanning.value = false
}
-function initCveDetail() {
- const cveId = (route.params.cve_id as string) ?? undefined
- if (!cveId)
- return
+function initCveDetail(cveId: string) {
+ if (!cveId) return
+
queryCveDetail(cveId)
}
// #endregion
@@ -58,7 +56,7 @@ function initCveDetail() {
const isDrawerVisible = ref(false)
-const drawerColunms = [
+const drawerColumns = [
{
dataIndex: 'index',
title: t('vul.cveDetail.index'),
@@ -70,12 +68,17 @@ const drawerColunms = [
]
// #endregion
-onBeforeRouteUpdate(() => {
- initCveDetail()
-})
+watch(
+ () => route.path,
+ () => {
+ cveId.value = (route.params.cve_id as string) ?? ''
+ initCveDetail(cveId.value)
+ },
+)
onMounted(() => {
- initCveDetail()
+ cveId.value = (route.params.cve_id as string) ?? ''
+ initCveDetail(cveId.value)
})
</script>
@@ -95,7 +98,8 @@ onMounted(() => {
{{ `${t('vul.cveDetail.publishTime')} : ${cveInfo.publish_time}` }}
</a-col>
<a-col v-if="cveInfo.severity" :span="8">
- {{ $t('vul.cveDetail.severity') }} <span :style="`color: ${severityColorMap[cveInfo.severity]}`">{{
+ {{ $t('vul.cveDetail.severity') }}
+ <span :style="`color: ${severityColorMap[cveInfo.severity]}`">{{
t(`vul.severityStatus.${cveInfo.severity.toLowerCase()}`)
}}</span>
</a-col>
@@ -117,7 +121,7 @@ onMounted(() => {
</a-col>
<a-drawer v-model:open="isDrawerVisible" :title="$t('vul.cveDetail.associateCVE')">
<a-table
- :columns="drawerColunms"
+ :columns="drawerColumns"
:data-source="cveInfo.related_cve.map((item, index) => ({ name: item, index }))"
:pagination="false"
bordered
@@ -125,7 +129,7 @@ onMounted(() => {
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'name'">
<router-link
- :to="{ path: `/vulnerability/cves-management/${record.name}` }"
+ :to="{ path: `/vulnerability/cves/cve-detail/${record.name}` }"
@click="isDrawerVisible = false"
>
{{ record.name }}
@@ -152,7 +156,7 @@ onMounted(() => {
</a-card>
<a-card>
<h1>{{ $t('vul.cveDetail.affectedHost') }}</h1>
- <HostTable class="host-table" />
+ <HostTable :key="cveId" class="host-table" />
</a-card>
</PageWrapper>
</template>
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: aops-hermes
Version: v2.1.1
Release: 3
Release: 4
Summary: Web for an intelligent diagnose frame
License: MulanPSL2
URL: https://gitee.com/openeuler/%{name}
@ -10,6 +10,7 @@ Source0: %{name}-%{version}.tar.gz
Source1: node_modules.tar.gz
Patch001: 0001-Modify-host-group-input-parameter-verification.patch
Patch002: 0002-set-the-default-language-for-requests.patch
Patch003: 0003-fix-cve-detail-display-issue.patch
BuildRequires: nodejs
@ -38,6 +39,9 @@ cp -r deploy/aops-hermes.service %{buildroot}/usr/lib/systemd/system/
%changelog
* Tue Dec 10 2024 Hu gang<18768366022@163.com> - v2.1.1-4
- fix the cve detail display issue
* Mon Dec 2 2024 Hu gang<18768366022@163.com> - v2.1.1-3
- set the default language for requests