Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion crates/openshell-sandbox-backend/src/boundary_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest as _, Sha256};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};

pub const MAX_CONTROL_FRAME_BYTES: usize = 1024 * 1024;
pub const MAX_CONTROL_FRAME_BYTES: usize = 2 * 1024 * 1024;
pub const STREAM_STDIN: u8 = 0;
pub const STREAM_STDOUT: u8 = 1;
pub const STREAM_STDERR: u8 = 2;
Expand Down Expand Up @@ -1330,6 +1330,35 @@ mod tests {
));
}

#[test]
fn start_agent_with_large_ca_bundle_fits_in_frame_limit() {
let request = RequestEnvelope::new(Request::StartAgent {
sandbox_id: "sandbox-1".to_string(),
spec: AgentSpecWire {
program: "/bin/true".to_string(),
args: Vec::new(),
workdir: None,
timeout_secs: 5,
interactive: false,
},
policy: Box::new(SandboxPolicyWire::from(SandboxPolicy {
version: 1,
filesystem: FilesystemPolicy::default(),
network: NetworkPolicy::default(),
landlock: LandlockPolicy::default(),
process: ProcessPolicy::default(),
})),
ca_cert: Some(vec![0xAB; 16 * 1024]),
ca_bundle: Some(vec![0xCD; 400 * 1024]),
provider_env_revision: 0,
provider_env: std::collections::HashMap::new(),
})
.expect("request envelope");
let frame = encode_frame(&request).expect("large CA bundle must fit in frame limit");
let decoded: RequestEnvelope = decode_frame(&frame).expect("round-trip");
assert_eq!(decoded, request);
}

#[test]
fn rejects_declared_oversize() {
let oversized = u32::try_from(MAX_CONTROL_FRAME_BYTES + 1).expect("test size fits u32");
Expand Down
Loading