fix: carry immutable hash in command dispatch

This commit is contained in:
2026-09-06 07:35:51 +00:00
parent 467ca65f60
commit f2d89d5b45
7 changed files with 30 additions and 13 deletions
+1 -1
View File
@@ -188,7 +188,7 @@ func validateClientHello(hello *rvboxv1.ClientHello) error {
}
func validateCommandDispatch(dispatch *rvboxv1.CommandDispatch, limits Limits, peerPlatform rvboxv1.Platform) error {
if dispatch == nil || dispatch.CommandRevision == 0 || dispatch.TargetSessionGeneration == 0 || dispatch.IssueTime == nil || dispatch.IssueTime.CheckValid() != nil {
if dispatch == nil || dispatch.CommandRevision == 0 || dispatch.TargetSessionGeneration == 0 || dispatch.IssueTime == nil || dispatch.IssueTime.CheckValid() != nil || len(dispatch.ImmutableRequestSha256) != sha256.Size {
return fmt.Errorf("%w: invalid command dispatch", ErrInvalidEnvelope)
}
if err := validateIssueUUID(dispatch.IssueUuid); err != nil {
+3 -1
View File
@@ -2,6 +2,7 @@ package agentproto
import (
"bytes"
"crypto/sha256"
"errors"
"strings"
"testing"
@@ -140,7 +141,7 @@ func TestWindowsEnvironmentCaseCollision_BH_LAUNCH_01(t *testing.T) {
func TestCommandDispatchUUIDRevisionAndTimestamp_BH_IDEM_01(t *testing.T) {
t.Parallel()
dispatch := &rvboxv1.CommandDispatch{IssueUuid: testIssueUUID, CommandRevision: 1, TargetSessionGeneration: 2, IssueTime: fixedTimestamp(), Spec: validCommandSpec()}
dispatch := &rvboxv1.CommandDispatch{IssueUuid: testIssueUUID, CommandRevision: 1, TargetSessionGeneration: 2, IssueTime: fixedTimestamp(), Spec: validCommandSpec(), ImmutableRequestSha256: make([]byte, sha256.Size)}
envelope := &rvboxv1.AgentEnvelope{SessionId: "session", SessionGeneration: 2, Payload: &rvboxv1.AgentEnvelope_CommandDispatch{CommandDispatch: dispatch}}
if err := ValidateEnvelope(envelope, DefaultLimits(), rvboxv1.Platform_PLATFORM_LINUX); err != nil {
t.Fatalf("valid dispatch: %v", err)
@@ -149,6 +150,7 @@ func TestCommandDispatchUUIDRevisionAndTimestamp_BH_IDEM_01(t *testing.T) {
func(value *rvboxv1.CommandDispatch) { value.IssueUuid = "not-a-uuid" },
func(value *rvboxv1.CommandDispatch) { value.CommandRevision = 0 },
func(value *rvboxv1.CommandDispatch) { value.TargetSessionGeneration = 0 },
func(value *rvboxv1.CommandDispatch) { value.ImmutableRequestSha256 = nil },
func(value *rvboxv1.CommandDispatch) {
value.IssueTime = timestamppb.New(time.Date(10000, 1, 1, 0, 0, 0, 0, time.UTC))
},