bdy 1.23.6-dev → 1.23.7-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distTs/package.json +10 -2
- package/distTs/src/agent/linux.js +53 -3
- package/distTs/src/agent/manager.js +3 -6
- package/distTs/src/agent/osx.js +51 -3
- package/distTs/src/agent/system.js +400 -21
- package/distTs/src/agent/windows.js +4 -7
- package/distTs/src/command/agent/debug.js +2 -2
- package/distTs/src/command/agent/install.js +37 -10
- package/distTs/src/command/agent/restart.js +2 -2
- package/distTs/src/command/agent/run.js +3 -0
- package/distTs/src/command/agent/start.js +2 -2
- package/distTs/src/command/agent/status.js +19 -0
- package/distTs/src/command/agent/stop.js +2 -2
- package/distTs/src/command/agent/uninstall.js +5 -8
- package/distTs/src/command/agent/update.js +2 -2
- package/distTs/src/command/artifact/publish.js +3 -1
- package/distTs/src/command/version.js +13 -5
- package/distTs/src/logger.js +40 -4
- package/distTs/src/texts.js +35 -19
- package/distTs/src/utils.js +98 -3
- package/node_modules/asn1/Jenkinsfile +65 -0
- package/node_modules/asn1/LICENSE +19 -0
- package/node_modules/asn1/README.md +50 -0
- package/node_modules/asn1/lib/ber/errors.js +13 -0
- package/node_modules/asn1/lib/ber/index.js +27 -0
- package/node_modules/asn1/lib/ber/reader.js +262 -0
- package/node_modules/asn1/lib/ber/types.js +36 -0
- package/node_modules/asn1/lib/ber/writer.js +317 -0
- package/node_modules/asn1/lib/index.js +20 -0
- package/node_modules/asn1/package.json +31 -0
- package/node_modules/bcrypt-pbkdf/CONTRIBUTING.md +13 -0
- package/node_modules/bcrypt-pbkdf/LICENSE +66 -0
- package/node_modules/bcrypt-pbkdf/README.md +45 -0
- package/node_modules/bcrypt-pbkdf/index.js +556 -0
- package/node_modules/bcrypt-pbkdf/package.json +15 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/ssh2/.eslintignore +4 -0
- package/node_modules/ssh2/.eslintrc.js +5 -0
- package/node_modules/ssh2/.github/workflows/ci.yml +110 -0
- package/node_modules/ssh2/.github/workflows/lint.yml +27 -0
- package/node_modules/ssh2/LICENSE +19 -0
- package/node_modules/ssh2/README.md +1529 -0
- package/node_modules/ssh2/SFTP.md +413 -0
- package/node_modules/ssh2/examples/server-chat.js +238 -0
- package/node_modules/ssh2/examples/sftp-server-download-only.js +134 -0
- package/node_modules/ssh2/install.js +27 -0
- package/node_modules/ssh2/lib/Channel.js +295 -0
- package/node_modules/ssh2/lib/agent.js +1123 -0
- package/node_modules/ssh2/lib/client.js +2176 -0
- package/node_modules/ssh2/lib/http-agents.js +84 -0
- package/node_modules/ssh2/lib/index.js +44 -0
- package/node_modules/ssh2/lib/keygen.js +582 -0
- package/node_modules/ssh2/lib/protocol/Protocol.js +2136 -0
- package/node_modules/ssh2/lib/protocol/SFTP.js +4052 -0
- package/node_modules/ssh2/lib/protocol/constants.js +356 -0
- package/node_modules/ssh2/lib/protocol/crypto/binding.gyp +23 -0
- package/node_modules/ssh2/lib/protocol/crypto/poly1305.js +43 -0
- package/node_modules/ssh2/lib/protocol/crypto/src/binding.cc +2300 -0
- package/node_modules/ssh2/lib/protocol/crypto.js +1602 -0
- package/node_modules/ssh2/lib/protocol/handlers.js +16 -0
- package/node_modules/ssh2/lib/protocol/handlers.misc.js +1285 -0
- package/node_modules/ssh2/lib/protocol/kex.js +1908 -0
- package/node_modules/ssh2/lib/protocol/keyParser.js +1484 -0
- package/node_modules/ssh2/lib/protocol/node-fs-compat.js +115 -0
- package/node_modules/ssh2/lib/protocol/utils.js +356 -0
- package/node_modules/ssh2/lib/protocol/zlib.js +255 -0
- package/node_modules/ssh2/lib/server.js +1380 -0
- package/node_modules/ssh2/lib/utils.js +336 -0
- package/node_modules/ssh2/package.json +49 -0
- package/node_modules/ssh2/test/common.js +316 -0
- package/node_modules/ssh2/test/fixtures/bad_rsa_private_key +26 -0
- package/node_modules/ssh2/test/fixtures/https_cert.pem +33 -0
- package/node_modules/ssh2/test/fixtures/https_key.pem +52 -0
- package/node_modules/ssh2/test/fixtures/id_dsa +12 -0
- package/node_modules/ssh2/test/fixtures/id_ecdsa +5 -0
- package/node_modules/ssh2/test/fixtures/id_rsa +15 -0
- package/node_modules/ssh2/test/fixtures/id_rsa.ppk +26 -0
- package/node_modules/ssh2/test/fixtures/id_rsa_enc +30 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa +21 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc +22 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm +23 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_dsa_enc_gcm.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa +9 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc +10 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm +10 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ecdsa_enc_gcm.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519 +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_ed25519.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa +27 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc +28 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm +29 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_new_rsa_enc_gcm.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa +12 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc +15 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_dsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa +5 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_ecdsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa +27 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc +30 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.pub.result +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256 +54 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub +1 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.pub.result +6 -0
- package/node_modules/ssh2/test/fixtures/keyParser/openssh_old_rsa_enc_aes256.result +6 -0
- package/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc +17 -0
- package/node_modules/ssh2/test/fixtures/keyParser/ppk_dsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa +26 -0
- package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc +18 -0
- package/node_modules/ssh2/test/fixtures/keyParser/ppk_rsa_enc.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub +9 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub +10 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa2.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub +11 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa3.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub +11 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa4.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub +8 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa5.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub +13 -0
- package/node_modules/ssh2/test/fixtures/keyParser/rfc4716_rsa6.pub.result +7 -0
- package/node_modules/ssh2/test/fixtures/openssh_new_rsa +27 -0
- package/node_modules/ssh2/test/fixtures/ssh_host_dsa_key +12 -0
- package/node_modules/ssh2/test/fixtures/ssh_host_ecdsa_key +5 -0
- package/node_modules/ssh2/test/fixtures/ssh_host_rsa_key +15 -0
- package/node_modules/ssh2/test/test-exec.js +578 -0
- package/node_modules/ssh2/test/test-integration-openssh.js +486 -0
- package/node_modules/ssh2/test/test-keygen.js +60 -0
- package/node_modules/ssh2/test/test-misc-client-server.js +1460 -0
- package/node_modules/ssh2/test/test-openssh.js +261 -0
- package/node_modules/ssh2/test/test-protocol-crypto.js +631 -0
- package/node_modules/ssh2/test/test-protocol-keyparser.js +177 -0
- package/node_modules/ssh2/test/test-server-hostkeys.js +138 -0
- package/node_modules/ssh2/test/test-sftp.js +842 -0
- package/node_modules/ssh2/test/test-shell.js +109 -0
- package/node_modules/ssh2/test/test-userauth-agent-openssh.js +110 -0
- package/node_modules/ssh2/test/test-userauth-agent.js +171 -0
- package/node_modules/ssh2/test/test-userauth.js +611 -0
- package/node_modules/ssh2/test/test-worker-imports.js +25 -0
- package/node_modules/ssh2/test/test.js +20 -0
- package/node_modules/ssh2/util/build_pagent.bat +2 -0
- package/node_modules/ssh2/util/pagent.c +88 -0
- package/node_modules/ssh2/util/pagent.exe +0 -0
- package/node_modules/tweetnacl/.npmignore +4 -0
- package/node_modules/tweetnacl/AUTHORS.md +28 -0
- package/node_modules/tweetnacl/CHANGELOG.md +221 -0
- package/node_modules/tweetnacl/LICENSE +24 -0
- package/node_modules/tweetnacl/PULL_REQUEST_TEMPLATE.md +20 -0
- package/node_modules/tweetnacl/README.md +459 -0
- package/node_modules/tweetnacl/nacl-fast.js +2388 -0
- package/node_modules/tweetnacl/nacl-fast.min.js +2 -0
- package/node_modules/tweetnacl/nacl.d.ts +98 -0
- package/node_modules/tweetnacl/nacl.js +1175 -0
- package/node_modules/tweetnacl/nacl.min.js +1 -0
- package/node_modules/tweetnacl/package.json +58 -0
- package/package.json +10 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const { inspect } = require('util');
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
mustCall,
|
|
8
|
+
mustCallAtLeast,
|
|
9
|
+
setupSimple,
|
|
10
|
+
} = require('./common.js');
|
|
11
|
+
|
|
12
|
+
const DEBUG = false;
|
|
13
|
+
|
|
14
|
+
const setup = setupSimple.bind(undefined, DEBUG);
|
|
15
|
+
|
|
16
|
+
{
|
|
17
|
+
const { client, server } = setup('Simple shell()');
|
|
18
|
+
|
|
19
|
+
const OUTPUT = 'shell output!\n';
|
|
20
|
+
|
|
21
|
+
server.on('connection', mustCall((conn) => {
|
|
22
|
+
conn.on('ready', mustCall(() => {
|
|
23
|
+
conn.on('session', mustCall((accept, reject) => {
|
|
24
|
+
const session = accept();
|
|
25
|
+
session.on('pty', mustCall((accept, reject, info) => {
|
|
26
|
+
accept();
|
|
27
|
+
session.on('shell', mustCall((accept, reject) => {
|
|
28
|
+
let input = '';
|
|
29
|
+
const stream = accept();
|
|
30
|
+
stream.write(OUTPUT);
|
|
31
|
+
stream.on('data', mustCallAtLeast((data) => {
|
|
32
|
+
input += data;
|
|
33
|
+
if (input === 'exit\n') {
|
|
34
|
+
stream.end();
|
|
35
|
+
conn.end();
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
}));
|
|
39
|
+
}));
|
|
40
|
+
}));
|
|
41
|
+
}));
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
client.on('ready', mustCall(() => {
|
|
45
|
+
let output = '';
|
|
46
|
+
client.on('close', mustCall(() => {
|
|
47
|
+
assert(output === OUTPUT, `Wrong shell output: ${inspect(output)}`);
|
|
48
|
+
})).shell(mustCall((err, stream) => {
|
|
49
|
+
assert(!err, `Unexpected shell error: ${err}`);
|
|
50
|
+
stream.write('exit\n');
|
|
51
|
+
stream.on('data', mustCallAtLeast((d) => {
|
|
52
|
+
output += d;
|
|
53
|
+
})).on('close', mustCall(() => {}));
|
|
54
|
+
}));
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
const { client, server } = setup('Shell with environment set');
|
|
60
|
+
|
|
61
|
+
const OUTPUT = 'shell output!\n';
|
|
62
|
+
const clientEnv = { SSH2NODETEST: 'foo' };
|
|
63
|
+
|
|
64
|
+
server.on('connection', mustCall((conn) => {
|
|
65
|
+
conn.on('ready', mustCall(() => {
|
|
66
|
+
conn.on('session', mustCall((accept, reject) => {
|
|
67
|
+
let pty = false;
|
|
68
|
+
let env = false;
|
|
69
|
+
accept().on('pty', mustCall((accept, reject, info) => {
|
|
70
|
+
accept();
|
|
71
|
+
pty = true;
|
|
72
|
+
})).on('env', mustCall((accept, reject, info) => {
|
|
73
|
+
accept && accept();
|
|
74
|
+
env = true;
|
|
75
|
+
assert(info.key === Object.keys(clientEnv)[0],
|
|
76
|
+
`Wrong env key: ${inspect(info.key)}`);
|
|
77
|
+
assert(info.val === Object.values(clientEnv)[0],
|
|
78
|
+
`Wrong env value: ${inspect(info.val)}`);
|
|
79
|
+
})).on('shell', mustCall((accept, reject) => {
|
|
80
|
+
assert(pty, 'Expected pty before shell');
|
|
81
|
+
assert(env, 'Expected env before shell');
|
|
82
|
+
let input = '';
|
|
83
|
+
const stream = accept();
|
|
84
|
+
stream.write(OUTPUT);
|
|
85
|
+
stream.on('data', mustCallAtLeast((data) => {
|
|
86
|
+
input += data;
|
|
87
|
+
if (input === 'exit\n') {
|
|
88
|
+
stream.end();
|
|
89
|
+
conn.end();
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
}));
|
|
93
|
+
}));
|
|
94
|
+
}));
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
client.on('ready', mustCall(() => {
|
|
98
|
+
let output = '';
|
|
99
|
+
client.on('close', mustCall(() => {
|
|
100
|
+
assert(output === OUTPUT, `Wrong shell output: ${inspect(output)}`);
|
|
101
|
+
})).shell({ env: clientEnv }, mustCall((err, stream) => {
|
|
102
|
+
assert(!err, `Unexpected shell error: ${err}`);
|
|
103
|
+
stream.write('exit\n');
|
|
104
|
+
stream.on('data', mustCallAtLeast((d) => {
|
|
105
|
+
output += d;
|
|
106
|
+
})).on('close', mustCall(() => {}));
|
|
107
|
+
}));
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const debug = false;
|
|
7
|
+
const SPAWN_OPTS = { windowsHide: true };
|
|
8
|
+
|
|
9
|
+
// TODO: figure out why this test is failing on Windows
|
|
10
|
+
if (process.platform === 'win32') {
|
|
11
|
+
console.log('Skipping ssh-agent test on Windows');
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (process.argv[2] === 'child') {
|
|
16
|
+
const {
|
|
17
|
+
fixtureKey,
|
|
18
|
+
mustCall,
|
|
19
|
+
setup,
|
|
20
|
+
} = require('./common.js');
|
|
21
|
+
|
|
22
|
+
const serverCfg = { hostKeys: [ fixtureKey('ssh_host_rsa_key').raw ] };
|
|
23
|
+
|
|
24
|
+
const clientKey = fixtureKey('openssh_new_rsa');
|
|
25
|
+
|
|
26
|
+
// Add key to the agent first
|
|
27
|
+
{
|
|
28
|
+
const {
|
|
29
|
+
error, status
|
|
30
|
+
} = spawnSync('ssh-add', [ clientKey.fullPath ], SPAWN_OPTS);
|
|
31
|
+
if (error || status !== 0) {
|
|
32
|
+
console.error('Failed to add key to agent');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const username = 'Agent User';
|
|
38
|
+
const { server } = setup(
|
|
39
|
+
'Agent authentication',
|
|
40
|
+
{
|
|
41
|
+
client: { username, agent: process.env.SSH_AUTH_SOCK },
|
|
42
|
+
server: serverCfg,
|
|
43
|
+
|
|
44
|
+
debug,
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
server.on('connection', mustCall((conn) => {
|
|
49
|
+
let authAttempt = 0;
|
|
50
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
51
|
+
assert(ctx.username === username,
|
|
52
|
+
`Wrong username: ${ctx.username}`);
|
|
53
|
+
switch (++authAttempt) {
|
|
54
|
+
case 1:
|
|
55
|
+
assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
|
|
56
|
+
return ctx.reject();
|
|
57
|
+
case 3:
|
|
58
|
+
assert(ctx.signature, 'Missing publickey signature');
|
|
59
|
+
// FALLTHROUGH
|
|
60
|
+
case 2:
|
|
61
|
+
assert(ctx.method === 'publickey',
|
|
62
|
+
`Wrong auth method: ${ctx.method}`);
|
|
63
|
+
assert(ctx.key.algo === clientKey.key.type,
|
|
64
|
+
`Wrong key algo: ${ctx.key.algo}`);
|
|
65
|
+
assert.deepStrictEqual(clientKey.key.getPublicSSH(),
|
|
66
|
+
ctx.key.data,
|
|
67
|
+
'Public key mismatch');
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (ctx.signature) {
|
|
71
|
+
const result =
|
|
72
|
+
clientKey.key.verify(ctx.blob, ctx.signature, ctx.hashAlgo);
|
|
73
|
+
assert(result === true, 'Could not verify publickey signature');
|
|
74
|
+
}
|
|
75
|
+
ctx.accept();
|
|
76
|
+
}, 3)).on('ready', mustCall(() => {
|
|
77
|
+
conn.end();
|
|
78
|
+
}));
|
|
79
|
+
}));
|
|
80
|
+
} else {
|
|
81
|
+
{
|
|
82
|
+
const {
|
|
83
|
+
error, status
|
|
84
|
+
} = spawnSync('which', ['ssh-agent'], SPAWN_OPTS);
|
|
85
|
+
|
|
86
|
+
if (error || status !== 0) {
|
|
87
|
+
console.log('No ssh-agent available, skipping agent test ...');
|
|
88
|
+
process.exit(0);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
const {
|
|
94
|
+
error, status
|
|
95
|
+
} = spawnSync('which', ['ssh-add'], SPAWN_OPTS);
|
|
96
|
+
|
|
97
|
+
if (error || status !== 0) {
|
|
98
|
+
console.log('No ssh-add available, skipping agent test ...');
|
|
99
|
+
process.exit(0);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const {
|
|
104
|
+
error, status
|
|
105
|
+
} = spawnSync('ssh-agent',
|
|
106
|
+
[ process.execPath, __filename, 'child' ],
|
|
107
|
+
{ ...SPAWN_OPTS, stdio: 'inherit' });
|
|
108
|
+
if (error || status !== 0)
|
|
109
|
+
throw new Error('Agent test failed');
|
|
110
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
|
|
5
|
+
const debug = false;
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
fixtureKey,
|
|
9
|
+
mustCall,
|
|
10
|
+
setup,
|
|
11
|
+
} = require('./common.js');
|
|
12
|
+
const {
|
|
13
|
+
AgentProtocol,
|
|
14
|
+
BaseAgent,
|
|
15
|
+
utils: { parseKey },
|
|
16
|
+
} = require('../lib/index.js');
|
|
17
|
+
|
|
18
|
+
const serverCfg = { hostKeys: [ fixtureKey('ssh_host_rsa_key').raw ] };
|
|
19
|
+
|
|
20
|
+
const clientKey = fixtureKey('openssh_new_rsa');
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
let getIdentitiesCount = 0;
|
|
24
|
+
let signCount = 0;
|
|
25
|
+
class MyAgent extends BaseAgent {
|
|
26
|
+
getIdentities(cb) {
|
|
27
|
+
assert.strictEqual(++getIdentitiesCount, 1);
|
|
28
|
+
// Ensure that no private portion of the key is used by re-parsing the
|
|
29
|
+
// public version of the key
|
|
30
|
+
cb(null, [ parseKey(clientKey.key.getPublicSSH()) ]);
|
|
31
|
+
}
|
|
32
|
+
sign(pubKey, data, options, cb) {
|
|
33
|
+
assert.strictEqual(++signCount, 1);
|
|
34
|
+
assert.strictEqual(pubKey.getPublicPEM(), clientKey.key.getPublicPEM());
|
|
35
|
+
const sig = clientKey.key.sign(data, options.hash);
|
|
36
|
+
cb(null, sig);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const username = 'Agent User';
|
|
41
|
+
const { server } = setup(
|
|
42
|
+
'Custom agent authentication',
|
|
43
|
+
{
|
|
44
|
+
client: { username, agent: new MyAgent() },
|
|
45
|
+
server: serverCfg,
|
|
46
|
+
|
|
47
|
+
debug,
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
server.on('connection', mustCall((conn) => {
|
|
52
|
+
let authAttempt = 0;
|
|
53
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
54
|
+
assert(ctx.username === username,
|
|
55
|
+
`Wrong username: ${ctx.username}`);
|
|
56
|
+
switch (++authAttempt) {
|
|
57
|
+
case 1:
|
|
58
|
+
assert(ctx.method === 'none', `Wrong auth method: ${ctx.method}`);
|
|
59
|
+
return ctx.reject();
|
|
60
|
+
case 3:
|
|
61
|
+
assert(ctx.signature, 'Missing publickey signature');
|
|
62
|
+
// FALLTHROUGH
|
|
63
|
+
case 2:
|
|
64
|
+
assert(ctx.method === 'publickey',
|
|
65
|
+
`Wrong auth method: ${ctx.method}`);
|
|
66
|
+
assert(ctx.key.algo === clientKey.key.type,
|
|
67
|
+
`Wrong key algo: ${ctx.key.algo}`);
|
|
68
|
+
assert.deepStrictEqual(clientKey.key.getPublicSSH(),
|
|
69
|
+
ctx.key.data,
|
|
70
|
+
'Public key mismatch');
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (ctx.signature) {
|
|
74
|
+
const result =
|
|
75
|
+
clientKey.key.verify(ctx.blob, ctx.signature, ctx.hashAlgo);
|
|
76
|
+
assert(result === true, 'Could not verify publickey signature');
|
|
77
|
+
}
|
|
78
|
+
ctx.accept();
|
|
79
|
+
}, 3)).on('ready', mustCall(() => {
|
|
80
|
+
assert.strictEqual(getIdentitiesCount, 1);
|
|
81
|
+
assert.strictEqual(signCount, 1);
|
|
82
|
+
conn.end();
|
|
83
|
+
}));
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
{
|
|
87
|
+
const client = new AgentProtocol(true);
|
|
88
|
+
const server = new AgentProtocol(false);
|
|
89
|
+
|
|
90
|
+
server.on('identities', mustCall((req) => {
|
|
91
|
+
setImmediate(() => server.failureReply(req));
|
|
92
|
+
}));
|
|
93
|
+
client.getIdentities(mustCall((err, keys) => {
|
|
94
|
+
assert(err, 'Missing expected error');
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
client.pipe(server).pipe(client);
|
|
98
|
+
}
|
|
99
|
+
{
|
|
100
|
+
const client = new AgentProtocol(true);
|
|
101
|
+
const server = new AgentProtocol(false);
|
|
102
|
+
|
|
103
|
+
server.on('identities', mustCall((req) => {
|
|
104
|
+
const keys = [ clientKey.key ];
|
|
105
|
+
server.getIdentitiesReply(req, keys);
|
|
106
|
+
}));
|
|
107
|
+
client.getIdentities(mustCall((err, keys) => {
|
|
108
|
+
assert(!err, 'Unexpected error');
|
|
109
|
+
assert.strictEqual(keys.length, 1);
|
|
110
|
+
assert.strictEqual(keys[0].isPrivateKey(), false);
|
|
111
|
+
assert.strictEqual(keys[0].getPublicPEM(), clientKey.key.getPublicPEM());
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
client.pipe(server).pipe(client);
|
|
115
|
+
}
|
|
116
|
+
{
|
|
117
|
+
const client = new AgentProtocol(true);
|
|
118
|
+
const server = new AgentProtocol(false);
|
|
119
|
+
const buf = Buffer.from('data to sign');
|
|
120
|
+
|
|
121
|
+
server.on('sign', mustCall((req, pubKey, data, options) => {
|
|
122
|
+
assert.strictEqual(pubKey.getPublicPEM(), clientKey.key.getPublicPEM());
|
|
123
|
+
assert.deepStrictEqual(data, buf);
|
|
124
|
+
assert.strictEqual(options.hash, undefined);
|
|
125
|
+
server.failureReply(req);
|
|
126
|
+
}));
|
|
127
|
+
client.sign(clientKey.key.getPublicSSH(),
|
|
128
|
+
buf,
|
|
129
|
+
mustCall((err, signature) => {
|
|
130
|
+
assert(err, 'Missing expected error');
|
|
131
|
+
}));
|
|
132
|
+
|
|
133
|
+
client.pipe(server).pipe(client);
|
|
134
|
+
}
|
|
135
|
+
{
|
|
136
|
+
const client = new AgentProtocol(true);
|
|
137
|
+
const server = new AgentProtocol(false);
|
|
138
|
+
const buf = Buffer.from('data to sign');
|
|
139
|
+
|
|
140
|
+
server.on('sign', mustCall((req, pubKey, data, options) => {
|
|
141
|
+
assert.strictEqual(pubKey.getPublicPEM(), clientKey.key.getPublicPEM());
|
|
142
|
+
assert.deepStrictEqual(data, buf);
|
|
143
|
+
assert.strictEqual(options.hash, undefined);
|
|
144
|
+
server.signReply(req, clientKey.key.sign(data));
|
|
145
|
+
}));
|
|
146
|
+
client.sign(clientKey.key.getPublicSSH(),
|
|
147
|
+
buf,
|
|
148
|
+
mustCall((err, signature) => {
|
|
149
|
+
assert(!err, 'Unexpected error');
|
|
150
|
+
const pubKey = parseKey(clientKey.key.getPublicSSH());
|
|
151
|
+
assert.strictEqual(pubKey.verify(buf, signature), true);
|
|
152
|
+
}));
|
|
153
|
+
|
|
154
|
+
client.pipe(server).pipe(client);
|
|
155
|
+
}
|
|
156
|
+
{
|
|
157
|
+
// Test that outstanding requests are handled upon unexpected closure of the
|
|
158
|
+
// protocol stream
|
|
159
|
+
|
|
160
|
+
const client = new AgentProtocol(true);
|
|
161
|
+
const server = new AgentProtocol(false);
|
|
162
|
+
|
|
163
|
+
server.on('identities', mustCall((req) => {
|
|
164
|
+
server.destroy();
|
|
165
|
+
}));
|
|
166
|
+
client.getIdentities(mustCall((err) => {
|
|
167
|
+
assert(err, 'Missing expected error');
|
|
168
|
+
}));
|
|
169
|
+
|
|
170
|
+
client.pipe(server).pipe(client);
|
|
171
|
+
}
|