fix ssh 授权目录不能为根目录

This commit is contained in:
bwcx_jzy 2022-02-12 16:05:49 +08:00
parent 276006b657
commit 1c6c5d22cc
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
3 changed files with 68 additions and 63 deletions

View File

@ -9,6 +9,8 @@
### 🐞 解决BUG、优化功能 ### 🐞 解决BUG、优化功能
1. 【server】 ssh 授权目录不能为根目录
------ ------

View File

@ -38,10 +38,12 @@ import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.Session; import com.jcraft.jsch.Session;
import io.jpom.common.BaseServerController; import io.jpom.common.BaseServerController;
import io.jpom.common.Type; import io.jpom.common.Type;
import io.jpom.common.interceptor.PermissionInterceptor;
import io.jpom.model.PageResultDto; import io.jpom.model.PageResultDto;
import io.jpom.model.data.AgentWhitelist; import io.jpom.model.data.AgentWhitelist;
import io.jpom.model.data.NodeModel; import io.jpom.model.data.NodeModel;
import io.jpom.model.data.SshModel; import io.jpom.model.data.SshModel;
import io.jpom.model.data.UserModel;
import io.jpom.model.enums.BuildReleaseMethod; import io.jpom.model.enums.BuildReleaseMethod;
import io.jpom.model.log.SshTerminalExecuteLog; import io.jpom.model.log.SshTerminalExecuteLog;
import io.jpom.plugin.ClassFeature; import io.jpom.plugin.ClassFeature;
@ -143,6 +145,14 @@ public class SshController extends BaseServerController {
sshModel.fileDirs(null); sshModel.fileDirs(null);
} else { } else {
List<String> list = StrSplitter.splitTrim(fileDirs, StrUtil.LF, true); List<String> list = StrSplitter.splitTrim(fileDirs, StrUtil.LF, true);
for (String s : list) {
String normalize = FileUtil.normalize(s);
int count = StrUtil.count(normalize, StrUtil.SLASH);
Assert.state(count >= 2, "ssh 授权目录不能是根目录");
}
//
UserModel userModel = getUser();
Assert.state(!userModel.isDemoUser(), PermissionInterceptor.DEMO_TIP);
sshModel.fileDirs(list); sshModel.fileDirs(list);
} }
sshModel.setHost(host); sshModel.setHost(host);

View File

