Files
Situation-Awareness-Platfor…/src/views/Jyh/AIRepair/index.vue

272 lines
7.2 KiB
Vue
Raw Normal View History

2025-03-14 20:03:14 +08:00
<template>
<div class="info-outside w-full">
<div class="info">
<div class="flex items-center justify-start w-full gap-1">
2025-03-21 12:11:57 +08:00
<img src="@/assets/imgs/jyh/aiIcon.png" />
<span class="text-base font-medium">AI修复建议:</span>
</div>
<div>
2025-03-21 12:11:57 +08:00
<br />
Ubuntu: 安装 linux-image-5.4.0-126 或更高版本 <br />
RHEL/CentOS: 通过 yum update kernel 升级<br />
Debian: 使用 apt-get upgrade linux-image-$(uname -r)<br />
<!-- <ul>
<li v-for="info in infoList">{{ info }}</li>
2025-03-21 12:11:57 +08:00
</ul> -->
</div>
</div>
</div>
2025-03-14 20:03:14 +08:00
<div class="ai-container">
2025-03-21 12:11:57 +08:00
<template v-if="tableData.length > 0">
<div class="ai-container-card" style="width: 100%" v-for="(rowItem, index) in tableData" :key="index">
2025-03-19 21:43:36 +08:00
<Panel :expand="!rowItem.expand">
<template #header>
<div class="ai-panel-header">
2025-03-21 12:11:57 +08:00
<div style="padding: 25px 8px 0px 20px">
<img style="width: 36px; height: 33px" src="@/assets/imgs/jyh/warning.png" />
2025-03-14 20:03:14 +08:00
</div>
2025-03-21 12:11:57 +08:00
<div style="width: 100%; padding: 20px 20px 0px 0">
2025-03-19 21:43:36 +08:00
<div class="ai-panel-header-title">
<div>
2025-03-21 12:11:57 +08:00
<d-tag color="red-w98" class="mr-1" size="sm">{{ '严重' }}</d-tag>
<span>{{ rowItem.libraryName || '--' }}</span>
2025-03-19 21:43:36 +08:00
</div>
2025-03-21 12:11:57 +08:00
<div
style="cursor: pointer; display: flex; gap: 8px; align-items: center"
@click="rowItem.expand == rowItem.expand"
>
<img style="width: 14px; height: 14px" src="@/assets/imgs/jyh/collapseIcon.png" />
2025-03-19 21:43:36 +08:00
<span>全部收起</span>
</div>
2025-03-14 20:03:14 +08:00
</div>
2025-03-19 21:43:36 +08:00
<div class="ai-panel-header-sub-title">
<div>
<span class="weak-text">安全问题</span>
2025-03-21 12:11:57 +08:00
<span>{{ rowItem.vulnerabilities.length || '--' }}</span>
2025-03-19 21:43:36 +08:00
</div>
<div>
<span class="weak-text">修复兼容性</span>
2025-03-21 12:11:57 +08:00
<span>{{ rowItem.vulnerabilities.length || '--' }}</span>
<img src="@/assets/imgs/jyh/help.png" class="icon-sm" />
<d-tag class="ml-1" type="warning" size="sm">{{
rowItem.vulnerabilities.length > 0 ? rowItem.vulnerabilities[0].severity : '--'
}}</d-tag>
2025-03-19 21:43:36 +08:00
</div>
<div>
<span class="weak-text">升级版本</span>
2025-03-21 12:11:57 +08:00
<span>{{ rowItem.currentVersion || '--' }}</span>
<img src="@/assets/imgs/jyh/ic_digital_power_next_step_@2x.png" class="icon-sm" />
<span>{{ rowItem.currentVersion || '--' }}</span>
2025-03-19 21:43:36 +08:00
</div>
2025-03-14 20:03:14 +08:00
</div>
</div>
</div>
2025-03-19 21:43:36 +08:00
</template>
2025-03-14 20:03:14 +08:00
2025-03-19 21:43:36 +08:00
<template #body>
2025-03-21 12:11:57 +08:00
<div style="padding: 8px 20px 20px 20px; width: 100%">
<Table class="jyh-table" :tableConfig="tableConfig" :dataSource="rowItem.vulnerabilities" />
<div class="w-full flex items-center justify-end">
<span>{{ rowItem.vulnerabilities.length }}</span>
</div>
2025-03-19 21:43:36 +08:00
</div>
</template>
</Panel>
</div>
</template>
<NoData v-else :small="false"></NoData>
2025-03-14 20:03:14 +08:00
</div>
</template>
<script setup>
2025-03-21 12:11:57 +08:00
import { ref, onMounted, defineProps } from 'vue';
2025-03-14 20:03:14 +08:00
import Panel from '@/components/AIRepair/Panel.vue';
import Table from '@/components/AIRepair/Table.vue';
2025-03-19 21:43:36 +08:00
import NoData from '@/components/NoData/NoData.vue';
2025-03-18 22:01:02 +08:00
import { getRepairInfo } from '@/api/jyh';
2025-03-19 21:43:36 +08:00
const propsData = defineProps(['versionId']);
const infoList = ref([
'当前代码主要风险为易受常见的注入攻击包括命令注入、SQL注入、表达式注入针对每种攻击应提供相应的防范措施如数据校验、使用安全函数和限制程序权限。',
'相对上一次检查【提升点】在于代码基础编码问题少了47.8%问题总数降低29.3%'
2025-03-21 12:11:57 +08:00
]);
2025-03-14 20:03:14 +08:00
const tableConfig = ref([
{
2025-03-19 21:43:36 +08:00
field: 'vulnId',
2025-03-14 20:03:14 +08:00
header: '安全问题编号',
sortable: true,
sortMethod: null
},
{
2025-03-19 21:43:36 +08:00
field: 'vulnType',
2025-03-14 20:03:14 +08:00
header: '安全问题类型',
sortable: false,
sortMethod: null
},
{
2025-03-19 21:43:36 +08:00
field: 'vulnId',
2025-03-14 20:03:14 +08:00
header: 'CWE编号',
sortable: false,
sortMethod: null
},
{
2025-03-19 21:43:36 +08:00
field: 'cvssScore',
2025-03-14 20:03:14 +08:00
header: '分值',
sortable: true,
sortMethod: null
2025-03-21 12:11:57 +08:00
}
]);
2025-03-14 20:03:14 +08:00
const list = ref([
{
expand: true,
title: 'Morgan',
data: {
listData: [
2025-03-21 12:11:57 +08:00
{
securityProblemCode: '1',
type: '安全问题',
CWEcode: 'CWE-123',
score: 70
},
{
securityProblemCode: '2',
type: '安全问题',
CWEcode: 'MIT-LICENSE',
score: 89
}
]
}
},
{
expand: true,
title: 'webpack',
data: {
listData: [
2025-03-21 12:11:57 +08:00
{
securityProblemCode: '1',
type: '安全问题',
CWEcode: 'CWE-123',
score: 100
},
{
securityProblemCode: '2',
type: '安全问题',
CWEcode: 'MIT-LICENSE',
score: 90
2025-03-14 20:03:14 +08:00
}
]
}
}
2025-03-21 12:11:57 +08:00
]);
2025-03-14 20:03:14 +08:00
2025-03-21 12:11:57 +08:00
const getInfo = async () => {
2025-03-19 21:43:36 +08:00
const { data } = await getRepairInfo({
2025-03-21 12:11:57 +08:00
current: 1,
size: 10,
2025-03-21 09:49:58 +08:00
// "softwareId": 47,
2025-03-21 12:11:57 +08:00
softwareId: propsData.versionId
2025-03-19 21:43:36 +08:00
});
2025-03-21 12:11:57 +08:00
if (data.code === 200) {
2025-03-19 21:43:36 +08:00
tableData.value = data?.data?.components || [];
// pager.value.total = data?.data?.data?.total || [];
}
2025-03-21 12:11:57 +08:00
};
2025-03-19 21:43:36 +08:00
const tableData = ref([]);
2025-03-21 12:11:57 +08:00
onMounted(() => {
getInfo();
2025-03-19 21:43:36 +08:00
});
2025-03-14 20:03:14 +08:00
</script>
<style scoped lang="scss">
@import 'devui-theme/styles-var/devui-var.scss';
.ai-container {
width: 100%;
display: flex;
flex-direction: column;
gap: 20px;
justify-content: center;
&-card {
border-top: 2px solid $devui-danger;
background-color: $devui-base-bg;
border-radius: var(--devui-border-radius-card, 8px);
2025-03-21 12:11:57 +08:00
box-shadow: var(--devui-shadow-length-base, 0 2px 6px 0) var(--devui-light-shadow, rgba(37, 43, 58, 0.12));
2025-03-14 20:03:14 +08:00
}
}
.ai-panel-header {
display: flex;
flex-direction: row;
2025-03-15 18:01:29 +08:00
height: 80px;
2025-03-14 20:03:14 +08:00
&-title {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
&-sub-title {
display: flex;
align-items: center;
margin-top: 10px;
div {
display: flex;
gap: 8px;
align-items: center;
margin-right: 20px;
position: relative;
&:not(:last-child)::after {
content: '';
position: absolute;
right: -10px;
height: 100%;
width: 1px;
background-color: $devui-line;
}
}
}
}
.weak-text {
color: $devui-text-weak;
}
.icon-sm {
width: 14px;
height: 14px;
}
.info-outside {
margin: 20px 0;
padding: 1px;
border-radius: 8px;
2025-03-21 12:11:57 +08:00
background-image: linear-gradient(
134.79deg,
#a4f7df 0%,
#a0cefb 21%,
#5f9afe 43%,
#d9b9fc 62%,
#01efbb 73%,
#fbae46 100%
);
}
.info {
padding: 10px 20px;
border-radius: 8px;
background-color: #ffffff;
img {
width: 24px;
height: 24px;
}
ul {
list-style: disc;
padding-left: 18px;
line-height: 22px;
}
}
2025-03-19 21:43:36 +08:00
</style>