Lines 984-1047javascript
985function resolveWindowsExeLocal(cmd) {
986 if (process.platform !== 'win32') return cmd;
988 const out = spawnSync('where', [cmd], {
990 stdio: ['ignore', 'pipe', 'ignore'],
994 if (out.status !== 0) return cmd;
995 const lines = (out.stdout || '').split(/\r?\n/).map(l => l.trim()).filter(Boolean);
996 const exe = lines.find(l => /\.exe$/i.test(l));
997 const shim = lines.find(l => /\.(cmd|bat)$/i.test(l));
998 return exe || shim || cmd;
1004function isPortReachableSync(host, port, timeoutMs) {
1005 const r = spawnSync(process.execPath, ['-e', `
1006 const net = require('net');
1007 const s = net.connect({ port: ${port}, host: ${JSON.stringify(host)} });
1009 s.on('connect', () => { done = true; s.destroy(); process.exit(0); });
1010 s.on('error', () => { if (!done) process.exit(1); });
1011 setTimeout(() => { if (!done) { s.destroy(); process.exit(1); } }, ${timeoutMs || 800});
1012 `], { timeout: (timeoutMs || 800) + 2000, windowsHide: true });
1013 return r.status === 0;
1016function findFreePortSync() {
1017 const r = spawnSync(process.execPath, ['-e', `
1018 const net = require('net');
1019 const srv = net.createServer();
1020 srv.listen(0, '127.0.0.1', () => { const p = srv.address().port; srv.close(() => { process.stdout.write(String(p)); }); });
1021 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 · L1004 1022 `], { encoding: 'utf-8', timeout: 5000 });
1023 if (r.status !== 0) throw new Error('could not allocate free port');
1024 return parseInt(r.stdout.trim(), 10);
1027function isPortAliveSync(port) {
1028 const r = spawnSync(process.execPath, ['-e', `
1029 const net = require('net');
1030 const s = net.connect({ port: ${port}, host: '127.0.0.1' });
1031 s.on('connect', () => { s.destroy(); process.exit(0); });
1032 s.on('error', () => process.exit(1));
1033 setTimeout(() => process.exit(1), 800);
1034 `], { timeout: 2000 });
1035 return r.status === 0;
1038function sleepSync(ms) {
1039 Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.max(0, ms | 0));
1042function playwriterHomeFor(cwd, claudeSessionId) {
1043 if (process.env.PLAYWRITER_HOME) return process.env.PLAYWRITER_HOME;
1044 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 · L1027 1045 try { ensureGitignored(cwd, '.gm/pw-sock-*/'); } catch (_) {}
1046 return path.join(cwd, '.gm', `pw-sock-${sessionProfileSlug(claudeSessionId)}`);