Lines 989-1052javascript
990function resolveWindowsExeLocal(cmd) {
991 if (process.platform !== 'win32') return cmd;
993 const out = spawnSync('where', [cmd], {
995 stdio: ['ignore', 'pipe', 'ignore'],
999 if (out.status !== 0) return cmd;
1000 const lines = (out.stdout || '').split(/\r?\n/).map(l => l.trim()).filter(Boolean);
1001 const exe = lines.find(l => /\.exe$/i.test(l));
1002 const shim = lines.find(l => /\.(cmd|bat)$/i.test(l));
1003 return exe || shim || cmd;
1009function isPortReachableSync(host, port, timeoutMs) {
1010 const r = spawnSync(process.execPath, ['-e', `
1011 const net = require('net');
1012 const s = net.connect({ port: ${port}, host: ${JSON.stringify(host)} });
1014 s.on('connect', () => { done = true; s.destroy(); process.exit(0); });
1015 s.on('error', () => { if (!done) process.exit(1); });
1016 setTimeout(() => { if (!done) { s.destroy(); process.exit(1); } }, ${timeoutMs || 800});
1017 `], { timeout: (timeoutMs || 800) + 2000, windowsHide: true });
1018 return r.status === 0;
1021function findFreePortSync() {
1022 const r = spawnSync(process.execPath, ['-e', `
1023 const net = require('net');
1024 const srv = net.createServer();
1025 srv.listen(0, '127.0.0.1', () => { const p = srv.address().port; srv.close(() => { process.stdout.write(String(p)); }); });
1026 srv.on('error', e => { process.stderr.write(e.message); process.exit(1); });
HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
plugkit-wasm-wrapper.jsView on unpkg · L1009 1027 `], { encoding: 'utf-8', timeout: 5000 });
1028 if (r.status !== 0) throw new Error('could not allocate free port');
1029 return parseInt(r.stdout.trim(), 10);
1032function isPortAliveSync(port) {
1033 const r = spawnSync(process.execPath, ['-e', `
1034 const net = require('net');
1035 const s = net.connect({ port: ${port}, host: '127.0.0.1' });
1036 s.on('connect', () => { s.destroy(); process.exit(0); });
1037 s.on('error', () => process.exit(1));
1038 setTimeout(() => process.exit(1), 800);
1039 `], { timeout: 2000 });
1040 return r.status === 0;
1043function sleepSync(ms) {
1044 Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.max(0, ms | 0));
1047function playwriterHomeFor(cwd, claudeSessionId) {
1048 if (process.env.PLAYWRITER_HOME) return process.env.PLAYWRITER_HOME;
1049 if (!cwd) return path.join(GM_TOOLS_ROOT, `pw-sock-${sessionProfileSlug(claudeSessionId)}`);
CriticalSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution with blocking evidence.
plugkit-wasm-wrapper.jsView on unpkg · L1032 1050 try { ensureGitignored(cwd, '.gm/pw-sock-*/'); } catch (_) {}
1051 return path.join(cwd, '.gm', `pw-sock-${sessionProfileSlug(claudeSessionId)}`);