aops-hermes/0005-Add-login-key-to-asset-management-module.patch
2023-10-18 09:47:51 +08:00

428 lines
17 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From c5a59c0e103a711ce5377a24554ac7c79e2fae54 Mon Sep 17 00:00:00 2001
From: wkl505997900 <2313665567@qq.com>
Date: Tue, 17 Oct 2023 16:59:32 +0800
Subject: [PATCH] update code
---
src/api/assest.js | 3 +-
src/api/leaks.js | 1 -
src/views/assests/HostEdition.vue | 41 ++++++++++++++--
src/views/assests/components/EditableCell.vue | 5 +-
src/views/assests/components/addMoreHost.vue | 25 ++++++++--
.../components/CreateRepairTaskDrawer.vue | 3 --
src/views/leaks/components/CvesTable.vue | 48 ++++---------------
src/views/leaks/components/HostTable.vue | 5 +-
vue.config.js | 14 +++---
9 files changed, 81 insertions(+), 64 deletions(-)
diff --git a/src/api/assest.js b/src/api/assest.js
index af1b125..69b12e2 100644
--- a/src/api/assest.js
+++ b/src/api/assest.js
@@ -124,7 +124,8 @@ export function addHost(parameter) {
ssh_port: parameter.ssh_port,
management: parameter.management,
ssh_user: parameter.ssh_user,
- password: parameter.password
+ password: parameter.password === undefined ? '' : parameter.password,
+ ssh_pkey: parameter.ssh_pkey === undefined ? '' : parameter.ssh_pkey
}
});
}
diff --git a/src/api/leaks.js b/src/api/leaks.js
index cd59dda..097d790 100644
--- a/src/api/leaks.js
+++ b/src/api/leaks.js
@@ -4,7 +4,6 @@
import request from '@/vendor/ant-design-pro/utils/request';
// import { getNotEmptyObjectOrNull } from '@/vendor/ant-design-pro/utils/util';
-
const api = {
getCveOverview: '/vulnerability/cve/overview',
getCveList: '/vulnerability/cve/list/get',
diff --git a/src/views/assests/HostEdition.vue b/src/views/assests/HostEdition.vue
index db6a7ee..de6253e 100644
--- a/src/views/assests/HostEdition.vue
+++ b/src/views/assests/HostEdition.vue
@@ -93,13 +93,39 @@
</a-tooltip>
</a-input>
</a-form-item>
- <a-form-item label="主机登录密码">
- <a-input-password
+ <a-form-item label="认证方式">
+ <a-radio-group name="identificationGroup" v-model="identificaWay" :default-value="1" @change="onChange">
+ <a-radio :value="1">
+ 主机登录密码
+ </a-radio>
+ <a-radio :value="2">
+ 主机登录公钥
+ </a-radio>
+ </a-radio-group>
+ </a-form-item>
+ <a-form-item>
+ <template v-slot:label>
+ <span v-if="identificaWay === 1">主机登录密码</span>
+ <span v-else>
+ <span>主机登录公钥</span>
+ <description-tips style="margin-left: 3px;margin-right: 1px;">
+ id_rsa.pub
+ </description-tips>
+ </span>
+ </template>
+ <a-input-password v-if="identificaWay === 1"
v-decorator="[
'password',
{rules: [{required: pageType === 'create' ? true : requiredRules, message: '请输入主机登录密码'}]}
]"
:placeholder="pageType === 'create' ? '请设置主机登录密码' : '请输入主机登录密码, 若未修改主机用户名或端口可以为空'"></a-input-password>
+ <a-input-password v-else
+ :maxLength="4096"
+ v-decorator="[
+ 'ssh_pkey',
+ {rules: [{required: pageType === 'create' ? true : requiredRules, message: '请输入主机登录公钥'}]}
+ ]"
+ :placeholder="pageType === 'create' ? '请设置主机登录公钥' : '请输入主机登录公钥, 若未修改主机用户名或端口可以为空'"></a-input-password>
</a-form-item>
<a-form-item :wrapper-col="{span: 10, offset: 5}">
<a-button @click="handleCancel">取消</a-button>
@@ -133,10 +159,13 @@ import {PageHeaderWrapper} from '@ant-design-vue/pro-layout';
import AddHostGroupModal from './components/AddHostGroupModal';
import {hostGroupList, addHost, getHostDetail, editHost} from '@/api/assest';
+import DescriptionTips from '@/components/DescriptionTips';
+
export default {
components: {
PageHeaderWrapper,
- AddHostGroupModal
+ AddHostGroupModal,
+ DescriptionTips
},
data() {
return {
@@ -148,7 +177,8 @@ export default {
form: this.$form.createForm(this),
submitLoading: false,
PortRequired: false,
- UserRequired: false
+ UserRequired: false,
+ identificaWay: 1 // 认证方式,
};
},
computed: {
@@ -194,6 +224,9 @@ export default {
}
},
methods: {
+ onChange(e) {
+ this.identificaWay = e.target.value;
+ },
handleUserChange(value) {
if (this.pageType === 'edit') {
value.target.value === this.basicHostInfo.ssh_user ? this.UserRequired = false : this.UserRequired = true
diff --git a/src/views/assests/components/EditableCell.vue b/src/views/assests/components/EditableCell.vue
index 282ba8c..28f0f62 100644
--- a/src/views/assests/components/EditableCell.vue
+++ b/src/views/assests/components/EditableCell.vue
@@ -8,7 +8,7 @@
<div v-if="editable" class="editable-cell-input-wrapper">
<a-form-model-item :prop="formkey">
<!-- 当formkey为密码时使用密码框组件 -->
- <a-input-password v-if="formkey === 'password'" @change="handleChange" @pressEnter="check" v-model="form[formkey]" />
+ <a-input-password v-if="formkey === 'password' || formkey === 'ssh_pkey'" @change="handleChange" @pressEnter="check" v-model="form[formkey]" />
<a-input v-else @change="handleChange" @pressEnter="check" v-model="form[formkey]" />
<a-icon
style="top: -7px;"
@@ -21,7 +21,7 @@
<div v-else class="editable-cell-text-wrapper">
<div class="editable-content">
<!-- <a-input :type="formkey === 'password' ? 'password' : 'text'" v-model="value" /> -->
- <span v-if="formkey === 'password'">{{ countStar(form[formkey]) }}</span>
+ <span v-if="formkey === 'password' || formkey === 'ssh_pkey'">{{ countStar(form[formkey]) }}</span>
<span v-else>{{ value || ' ' }}</span>
</div>
<a-icon type="edit" class="editable-cell-icon" @click="edit" />
@@ -97,6 +97,7 @@ export default {
ssh_port: [{required: true, message: '请输入端口'}, {validator: checkSSHPort}],
ssh_user: [{ validator: validateUser, trigger: 'change' }],
password: [{ required: true, message: 'password不能为空', trigger: 'change' }],
+ ssh_pkey: [{ required: true, message: 'ssh_pkey不能为空', trigger: 'change' }],
host_name: [{ validator: checkNameInput, trigger: 'change' }],
host_group_name: [{ required: true, message: 'host_group_name不能为空', trigger: 'change' }],
management: [{ validator: checkmanagement, trigger: 'change' }]
diff --git a/src/views/assests/components/addMoreHost.vue b/src/views/assests/components/addMoreHost.vue
index 055f1b9..818ffa6 100644
--- a/src/views/assests/components/addMoreHost.vue
+++ b/src/views/assests/components/addMoreHost.vue
@@ -1,7 +1,7 @@
<template>
<div @click="showModal">
<a-button type="primary">批量添加主机</a-button>
- <a-modal title="添加主机" :visible="visible" :footer="null" @cancel="closeModal" width="1468px">
+ <a-modal title="添加主机" :visible="visible" :footer="null" @cancel="closeModal" width="1668px">
<div class="upload_head">
<a-upload :file-list="fileDataList" :remove="removeFile" :before-upload="preUpload">
<div style="display:flex;">
@@ -63,6 +63,15 @@
@allowSub="allowSub()"
@change="onCellChange(record.key, 'password', $event)" />
</template>
+ <template slot="ssh_pkey" slot-scope="text, record">
+ <editable-cell
+ ref="ssh_pkey"
+ formkey="ssh_pkey"
+ :text="String(text)"
+ @unSubmit="unSubmit()"
+ @allowSub="allowSub()"
+ @change="onCellChange(record.key, 'ssh_pkey', $event)" />
+ </template>
<template slot="host_name" slot-scope="text, record">
<editable-cell
ref="host_name"
@@ -144,7 +153,7 @@ export default {
dataAllow: true,
count: '',
rowKey: 'ip',
- colList: ['host_ip', 'ssh_port', 'ssh_user', 'password', 'host_name', 'host_group_name', 'management'],
+ colList: ['host_ip', 'ssh_port', 'ssh_user', 'password', 'ssh_pkey', 'host_name', 'host_group_name', 'management'],
tableVis: false,
fileDataList: [],
visible: false,
@@ -157,6 +166,7 @@ export default {
ssh_port: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}],
ssh_user: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}],
password: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}],
+ ssh_pkey: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}],
host_name: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}],
host_group_name: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}],
management: [{required: true, message: 'Please select Activity zone', trigger: 'blur'}]
@@ -201,6 +211,13 @@ export default {
title: '登录密码',
scopedSlots: {customRender: 'password'}
},
+ {
+ dataIndex: 'ssh_pkey',
+ width: 200,
+ key: 'ssh_pkey',
+ title: '登录密钥',
+ scopedSlots: {customRender: 'ssh_pkey'}
+ },
{
dataIndex: 'host_name',
width: 150,
@@ -260,6 +277,7 @@ export default {
ssh_port: '',
ssh_user: '',
password: '',
+ ssh_pkey: '',
host_name: '',
host_group_name: '',
management: '',
@@ -332,7 +350,7 @@ export default {
const result = XLSX.utils.sheet_to_json(worksheet); // 将数据json数据格式
result.forEach((item) => {
const arr = Object.keys(item)
- if (!arr.includes('host_ip') || !arr.includes('ssh_port') || !arr.includes('ssh_user') || !arr.includes('password') || !arr.includes('host_name') || !arr.includes('host_group_name') || !arr.includes('management')) {
+ if (!arr.includes('host_ip') || !arr.includes('ssh_port') || !arr.includes('ssh_user') || !arr.includes('password') || !arr.includes('ssh_pkey') || !arr.includes('host_name') || !arr.includes('host_group_name') || !arr.includes('management')) {
this.removeFile(file);
this.dataAllow = false;
}
@@ -368,6 +386,7 @@ export default {
this.$set(item, 'host_name', String(item.host_name))
item.management = Boolean(item.management)
item.password = String(item.password)
+ item.ssh_pkey = String(item.ssh_pkey)
delete item.key;
delete item.editable;
delete item.result;
diff --git a/src/views/leaks/components/CreateRepairTaskDrawer.vue b/src/views/leaks/components/CreateRepairTaskDrawer.vue
index 746edaa..3883e1e 100644
--- a/src/views/leaks/components/CreateRepairTaskDrawer.vue
+++ b/src/views/leaks/components/CreateRepairTaskDrawer.vue
@@ -440,9 +440,6 @@ export default {
watch: {},
created() {
},
- beforeDestroy() {
- this.$emit('createSuccess');
- },
methods: {
jumpToPage() {
clearTimeout(this.jumpModalInterval);
diff --git a/src/views/leaks/components/CvesTable.vue b/src/views/leaks/components/CvesTable.vue
index 24245d9..d12931e 100644
--- a/src/views/leaks/components/CvesTable.vue
+++ b/src/views/leaks/components/CvesTable.vue
@@ -38,11 +38,6 @@
</a-col>
<a-col>
<a-row type="flex" :gutter="6">
- <!-- <a-col>
- <status-change-modal
- :selectedRowsAll="selectedRowsAll"
- @statusUpdated="handleStatusUpdated" />
- </a-col> -->
<a-col>
<upload-file v-if="standalone ? true : false" @addSuccess="handleUploadSuccess" />
</a-col>
@@ -794,7 +789,7 @@ export default {
const result = this.innerCveList.some(item => item.cve_id === id)
if (result) {
const target = this.innerCveList.find(item => item.cve_id === id)
- const index = target.rpms.findIndex(item => item.installed_rpm === val.installed_rpm)
+ const index = target.rpms.findIndex(item => item.installed_rpm === val.installed_rpm && item.available_rpm === val.available_rpm)
target.rpms.splice(index, 1)
if (target.rpms.length === 0) {
const dindex = this.innerCveList.findIndex(it => it.cve_id === id)
@@ -1056,7 +1051,7 @@ export default {
});
return;
}
- getCveList({
+ return getCveList({
tableInfo: {
pagination: {
current: pagination.current,
@@ -1142,32 +1137,6 @@ export default {
handleTaskCreateSuccess() {
this.handleRefresh();
},
- handleScanAll() {},
- handleStatusUpdated() {
- this.selectedRowKeys = [];
- this.selectedRowsAll = [];
- if (this.standalone) {
- this.handleRefresh();
- } else {
- const pagination = this.pagination || {};
- const filters = this.filters || {};
- const sorter = this.sorter || {};
- this.$emit('statusUpdated', {
- tableInfo: {
- pagination: {
- current: pagination.current,
- pageSize: pagination.pageSize
- },
- filters: filters,
- sorter: {
- field: sorter.field,
- order: sorter.order
- }
- }
- });
- }
- },
- uploadfile() {},
handleUploadSuccess() {
setTimeout(() => {
this.getCvesAll();
@@ -1175,16 +1144,15 @@ export default {
this.getCves();
}
},
- beforeRouteLeave(to, from, next) {
- // 路由跳转前,清除轮询
- next();
+ beforeDestroy() {
this.innerCveList = []
},
mounted() {
- setTimeout(() => {
- this.getCvesAll();
- }, 500);
- this.getCves();
+ this.getCves().then(
+ () => {
+ this.getCvesAll();
+ }
+ );
}
};
</script>
diff --git a/src/views/leaks/components/HostTable.vue b/src/views/leaks/components/HostTable.vue
index 327a4a9..63dc4f2 100644
--- a/src/views/leaks/components/HostTable.vue
+++ b/src/views/leaks/components/HostTable.vue
@@ -962,14 +962,13 @@ export default {
return false;
}
},
- mounted() {
- this.getHostList();
+ mounted: function () {
this.getHostGroup();
if (this.standalone) {
// 主机列表页面中要自行获取全量主机和扫描状态
this.getScanStatusAll([]);
- this.getHostListAll();
} else {
+ this.getHostList();
// 主机详情页面中要自行获取repo列表
this.getRepoList();
}
diff --git a/vue.config.js b/vue.config.js
index 3fdb052..a93ea29 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -27,8 +27,8 @@ function getGitHash() {
const serverMap = {
serverIpBase: 'http://127.0.0.1',
serveiIp1: 'http://172.168.115.178',
- serveiIp2: 'http://172.168.235.132',
- serveiIp3: 'http://172.168.121.194'
+ serveiIp2: 'http://172.168.97.229',
+ serveiIp3: 'http://172.168.240.235'
}
// vue.config.js
@@ -138,7 +138,7 @@ const vueConfig = {
},
'/api/diag': {
// target: serverMap.serverIpBase + ':11113',
- target: serverMap.serveiIp3 + ':11113',
+ target: serverMap.serveiIp2 + ':11113',
ws: false,
changeOrigin: true,
pathRewrite: {
@@ -147,7 +147,7 @@ const vueConfig = {
},
'/api/check': {
// target: serverMap.serverIpBase + ':11112',
- target: serverMap.serveiIp3 + ':11112',
+ target: serverMap.serveiIp2 + ':11112',
ws: false,
changeOrigin: true,
pathRewrite: {
@@ -156,7 +156,7 @@ const vueConfig = {
},
'/api/vulnerability': {
// target: serverMap.serverIpBase + ':11116',
- target: serverMap.serveiIp3 + ':11116',
+ target: serverMap.serveiIp2 + ':11116',
ws: false,
changeOrigin: true,
pathRewrite: {
@@ -165,7 +165,7 @@ const vueConfig = {
},
'/api/gala-spider': {
// target: serverMap.serverIpBase + ':11115',
- target: serverMap.serveiIp3 + ':11115',
+ target: serverMap.serveiIp2 + ':11115',
ws: false,
changeOrigin: true,
pathRewrite: {
@@ -174,7 +174,7 @@ const vueConfig = {
},
'/api': {
// target: serverMap.serverIpBase + ':11111',
- target: serverMap.serveiIp3 + ':11111',
+ target: serverMap.serveiIp2 + ':11111',
ws: false,
changeOrigin: true,
pathRewrite: {
--
Gitee