@ -3,69 +3,62 @@
<a-tabs type="card" default-active-key="1"> <a-tabs type="card" default-active-key="1">
<a-tab-pane key="1" tab="服务端"> <upgrade></upgrade></a-tab-pane> <a-tab-pane key="1" tab="服务端"> <upgrade></upgrade></a-tab-pane>
<a-tab-pane key="2" tab="所有节点(插件端)" force-render> <a-tab-pane key="2" tab="所有节点(插件端)" force-render>
<a-space direction="vertical" size="middle"> <a-table
<a-row> :columns="columns"
<div> :data-source="listComputed"
<a-space> bordered
<a-input class="search-input-item" v-model="listQuery['%id%']" placeholder="节点ID" /> size="middle"
<a-input class="search-input-item" v-model="listQuery['%name%']" placeholder="节点名称" /> rowKey="id"
<a-input class="search-input-item" v-model="listQuery['%url%']" placeholder="节点地址" /> class="table"
<a-select show-search option-filter-prop="children" v-model="listQuery.group" allowClear placeholder="分组" class="search-input-item"> :pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false"
<a-select-option v-for="item in groupList" :key="item">{{ item }}</a-select-option> @change="changePage"
</a-select> :row-selection="rowSelection"
<a-button :loading="loading" type="primary" @click="refresh">搜索</a-button> >
</a-space> <template slot="title">
</div> <a-space>
</a-row> <a-input class="search-input-item" v-model="listQuery['%name%']" placeholder="节点名称" />
<a-input class="search-input-item" v-model="listQuery['%url%']" placeholder="节点地址" />
<a-select show-search option-filter-prop="children" v-model="listQuery.group" allowClear placeholder="分组" class="search-input-item">
<a-select-option v-for="item in groupList" :key="item">{{ item }}</a-select-option>
</a-select>
<a-button :loading="loading" type="primary" @click="refresh">搜索</a-button>
<a-table <a-select v-model="temp.protocol" placeholder="升级协议" class="search-input-item">
:columns="columns" <a-select-option value="WebSocket">WebSocket</a-select-option>
:data-source="listComputed" <a-select-option value="Http">Http</a-select-option>
bordered </a-select>
rowKey="id" <a-button type="primary" @click="batchUpdate">批量更新</a-button>
class="table" |
:pagination="this.listQuery.total / this.listQuery.limit > 1 ? (this, pagination) : false" <a-upload name="file" accept=".jar,.zip" action="" :showUploadList="false" :multiple="false" :before-upload="beforeUpload">
@change="changePage" <a-button type="primary">
:row-selection="rowSelection" <a-icon type="upload" />
> 新版本
<template slot="title"> </a-button>
<a-space> </a-upload>
<a-select v-model="temp.protocol" placeholder="升级协议" class="search-input-item"> <a-tooltip :title="`打包时间:${agentTimeStamp || '未知'}`">
<a-select-option value="WebSocket">WebSocket</a-select-option> Agent版本{{ agentVersion | version }}
<a-select-option value="Http">Http</a-select-option> <a-tag v-if="temp.upgrade" color="pink" @click="downloadRemoteEvent">新版本{{ temp.newVersion }} </a-tag>
</a-select> <!-- </div> -->
<a-button type="primary" @click="batchUpdate">批量更新</a-button> </a-tooltip>
| <!-- 打包时间{{ agentTimeStamp | version }}</div> -->
<a-upload name="file" accept=".jar,.zip" action="" :showUploadList="false" :multiple="false" :before-upload="beforeUpload"> </a-space>
<a-button type="primary"> </template>
<a-icon type="upload" /> <template slot="version" slot-scope="text">
新版本 {{ text | version }}
</a-button> </template>
</a-upload> <template slot="status" slot-scope="text">
<div> <div class="restarting" v-if="text && text.type === 'restarting'">
Agent版本{{ agentVersion | version }} <a-tooltip :title="text.data"> {{ text.data }} </a-tooltip>
<a-tag v-if="temp.upgrade" color="pink" @click="downloadRemoteEvent">新版本{{ temp.newVersion }} </a-tag> </div>
</div> <div class="uploading" v-if="text && text.type === 'uploading'">
<div>打包时间{{ agentTimeStamp | version }}</div> <div class="text">{{ text.percent === 100 ? "上传成功" : "正在上传文件" }}</div>
</a-space> <a-progress :percent="text.percent" />
</template> </div>
<template slot="version" slot-scope="text"> </template>
{{ text | version }} <template slot="operation" slot-scope="text, record">
</template> <a-button type="primary" size="small" @click="updateNodeHandler(record)">更新</a-button>
<template slot="status" slot-scope="text"> </template>
<div class="restarting" v-if="text && text.type === 'restarting'"> </a-table>
<a-tooltip :title="text.data"> {{ text.data }} </a-tooltip>
</div>
<div class="uploading" v-if="text && text.type === 'uploading'">
<div class="text">{{ text.percent === 100 ? "上传成功" : "正在上传文件" }}</div>
<a-progress :percent="text.percent" />
</div>
</template>
<template slot="operation" slot-scope="text, record">
<a-button type="primary" @click="updateNodeHandler(record)">更新</a-button>
</template>
</a-table>
</a-space>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</div> </div>
@ -106,7 +99,7 @@ export default {
{ title: "打包时间", dataIndex: "timeStamp", ellipsis: true, scopedSlots: { customRender: "timeStamp" } }, { title: "打包时间", dataIndex: "timeStamp", ellipsis: true, scopedSlots: { customRender: "timeStamp" } },
{ title: "状态", dataIndex: "status", ellipsis: true, scopedSlots: { customRender: "status" } }, { title: "状态", dataIndex: "status", ellipsis: true, scopedSlots: { customRender: "status" } },
// {title: '', dataIndex: 'autoUpdate', ellipsis: true, scopedSlots: {customRender: 'autoUpdate'}}, // {title: '', dataIndex: 'autoUpdate', ellipsis: true, scopedSlots: {customRender: 'autoUpdate'}},
{ title: "操作", dataIndex: "operation", width: 120, scopedSlots: { customRender: "operation" }, align: "left" }, { title: "操作", dataIndex: "operation", width: 90, scopedSlots: { customRender: "operation" }, align: "center" },
], ],
nodeVersion: {}, nodeVersion: {},
nodeStatus: {}, nodeStatus: {},