()
| 219 | let running = true; |
| 220 | |
| 221 | const sampleOnce = async () => { |
| 222 | const pids = child.pid ? await processTree(child.pid) : []; |
| 223 | maxTreeSize = Math.max(maxTreeSize, pids.length); |
| 224 | const { lines, error } = await lsofSockets(pids); |
| 225 | if (error !== null) { lsofErrors += 1; } |
| 226 | samples += 1; |
| 227 | for (const line of lines) { |
| 228 | const socket = classifyLine(line); |
| 229 | if (socket === null) { continue; } |
| 230 | if (socket.loopback) { |
| 231 | const key = `${socket.protocol} ${socket.remote}`; |
| 232 | loopback.set(key, (loopback.get(key) ?? 0) + 1); |
| 233 | continue; |
| 234 | } |
| 235 | violations.push({ |
| 236 | atMs: Date.now() - started, |
| 237 | protocol: socket.protocol, |
| 238 | command: socket.command, |
| 239 | pid: socket.pid, |
| 240 | local: socket.local, |
| 241 | remote: socket.remote, |
| 242 | remoteHost: socket.remoteHost, |
| 243 | remotePort: socket.remotePort, |
| 244 | }); |
| 245 | } |
| 246 | }; |
| 247 | |
| 248 | const warmupMs = Math.max(50, Math.floor(options.intervalMs / 4)); |
| 249 | const sampler = (async () => { |
no test coverage detected