bdy 1.26.10 → 1.26.11-beta
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 +2 -2
- package/distTs/src/command/agent/selftest.js +2 -3
- package/distTs/src/index.js +0 -8
- package/distTs/src/sshChannelWindow.js +45 -124
- package/distTs/src/sshKex.js +32 -0
- package/distTs/src/sshKeygen.js +1 -10
- package/distTs/src/tunnel/server/sftp.js +0 -24
- package/distTs/src/tunnel/server/ssh.js +4 -2
- package/distTs/src/tunnel/ssh/client.js +11 -12
- package/node_modules/ssh2/.github/workflows/ci.yml +12 -18
- package/node_modules/ssh2/.github/workflows/lint.yml +2 -2
- package/node_modules/ssh2/README.md +30 -8
- package/node_modules/ssh2/lib/Channel.js +38 -3
- package/node_modules/ssh2/lib/agent.js +3 -101
- package/node_modules/ssh2/lib/client.js +30 -10
- package/node_modules/ssh2/lib/keygen.js +6 -7
- package/node_modules/ssh2/lib/protocol/Protocol.js +3 -1
- package/node_modules/ssh2/lib/protocol/SFTP.js +8 -0
- package/node_modules/ssh2/lib/protocol/constants.js +21 -0
- package/node_modules/ssh2/lib/protocol/crypto/src/binding.cc +33 -32
- package/node_modules/ssh2/lib/protocol/kex.js +122 -0
- package/node_modules/ssh2/lib/protocol/zlib.js +11 -1
- package/node_modules/ssh2/lib/server.js +57 -12
- package/node_modules/ssh2/package.json +9 -6
- package/node_modules/ssh2/test/test-channel-window.js +142 -0
- package/node_modules/ssh2/test/test-destroy.js +97 -0
- package/node_modules/ssh2/test/test-integration-openssh.js +70 -7
- package/node_modules/ssh2/test/test-kex-mlkem.js +211 -0
- package/node_modules/ssh2/test/test-keygen.js +16 -6
- package/node_modules/ssh2/test/test-late-write.js +61 -0
- package/node_modules/ssh2/test/test-misc-client-server.js +29 -0
- package/node_modules/ssh2/test/test-nodelay.js +54 -0
- package/node_modules/ssh2/test/test-protocol-keyparser.js +1 -1
- package/node_modules/ssh2/test/test-sftp.js +33 -0
- package/node_modules/ssh2/test/test-userauth-signature.js +157 -0
- package/package.json +2 -2
- package/node_modules/ssh2/util/build_pagent.bat +0 -2
- package/node_modules/ssh2/util/pagent.c +0 -88
- package/node_modules/ssh2/util/pagent.exe +0 -0
|
@@ -60,6 +60,35 @@ const setup = setupSimple.bind(undefined, debug);
|
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
{
|
|
64
|
+
const ident = 'ident-for-verifier';
|
|
65
|
+
const { server } = setup_(
|
|
66
|
+
'Verify host fingerprint (server identification passed)',
|
|
67
|
+
{
|
|
68
|
+
client: {
|
|
69
|
+
...clientCfg,
|
|
70
|
+
hostVerifier: mustCall((key, verify, info) => {
|
|
71
|
+
assert(Buffer.isBuffer(key), 'Expected buffer');
|
|
72
|
+
assert.strictEqual(typeof verify, 'function');
|
|
73
|
+
assert.strictEqual(info.header.identRaw, `SSH-2.0-${ident}`);
|
|
74
|
+
assert.strictEqual(info.header.versions.protocol, '2.0');
|
|
75
|
+
assert.strictEqual(info.header.versions.software, ident);
|
|
76
|
+
return true;
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
server: { ...serverCfg, ident },
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
server.on('connection', mustCall((conn) => {
|
|
84
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
85
|
+
ctx.accept();
|
|
86
|
+
})).on('ready', mustCall(() => {
|
|
87
|
+
conn.end();
|
|
88
|
+
}));
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
|
|
63
92
|
{
|
|
64
93
|
const { server } = setup_(
|
|
65
94
|
'Verify host fingerprint (sync success, hostHash not set)',
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
const { Socket } = require('net');
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
fixture,
|
|
8
|
+
mustCall,
|
|
9
|
+
setup,
|
|
10
|
+
} = require('./common.js');
|
|
11
|
+
|
|
12
|
+
const debug = false;
|
|
13
|
+
|
|
14
|
+
// Which sockets had setNoDelay() called on them, and with what
|
|
15
|
+
const calls = new Map();
|
|
16
|
+
const setNoDelay = Socket.prototype.setNoDelay;
|
|
17
|
+
Socket.prototype.setNoDelay = function(noDelay) {
|
|
18
|
+
calls.set(this, noDelay);
|
|
19
|
+
return setNoDelay.call(this, noDelay);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Before connect() there is no socket yet: the setting has to wait for it
|
|
23
|
+
[
|
|
24
|
+
{ desc: 'no argument', args: [], expected: true },
|
|
25
|
+
{ desc: 'true', args: [ true ], expected: true },
|
|
26
|
+
{ desc: 'false', args: [ false ], expected: false },
|
|
27
|
+
{ desc: 'not called', args: undefined, expected: undefined },
|
|
28
|
+
].forEach(({ desc, args, expected }) => {
|
|
29
|
+
const { client, server } = setup(
|
|
30
|
+
`setNoDelay() before connect() (${desc})`,
|
|
31
|
+
{
|
|
32
|
+
client: { username: 'foo', password: 'bar' },
|
|
33
|
+
server: { hostKeys: [ fixture('ssh_host_rsa_key') ] },
|
|
34
|
+
debug,
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
if (args)
|
|
39
|
+
assert.strictEqual(client.setNoDelay(...args), client);
|
|
40
|
+
|
|
41
|
+
server.on('connection', mustCall((conn) => {
|
|
42
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
43
|
+
ctx.accept();
|
|
44
|
+
}));
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
client.on('ready', mustCall(() => {
|
|
48
|
+
assert.strictEqual(calls.get(client._sock), expected);
|
|
49
|
+
// And still reaches a socket that exists
|
|
50
|
+
client.setNoDelay(false);
|
|
51
|
+
assert.strictEqual(calls.get(client._sock), false);
|
|
52
|
+
client.end();
|
|
53
|
+
}));
|
|
54
|
+
});
|
|
@@ -120,7 +120,7 @@ readdirSync(BASE_PATH).forEach((name) => {
|
|
|
120
120
|
'Expected error during parse with an incorrect passphrase',
|
|
121
121
|
true);
|
|
122
122
|
}
|
|
123
|
-
if (!/bad passphrase\?|unable to authenticate data/i
|
|
123
|
+
if (!/bad passphrase\?|unable to authenticate data|bad decrypt/i
|
|
124
124
|
.test(errIncPass.message)) {
|
|
125
125
|
failMsg(name,
|
|
126
126
|
'Error during parse with an incorrect passphrase: '
|
|
@@ -755,6 +755,39 @@ setup('WriteStream', mustCall((client, server) => {
|
|
|
755
755
|
}));
|
|
756
756
|
}
|
|
757
757
|
|
|
758
|
+
|
|
759
|
+
{
|
|
760
|
+
const { client, server } = setup_(
|
|
761
|
+
'SFTP server destroy() sends exit-status 0',
|
|
762
|
+
{
|
|
763
|
+
client: { username: 'foo', password: 'bar' },
|
|
764
|
+
server: { hostKeys: [ fixture('ssh_host_rsa_key') ] },
|
|
765
|
+
},
|
|
766
|
+
);
|
|
767
|
+
|
|
768
|
+
server.on('connection', mustCall((conn) => {
|
|
769
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
770
|
+
ctx.accept();
|
|
771
|
+
})).on('ready', mustCall(() => {
|
|
772
|
+
conn.on('session', mustCall((accept, reject) => {
|
|
773
|
+
accept().on('sftp', mustCall((accept, reject) => {
|
|
774
|
+
const sftp = accept();
|
|
775
|
+
sftp.destroy();
|
|
776
|
+
}));
|
|
777
|
+
}));
|
|
778
|
+
}));
|
|
779
|
+
}));
|
|
780
|
+
|
|
781
|
+
client.on('ready', mustCall(() => {
|
|
782
|
+
const timeout = setTimeout(mustNotCall(), 1000);
|
|
783
|
+
client.sftp(mustCall((err, sftp) => {
|
|
784
|
+
clearTimeout(timeout);
|
|
785
|
+
assert(err, 'Expected error');
|
|
786
|
+
assert(err.code === 0, `Expected exit code 0, saw: ${err.code}`);
|
|
787
|
+
client.end();
|
|
788
|
+
}));
|
|
789
|
+
}));
|
|
790
|
+
}
|
|
758
791
|
{
|
|
759
792
|
const { client, server } = setup_(
|
|
760
793
|
'SFTP client sets environment',
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('assert');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
fixture,
|
|
7
|
+
fixtureKey,
|
|
8
|
+
mustCall,
|
|
9
|
+
mustNotCall,
|
|
10
|
+
setup,
|
|
11
|
+
} = require('./common.js');
|
|
12
|
+
|
|
13
|
+
const { generateKeyPairSync, parseKey } = require('../lib/index.js').utils;
|
|
14
|
+
|
|
15
|
+
const serverCfg = { hostKeys: [ fixture('ssh_host_rsa_key') ] };
|
|
16
|
+
// There is no Ed25519 fixture
|
|
17
|
+
const ed25519Key = (() => {
|
|
18
|
+
const raw = generateKeyPairSync('ed25519').private;
|
|
19
|
+
return { raw, key: parseKey(raw) };
|
|
20
|
+
})();
|
|
21
|
+
const debug = false;
|
|
22
|
+
|
|
23
|
+
// accept() only logs a client in with a signature made with the key it
|
|
24
|
+
// offered. An application that accepts as soon as it recognizes the public
|
|
25
|
+
// key, which is not a secret, must not be logging in whoever knows that key.
|
|
26
|
+
const otherKey = fixtureKey('openssh_new_rsa');
|
|
27
|
+
const forgeries = {
|
|
28
|
+
'signature changed': (ctx) => {
|
|
29
|
+
ctx.signature[ctx.signature.length - 1] ^= 0x01;
|
|
30
|
+
},
|
|
31
|
+
'signature of other data': (ctx) => {
|
|
32
|
+
ctx.blob = Buffer.concat([ ctx.blob, Buffer.from('x') ]);
|
|
33
|
+
},
|
|
34
|
+
'signature of another key': (ctx) => {
|
|
35
|
+
ctx.key = {
|
|
36
|
+
algo: otherKey.key.type,
|
|
37
|
+
data: otherKey.key.getPublicSSH(),
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
'no data that was signed': (ctx) => {
|
|
41
|
+
ctx.blob = undefined;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
[
|
|
46
|
+
{ desc: 'RSA', clientKey: fixtureKey('id_rsa') },
|
|
47
|
+
{ desc: 'ECDSA', clientKey: fixtureKey('id_ecdsa') },
|
|
48
|
+
{ desc: 'Ed25519', clientKey: ed25519Key },
|
|
49
|
+
].forEach(({ desc, clientKey }) => {
|
|
50
|
+
// What the client really sent is accepted
|
|
51
|
+
{
|
|
52
|
+
const { server } = setup(
|
|
53
|
+
`publickey, ${desc}: valid signature`,
|
|
54
|
+
{
|
|
55
|
+
client: { username: 'foo', privateKey: clientKey.raw },
|
|
56
|
+
server: serverCfg,
|
|
57
|
+
debug,
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
server.on('connection', mustCall((conn) => {
|
|
62
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
63
|
+
if (ctx.method !== 'publickey')
|
|
64
|
+
return ctx.reject();
|
|
65
|
+
ctx.accept();
|
|
66
|
+
}, 3)).on('ready', mustCall(() => {
|
|
67
|
+
conn.end();
|
|
68
|
+
}));
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
for (const [ how, forge ] of Object.entries(forgeries)) {
|
|
73
|
+
const { client, server } = setup(
|
|
74
|
+
`publickey, ${desc}: ${how}`,
|
|
75
|
+
{
|
|
76
|
+
client: { username: 'foo', privateKey: clientKey.raw },
|
|
77
|
+
server: serverCfg,
|
|
78
|
+
debug,
|
|
79
|
+
noForceClientReady: true,
|
|
80
|
+
noForceServerReady: true,
|
|
81
|
+
noClientError: true,
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
server.on('connection', mustCall((conn) => {
|
|
86
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
87
|
+
if (ctx.method !== 'publickey')
|
|
88
|
+
return ctx.reject();
|
|
89
|
+
// The key query, which authenticates nobody, goes through as it is
|
|
90
|
+
if (ctx.signature)
|
|
91
|
+
forge(ctx);
|
|
92
|
+
ctx.accept();
|
|
93
|
+
}, 3)).on('ready', mustNotCall());
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
client.on('ready', mustNotCall()).on('error', mustCall((err) => {
|
|
97
|
+
assert.strictEqual(err.level, 'client-authentication');
|
|
98
|
+
assert(/All configured authentication methods failed/.test(err.message),
|
|
99
|
+
`Wrong error: ${err.message}`);
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// The same for hostbased, where the signature is the host's
|
|
105
|
+
{
|
|
106
|
+
const clientKey = fixtureKey('id_rsa');
|
|
107
|
+
const clientCfg = {
|
|
108
|
+
username: 'foo',
|
|
109
|
+
privateKey: clientKey.raw,
|
|
110
|
+
localUsername: 'Local User',
|
|
111
|
+
localHostname: 'Local Host',
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
{
|
|
115
|
+
const { server } = setup(
|
|
116
|
+
'hostbased: valid signature',
|
|
117
|
+
{ client: clientCfg, server: serverCfg, debug }
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
server.on('connection', mustCall((conn) => {
|
|
121
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
122
|
+
if (ctx.method !== 'hostbased')
|
|
123
|
+
return ctx.reject();
|
|
124
|
+
ctx.accept();
|
|
125
|
+
}, 3)).on('ready', mustCall(() => {
|
|
126
|
+
conn.end();
|
|
127
|
+
}));
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
{
|
|
132
|
+
const { client, server } = setup(
|
|
133
|
+
'hostbased: signature changed',
|
|
134
|
+
{
|
|
135
|
+
client: clientCfg,
|
|
136
|
+
server: serverCfg,
|
|
137
|
+
debug,
|
|
138
|
+
noForceClientReady: true,
|
|
139
|
+
noForceServerReady: true,
|
|
140
|
+
noClientError: true,
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
server.on('connection', mustCall((conn) => {
|
|
145
|
+
conn.on('authentication', mustCall((ctx) => {
|
|
146
|
+
if (ctx.method !== 'hostbased')
|
|
147
|
+
return ctx.reject();
|
|
148
|
+
forgeries['signature changed'](ctx);
|
|
149
|
+
ctx.accept();
|
|
150
|
+
}, 3)).on('ready', mustNotCall());
|
|
151
|
+
}));
|
|
152
|
+
|
|
153
|
+
client.on('ready', mustNotCall()).on('error', mustCall((err) => {
|
|
154
|
+
assert.strictEqual(err.level, 'client-authentication');
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
157
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.26.
|
|
4
|
+
"version": "1.26.11-beta",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://buddy.works/docs/cli",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"puppeteer-core": "25.16.0",
|
|
90
90
|
"range-parser": "1.2.1",
|
|
91
91
|
"socket.io-client": "4.8.3",
|
|
92
|
-
"ssh2": "1.17.0",
|
|
92
|
+
"ssh2": "npm:@buddy-works/ssh2@1.17.0-pq.1",
|
|
93
93
|
"tar-stream": "3.2.0",
|
|
94
94
|
"terminal-kit": "3.1.2",
|
|
95
95
|
"undici": "8.12.3",
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
#include <windows.h>
|
|
2
|
-
#include <stdio.h>
|
|
3
|
-
#include <fcntl.h>
|
|
4
|
-
|
|
5
|
-
#define AGENT_COPYDATA_ID 0x804e50ba
|
|
6
|
-
#define AGENT_MAX_MSGLEN 8192
|
|
7
|
-
|
|
8
|
-
#define GET_32BIT_MSB_FIRST(cp) \
|
|
9
|
-
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
|
|
10
|
-
((unsigned long)(unsigned char)(cp)[1] << 16) | \
|
|
11
|
-
((unsigned long)(unsigned char)(cp)[2] << 8) | \
|
|
12
|
-
((unsigned long)(unsigned char)(cp)[3]))
|
|
13
|
-
|
|
14
|
-
#define GET_32BIT(cp) GET_32BIT_MSB_FIRST(cp)
|
|
15
|
-
|
|
16
|
-
#define RET_ERR_BADARGS 10
|
|
17
|
-
#define RET_ERR_UNAVAILABLE 11
|
|
18
|
-
#define RET_ERR_NOMAP 12
|
|
19
|
-
#define RET_ERR_BINSTDIN 13
|
|
20
|
-
#define RET_ERR_BINSTDOUT 14
|
|
21
|
-
#define RET_ERR_BADLEN 15
|
|
22
|
-
|
|
23
|
-
#define RET_NORESPONSE 1
|
|
24
|
-
#define RET_RESPONSE 0
|
|
25
|
-
|
|
26
|
-
int main (int argc, const char* argv[]) {
|
|
27
|
-
HWND hwnd;
|
|
28
|
-
char *mapname;
|
|
29
|
-
HANDLE filemap;
|
|
30
|
-
unsigned char *p, *ret;
|
|
31
|
-
int id, retlen, inlen, n, rmode, r = RET_NORESPONSE;
|
|
32
|
-
COPYDATASTRUCT cds;
|
|
33
|
-
void *in;
|
|
34
|
-
|
|
35
|
-
if (argc < 2)
|
|
36
|
-
return RET_ERR_BADARGS;
|
|
37
|
-
|
|
38
|
-
hwnd = FindWindow("Pageant", "Pageant");
|
|
39
|
-
if (!hwnd)
|
|
40
|
-
return RET_ERR_UNAVAILABLE;
|
|
41
|
-
|
|
42
|
-
rmode = _setmode(_fileno(stdin), _O_BINARY);
|
|
43
|
-
if (rmode == -1)
|
|
44
|
-
return RET_ERR_BINSTDIN;
|
|
45
|
-
|
|
46
|
-
rmode = _setmode(_fileno(stdout), _O_BINARY);
|
|
47
|
-
if (rmode == -1)
|
|
48
|
-
return RET_ERR_BINSTDOUT;
|
|
49
|
-
|
|
50
|
-
inlen = atoi(argv[1]);
|
|
51
|
-
in = malloc(inlen);
|
|
52
|
-
n = fread(in, 1, inlen, stdin);
|
|
53
|
-
if (n != inlen) {
|
|
54
|
-
free(in);
|
|
55
|
-
return RET_ERR_BADLEN;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
mapname = malloc(32);
|
|
59
|
-
n = sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId());
|
|
60
|
-
|
|
61
|
-
filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
|
|
62
|
-
0, AGENT_MAX_MSGLEN, mapname);
|
|
63
|
-
if (filemap == NULL || filemap == INVALID_HANDLE_VALUE) {
|
|
64
|
-
free(in);
|
|
65
|
-
free(mapname);
|
|
66
|
-
return RET_ERR_NOMAP;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, 0);
|
|
70
|
-
memcpy(p, in, inlen);
|
|
71
|
-
cds.dwData = AGENT_COPYDATA_ID;
|
|
72
|
-
cds.cbData = 1 + n;
|
|
73
|
-
cds.lpData = mapname;
|
|
74
|
-
|
|
75
|
-
id = SendMessage(hwnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) &cds);
|
|
76
|
-
if (id > 0) {
|
|
77
|
-
r = RET_RESPONSE;
|
|
78
|
-
retlen = 4 + GET_32BIT(p);
|
|
79
|
-
fwrite(p, 1, retlen, stdout);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
free(in);
|
|
83
|
-
free(mapname);
|
|
84
|
-
UnmapViewOfFile(p);
|
|
85
|
-
CloseHandle(filemap);
|
|
86
|
-
|
|
87
|
-
return r;
|
|
88
|
-
}
|
|
Binary file
|