添加 docker runsh 命令
This commit is contained in:
+51
-3
@@ -1,4 +1,4 @@
|
||||
const crypto = require("crypto");
|
||||
const crypto = require("crypto");
|
||||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
const path = require("path");
|
||||
@@ -298,17 +298,65 @@ function writeJson(filePath, key, value) {
|
||||
return nextData;
|
||||
}
|
||||
|
||||
function resolvePlainPassword(params) {
|
||||
if (params.plainPwd !== undefined) {
|
||||
return params.plainPwd;
|
||||
}
|
||||
if (params.plainPassword !== undefined) {
|
||||
return params.plainPassword;
|
||||
}
|
||||
if (params.plaintextPwd !== undefined) {
|
||||
return params.plaintextPwd;
|
||||
}
|
||||
if (params.plaintextPassword !== undefined) {
|
||||
return params.plaintextPassword;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resolveScpPassword(params) {
|
||||
const plainPassword = resolvePlainPassword(params);
|
||||
if (plainPassword !== undefined) {
|
||||
return plainPassword;
|
||||
}
|
||||
return resolveValue(params.pwd || params.password);
|
||||
}
|
||||
|
||||
function scp(from, to, params = {}) {
|
||||
if (!from || !to) {
|
||||
throw new Error("scp from and to are required");
|
||||
}
|
||||
platform.scp(from, to, Object.assign({}, params, { pwd: resolveValue(params.pwd) }));
|
||||
const pwd = resolveScpPassword(params);
|
||||
platform.scp(from, to, Object.assign({}, params, {
|
||||
pwd,
|
||||
password: pwd,
|
||||
key: resolveValue(params.key || params.identityFile),
|
||||
identityFile: resolveValue(params.identityFile || params.key)
|
||||
}));
|
||||
}
|
||||
|
||||
function exit(code = 0) {
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
function isSecretLogKey(key) {
|
||||
return /^(pwd|password|plainPwd|plainPassword|plaintextPwd|plaintextPassword)$/i.test(key);
|
||||
}
|
||||
|
||||
function redactLogValue(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(redactLogValue);
|
||||
}
|
||||
if (value && typeof value === "object") {
|
||||
const result = {};
|
||||
for (const key of Object.keys(value)) {
|
||||
result[key] = isSecretLogKey(key) ? "******" : redactLogValue(value[key]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function stringifyLogValue(value) {
|
||||
if (typeof value === "string") {
|
||||
return value;
|
||||
@@ -320,7 +368,7 @@ function stringifyLogValue(value) {
|
||||
return `[Function ${value.name || "anonymous"}]`;
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(value);
|
||||
return JSON.stringify(redactLogValue(value));
|
||||
} catch (e) {
|
||||
return String(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user