Skip to content

test(security): count only bridge connections on the fake VNC server - #503

Open
phatloi0010 wants to merge 1 commit into
pickforge:mainfrom
phatloi0010:fix/viewer-bridge-socket-count-492
Open

phatloi0010 wants to merge 1 commit into
pickforge:mainfrom
phatloi0010:fix/viewer-bridge-socket-count-492

Conversation

@phatloi0010

Copy link
Copy Markdown

Summary

test/security/security-viewer-bridge.test.ts starts a fake loopback VNC server (upstream) in beforeEach and previously pushed every accepted TCP socket into sockets. On a host where a local process probes new loopback listeners (such as an IDE port detector / T3 Code, as in #480), those external connections were appended to sockets and broke expect(sockets).toHaveLength(0) assertions in tests where the viewer bridge rightly refused to connect to VNC.

This change verifies that the client side of an accepted loopback connection on upstream belongs to the current test process (process.pid) by matching the peer endpoint (0100007F:<remotePort> -> 0100007F:<localPort>) in /proc/net/tcp against socket descriptors in /proc/<pid>/fd. Connections from any other process are immediately destroyed (so a local port prober that keeps its end open also cannot hold upstream.close() open in afterEach) and excluded from sockets.

Other test servers across test/ and packages/*/test/ that count connections (native-viewer-host.test.ts, desktop-linux/test/integration.test.ts, x11-fixture.ts, request-takeover.test.ts) listen on Unix domain sockets rather than loopback TCP ports, and devtools.test.ts counts HTTP requests rather than raw TCP connections.

Closes #492

No device pass: this changes one test file and no product behavior.

Requirement Verification Scenario and edge cases Result
Count only connections the bridge makes on upstream Peer inode check against /proc/net/tcp and /proc/<pid>/fd; immediate socket.destroy() for foreign peers Bridge connections in process.pid are recorded in sockets; external port prober connections are destroyed and ignored Passed
Check other tests that count connections to a loopback test server Audit all createServer listeners across test/ and packages/*/test/ Other connection-counting servers bind Unix sockets (host.sock, busPath, this.socketPath), not loopback TCP ports Confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(security): viewer bridge socket counts include connections from a local port prober

1 participant