@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.
@@ -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]::FullContro' +
28
- 'l, [System.Security.AccessControl.AccessControlType]::Allow)\n' +
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]::DeleteSubdirec' +
94
- 'toriesAndFiles -bor\n' +
95
- ' [System.Security.AccessControl.FileSystemRights]::ChangePermissi' +
96
- 'ons -bor\n' +
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: 10_000,
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: 10_000,
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.2.0",
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 src/ test/ README.md README_zh.md TESTING.md",
20
- "format:check": "prettier --check src/ test/ README.md README_zh.md TESTING.md"
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": "^3.9.5",
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": "ca40950f56a051845f89c3b4b673bf5825c0e199"
60
+ "gitHead": "3cdfd27ab6a62e45882e64ef05b9c49f82694604"
61
61
  }