Skip to content

fix(s4): add shared secret socket authentication — proper tests#215

Merged
elazarcoh merged 5 commits intomainfrom
fix/s4-socket-auth
Mar 11, 2026
Merged

fix(s4): add shared secret socket authentication — proper tests#215
elazarcoh merged 5 commits intomainfrom
fix/s4-socket-auth

Conversation

@elazarcoh
Copy link
Owner

Rebased on ci/vitest-framework. Replaced hand-rolled JS test with vitest socket-auth.test.ts. Integration tests verify wrong-secret rejection and correct-secret acceptance. Python test uses importlib.util.

@elazarcoh elazarcoh force-pushed the fix/s4-socket-auth branch from 31a1e4f to b338fa2 Compare March 7, 2026 21:13
An error occurred while trying to automatically change base from ci/vitest-framework to main March 7, 2026 21:32
@elazarcoh elazarcoh force-pushed the fix/s4-socket-auth branch from b338fa2 to 78ca494 Compare March 7, 2026 22:47
@elazarcoh elazarcoh changed the base branch from ci/vitest-framework to main March 7, 2026 22:51
@elazarcoh elazarcoh force-pushed the fix/s4-socket-auth branch from 78ca494 to 0fe9445 Compare March 7, 2026 22:52
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

✅ CI Results

🧪 Tests

Suite ✅ Passed ❌ Failed ⏭️ Skipped 📊 Total
E2E (UI) 16 0 2 18
Python Unit 114 0 0 114
TS Unit 109 0 0 109

📦 Artifacts

screenshots-ubuntu-latest  ·  test-results  ·  extension-vsix  ·  ts-unit-test-results  ·  python-unit-test-results

→ Full run details

@elazarcoh elazarcoh force-pushed the fix/s4-socket-auth branch from 0fe9445 to 1996c10 Compare March 10, 2026 22:01
elazarcoh and others added 5 commits March 11, 2026 08:14
Server generates a random 32-byte secret on startup. The secret hex is
passed to the Python client via constructOpenSendAndCloseCode. Python
sends the raw secret bytes as the first 32 bytes on each connection.
Server validates using crypto.timingSafeEqual before processing any
messages. Invalid connections are destroyed immediately.

This prevents unauthorized local processes from injecting data into
the socket even if they discover the port number.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Delete hand-rolled test_socket_auth.js (plain Node runner)
- Add socket-auth.test.ts using vitest with real SocketServer imports
- Unit tests: secretHex is non-empty hex, length = AUTH_SECRET_LENGTH*2,
  only 0-9a-f chars, different instances have different secrets
- Integration tests: wrong secret → socket destroyed; correct secret → accepted
- Mock typedi and vscode-extensions-json-generator/utils to avoid vscode host deps
- Python tests already pass without importlib migration (use raw sockets)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…spy, fix error handler

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Socket tests now require AUTH_SECRET_LENGTH (32 bytes) sent as the first
message on connection for authentication. Updated response-timeout and
max-msg-size integration tests to send the server's secret hex before
sending message payloads.

Also added missing 'vi' import to max-msg-size.test.ts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@elazarcoh elazarcoh force-pushed the fix/s4-socket-auth branch from f74459e to b3c291c Compare March 11, 2026 06:14
@elazarcoh elazarcoh enabled auto-merge March 11, 2026 06:14
@elazarcoh elazarcoh merged commit b5790b9 into main Mar 11, 2026
10 checks passed
@elazarcoh elazarcoh deleted the fix/s4-socket-auth branch March 11, 2026 06:29
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.

1 participant