@pyrokine/mcp-ssh 3.2.0 → 3.3.1
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/README.md +84 -22
- package/README_zh.md +45 -12
- package/dist/command-risk.js +1 -1
- package/dist/directory-verification.js +10 -10
- package/dist/file-ops.d.ts +9 -5
- package/dist/file-ops.js +165 -58
- package/dist/known-hosts.d.ts +2 -2
- package/dist/known-hosts.js +110 -59
- package/dist/openssh.d.ts +5 -5
- package/dist/openssh.js +92 -38
- package/dist/remote-platform.js +2 -2
- package/dist/session-manager.d.ts +7 -1
- package/dist/session-manager.js +140 -23
- package/dist/sftp-timeout.d.ts +1 -1
- package/dist/sftp-timeout.js +12 -2
- package/dist/tools/connection.js +14 -10
- package/dist/tools/exec.js +66 -35
- package/dist/tools/file.js +93 -21
- package/dist/transfer-outcome.js +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/windows-acl.d.ts +3 -2
- package/dist/windows-acl.js +23 -10
- package/package.json +5 -5
package/dist/windows-acl.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { encodedPowershell, quotePowershell } from './remote-platform.js';
|
|
3
|
+
export function getWindowsPowerShellEnv() {
|
|
4
|
+
return Object.fromEntries(Object.entries(process.env).filter(([name]) => name.toLowerCase() !== 'psmodulepath'));
|
|
5
|
+
}
|
|
3
6
|
export function windowsAclScript(filePath, apply) {
|
|
4
7
|
const target = quotePowershell(filePath);
|
|
5
8
|
return ('\n' +
|
|
@@ -24,8 +27,8 @@ export function windowsAclScript(filePath, apply) {
|
|
|
24
27
|
'}\n' +
|
|
25
28
|
'foreach ($sid in @($identity, $system, $administrators)) {\n' +
|
|
26
29
|
' $rule = [System.Security.AccessControl.FileSystemAccessRule]::ne' +
|
|
27
|
-
'w($sid, [System.Security.AccessControl.FileSystemRights]::
|
|
28
|
-
'
|
|
30
|
+
'w($sid, [System.Security.AccessControl.FileSystemRights]::' +
|
|
31
|
+
'FullControl, [System.Security.AccessControl.AccessControlType]::Allow)\n' +
|
|
29
32
|
' $acl.AddAccessRule($rule)\n' +
|
|
30
33
|
'}\n' +
|
|
31
34
|
'Set-Acl -LiteralPath $path -AclObject $acl\n' +
|
|
@@ -90,10 +93,10 @@ export function windowsTemporaryPathScript(name) {
|
|
|
90
93
|
' }\n' +
|
|
91
94
|
' $rights = [System.Security.AccessControl.FileSystemRights]::Delete ' +
|
|
92
95
|
'-bor\n' +
|
|
93
|
-
' [System.Security.AccessControl.FileSystemRights]::
|
|
94
|
-
'
|
|
95
|
-
' [System.Security.AccessControl.FileSystemRights]::
|
|
96
|
-
'
|
|
96
|
+
' [System.Security.AccessControl.FileSystemRights]::' +
|
|
97
|
+
'DeleteSubdirectoriesAndFiles -bor\n' +
|
|
98
|
+
' [System.Security.AccessControl.FileSystemRights]::' +
|
|
99
|
+
'ChangePermissions -bor\n' +
|
|
97
100
|
' [System.Security.AccessControl.FileSystemRights]::TakeOwnership\n' +
|
|
98
101
|
' if ($current.FullName -eq $directory.FullName) {\n' +
|
|
99
102
|
' $rights = $rights -bor ' +
|
|
@@ -117,10 +120,14 @@ export function windowsTemporaryPathScript(name) {
|
|
|
117
120
|
`${quotePowershell(name)}` +
|
|
118
121
|
'))\n');
|
|
119
122
|
}
|
|
120
|
-
export function checkWindowsKnownHostsIntegrity(filePath) {
|
|
123
|
+
export function checkWindowsKnownHostsIntegrity(filePath, deadline) {
|
|
121
124
|
if (process.platform !== 'win32') {
|
|
122
125
|
throw new Error('Windows ACL verification requires a native Windows process');
|
|
123
126
|
}
|
|
127
|
+
const timeout = deadline === undefined ? 10_000 : Math.min(10_000, deadline - Date.now());
|
|
128
|
+
if (timeout <= 0) {
|
|
129
|
+
throw new Error('known_hosts verification deadline exhausted');
|
|
130
|
+
}
|
|
124
131
|
const script = "$ErrorActionPreference = 'Stop'\n" +
|
|
125
132
|
'$identity = [Security.Principal.WindowsIdentity]::GetCurrent().User.Valu' +
|
|
126
133
|
'e\n' +
|
|
@@ -165,7 +172,8 @@ export function checkWindowsKnownHostsIntegrity(filePath) {
|
|
|
165
172
|
"[Console]::Write('verified')";
|
|
166
173
|
const encoded = encodedPowershell(script).split(' ').at(-1);
|
|
167
174
|
const result = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-EncodedCommand', encoded], {
|
|
168
|
-
timeout
|
|
175
|
+
timeout,
|
|
176
|
+
env: getWindowsPowerShellEnv(),
|
|
169
177
|
encoding: 'utf8',
|
|
170
178
|
windowsHide: true,
|
|
171
179
|
maxBuffer: 16_384,
|
|
@@ -174,14 +182,19 @@ export function checkWindowsKnownHostsIntegrity(filePath) {
|
|
|
174
182
|
throw new Error('known_hosts write integrity could not be verified on Windows');
|
|
175
183
|
}
|
|
176
184
|
}
|
|
177
|
-
export function checkWindowsAcl(filePath, apply = false) {
|
|
185
|
+
export function checkWindowsAcl(filePath, apply = false, deadline) {
|
|
178
186
|
if (process.platform !== 'win32') {
|
|
179
187
|
throw new Error('Windows ACL verification requires a native Windows process');
|
|
180
188
|
}
|
|
189
|
+
const timeout = deadline === undefined ? 10_000 : Math.min(10_000, deadline - Date.now());
|
|
190
|
+
if (timeout <= 0) {
|
|
191
|
+
return 'key_acl_unverified';
|
|
192
|
+
}
|
|
181
193
|
const command = encodedPowershell(windowsAclScript(filePath, apply));
|
|
182
194
|
const encoded = command.split(' ').at(-1);
|
|
183
195
|
const result = spawnSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-EncodedCommand', encoded], {
|
|
184
|
-
timeout
|
|
196
|
+
timeout,
|
|
197
|
+
env: getWindowsPowerShellEnv(),
|
|
185
198
|
encoding: 'utf8',
|
|
186
199
|
windowsHide: true,
|
|
187
200
|
maxBuffer: 16_384,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyrokine/mcp-ssh",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "A comprehensive SSH MCP Server for Claude Code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.mjs\"",
|
|
17
17
|
"lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.mjs\" --fix",
|
|
18
18
|
"test": "npm run build && node test/run-tests.mjs",
|
|
19
|
-
"format": "prettier --write
|
|
20
|
-
"format:check": "prettier --check
|
|
19
|
+
"format": "prettier --write . --ignore-path ../.gitignore --ignore-path ../.prettierignore",
|
|
20
|
+
"format:check": "prettier --check . --ignore-path ../.gitignore --ignore-path ../.prettierignore"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"mcp",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/node": "^26.1.1",
|
|
44
44
|
"@types/ssh2": "^1.15.5",
|
|
45
45
|
"eslint": "^10.7.0",
|
|
46
|
-
"prettier": "
|
|
46
|
+
"prettier": "3.9.5",
|
|
47
47
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
48
48
|
"typescript-eslint": "^8.64.0",
|
|
49
49
|
"typescript7": "npm:typescript@^7.0.2"
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"README_zh.md",
|
|
58
58
|
"LICENSE"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "3cdfd27ab6a62e45882e64ef05b9c49f82694604"
|
|
61
61
|
}
|