Repository navigation
fix(session): reject non-positive PIDs in daemon health responses - #1222
Open
ShryukGrandhi wants to merge 1 commit into
Open
ShryukGrandhi wants to merge 1 commit into
ShryukGrandhi wants to merge 1 commit into
Conversation
Signed-off-by: ShryukGrandhi <85529990+ShryukGrandhi@users.noreply.github.com>
Contributor
|
PR author is not in the allowed authors list. |
|
@ShryukGrandhi is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Most of #765 is already handled on
main.readSessionBrokerHealthgoes throughprobeSessionBrokerHealth, which reads a bounded body and decodes it withparseSessionBrokerHealth(exact keys,ok: true, safe integers, strings, and the legacypathsshape). The one acceptance criterion still open was the PID: the decoder used the generic safe-integer check with a minimum of 0, so a health payload with"pid": 0decoded as healthy.process.kill(0, ...)signals the caller's whole process group, so a zero PID should never get through.Changes
parseSessionBrokerHealthnow requirespidto be a safe integer >= 1. That matches the check the launch-metadata decoder already does. The other counters still accept 0.MAX_SAFE_INTEGER + 1) PIDs.The restart path in
hunk daemon restart(daemonCommands.ts) signals only the PID from the validated launch metadata (parseSessionBrokerLaunchMetadata, which also requires a minimum of 1). It never uses the health payload's PID, so no restart code changes were needed.Testing
bun test packages/hunk/src/session/broker/brokerLauncher.test.ts: the newpid: 0case fails before the fix and passes after it.bun test packages/hunk/src/session: 443 pass, 1 fail. The failing test is a timing-sensitive daemon-server test (keeps a silent session past the stale TTL...). It is not related to this change: it and other daemon-server tests also failed intermittently on unmodifiedmainon the same machine.bun run typecheck,oxlint, andoxfmton the touched files are clean.Fixes #765