Skip to content

Commit

Permalink
Enhance sftp interactiveAuth mode (fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii.bobrovyk committed Nov 25, 2021
1 parent 898346c commit 27c4fda
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/remote-client/sshClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export default class SSHClient extends RemoteClient {
// ? Math.max(10800 * 1000, connectTimeout || 0) // 180 mins
: connectTimeout,
...option,
tryKeyboard: interactiveAuth,
tryKeyboard: !!interactiveAuth,
});
});
}
Expand Down
6 changes: 5 additions & 1 deletion src/modules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const configScheme = {
agent: nullable(Joi.string()),
privateKeyPath: nullable(Joi.string()),
passphrase: nullable(Joi.string().allow(true)),
interactiveAuth: Joi.boolean(),
interactiveAuth: Joi.alternatives([
Joi.boolean(),
Joi.array()
.items(Joi.string()),
]).optional(),
algorithms: Joi.any(),
sshConfigPath: Joi.string(),
sshCustomParams: Joi.string(),
Expand Down
22 changes: 16 additions & 6 deletions src/modules/serviceManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,24 @@ const serviceManager = new Trie<FileService>(

function maskConfig(config) {
const copy = {};
const privated = ['username', 'password', 'passphrase'];
const MASK = '******';
Object.keys(config).forEach(key => {
const configValue = config[key];
// tslint:disable-next-line triple-equals
if (privated.indexOf(key) !== -1 && configValue != undefined) {
copy[key] = '******';
} else {
copy[key] = configValue;
switch (key) {
case 'username':
case 'password':
case 'passphrase':
copy[key] = MASK;
break;
case 'interactiveAuth':
if (Array.isArray(configValue)) {
copy[key] = configValue.map(phrase => MASK);
} else {
copy[key] = configValue;
}
break;
default:
copy[key] = configValue;
}
});
return copy;
Expand Down
2 changes: 1 addition & 1 deletion test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const configScheme = {
interactiveAuth: Joi.alternatives([
Joi.boolean(),
Joi.array()
.items(Joi.string())
.items(Joi.string()),
]).optional(),

secure: Joi.any().valid(true, false, 'control', 'implicit').optional(),
Expand Down

0 comments on commit 27c4fda

Please sign in to comment.