From 3791a745692d8c3d951f7442229170e5b8736be9 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Sun, 23 Aug 2026 12:07:27 -0400 Subject: [PATCH] fix(sandbox): align canonical spec with msb 0.6.8 runtime defaults --- backend/src/services/sandbox/command.ts | 6 ++++-- backend/test/routes/internal-sandbox.test.ts | 4 ++-- backend/test/services/sandbox/command.test.ts | 6 +++--- backend/test/services/sandbox/runtime.test.ts | 12 ++++++------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/src/services/sandbox/command.ts b/backend/src/services/sandbox/command.ts index 394f10ca..4a64c135 100644 --- a/backend/src/services/sandbox/command.ts +++ b/backend/src/services/sandbox/command.ts @@ -9,6 +9,8 @@ export const SANDBOX_UNAVAILABLE_PREFIX = 'Sandbox enforcement is on but the san const SANDBOX_PLAN_REQUEST_MARGIN_MS = 30000 +const MSB_METRICS_SAMPLE_INTERVAL_MS = 1000 + export function sandboxPlanTimeoutMs(): number { return ENV.SANDBOX.START_TIMEOUT_MS + SANDBOX_PLAN_REQUEST_MARGIN_MS } @@ -237,7 +239,7 @@ export function resolveExpectedSandboxNetworkPolicy(netProfile: string): Sandbox default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, ...groups.map((group) => ({ direction: 'egress', destination: { group }, protocols: [], ports: [], action: 'allow' })), ], } @@ -402,7 +404,7 @@ export function buildCanonicalSandboxSpec(): Record { hostname: null, user: args.user, log_level: null, - metrics_sample_interval_ms: null, + metrics_sample_interval_ms: MSB_METRICS_SAMPLE_INTERVAL_MS, disable_metrics_sample: false, }, env: [], diff --git a/backend/test/routes/internal-sandbox.test.ts b/backend/test/routes/internal-sandbox.test.ts index e6e56bf7..9730a8d6 100644 --- a/backend/test/routes/internal-sandbox.test.ts +++ b/backend/test/routes/internal-sandbox.test.ts @@ -47,7 +47,7 @@ function trustedRunningInspect(): { exitCode: number; stdout: string; stderr: st hostname: null, user: resolveSandboxExecUser(), log_level: null, - metrics_sample_interval_ms: null, + metrics_sample_interval_ms: 1000, disable_metrics_sample: false, }, env: [], @@ -67,7 +67,7 @@ function trustedRunningInspect(): { exitCode: number; stdout: string; stderr: st default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { group: 'public' }, protocols: [], ports: [], action: 'allow' }, ], }, diff --git a/backend/test/services/sandbox/command.test.ts b/backend/test/services/sandbox/command.test.ts index 4b27ed52..96396fa4 100644 --- a/backend/test/services/sandbox/command.test.ts +++ b/backend/test/services/sandbox/command.test.ts @@ -552,7 +552,7 @@ describe('sandbox network policy attestation helpers', () => { default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { group: 'public' }, protocols: [], ports: [], action: 'allow' }, ], } @@ -566,7 +566,7 @@ describe('sandbox network policy attestation helpers', () => { default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { group: 'public' }, protocols: [], ports: [], action: 'allow' }, { direction: 'egress', destination: { group: 'private' }, protocols: [], ports: [], action: 'allow' }, { direction: 'egress', destination: { group: 'host' }, protocols: [], ports: [], action: 'allow' }, @@ -648,7 +648,7 @@ describe('sandbox network policy attestation helpers', () => { expect(sandboxNetworkPolicyMismatch({ default_egress: 'deny' }, expected)).toContain('missing or malformed') expect(sandboxNetworkPolicyMismatch({ ...publicPolicy, rules: 'not-an-array' }, expected)).toContain('missing or malformed') expect(sandboxNetworkPolicyMismatch( - { ...publicPolicy, rules: [{ direction: 'egress', destination: { group: 'dns' }, action: 'allow' }] }, + { ...publicPolicy, rules: [{ direction: 'egress', destination: { group: 'host' }, action: 'allow' }] }, expected, )).toContain('network policy') }) diff --git a/backend/test/services/sandbox/runtime.test.ts b/backend/test/services/sandbox/runtime.test.ts index 2557c112..a7d874cb 100644 --- a/backend/test/services/sandbox/runtime.test.ts +++ b/backend/test/services/sandbox/runtime.test.ts @@ -130,7 +130,7 @@ describe('SandboxRuntimeService', () => { hostname: null, user: resolveSandboxExecUser(), log_level: 'info', - metrics_sample_interval_ms: null, + metrics_sample_interval_ms: 1000, disable_metrics_sample: false, }, env: [ @@ -153,7 +153,7 @@ describe('SandboxRuntimeService', () => { default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { group: 'public' }, protocols: [], ports: [], action: 'allow' }, ], }, @@ -1142,7 +1142,7 @@ describe('SandboxRuntimeService', () => { default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { any: true }, protocols: [], ports: [], action: 'allow' }, ], }, @@ -1185,7 +1185,7 @@ describe('SandboxRuntimeService', () => { default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { group: 'public' }, protocols: [], ports: [], action: 'allow' }, { direction: 'egress', destination: { group: 'private' }, protocols: [], ports: [], action: 'allow' }, ], @@ -1229,7 +1229,7 @@ describe('SandboxRuntimeService', () => { default_egress: 'deny', default_ingress: 'allow', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, ], }, max_connections: null, @@ -1271,7 +1271,7 @@ describe('SandboxRuntimeService', () => { default_egress: 'deny', default_ingress: 'deny', rules: [ - { direction: 'egress', destination: { group: 'dns' }, protocols: [], ports: [], action: 'allow' }, + { direction: 'egress', destination: { group: 'host' }, protocols: ['udp', 'tcp'], ports: [{ start: 53, end: 53 }], action: 'allow' }, { direction: 'egress', destination: { group: 'public' }, protocols: [], ports: [], action: 'allow' }, ], },