MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / sampleOnce

Function sampleOnce

graph-ui/tools/net-deny-gate.mjs:221–246  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 () => {

Callers 1

mainFunction · 0.85

Calls 5

lsofSocketsFunction · 0.85
classifyLineFunction · 0.85
processTreeFunction · 0.70
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected