Skip to content

Commit 04ced91

Browse files
committed
refactor(sandbox): consume dedicated backend crate
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 3254745 commit 04ced91

5 files changed

Lines changed: 28 additions & 29 deletions

File tree

‎Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/openshell-sandbox/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ perf-harness = []
2121
openshell-core = { path = "../openshell-core", default-features = false }
2222
openshell-binary-identity = { path = "../openshell-binary-identity" }
2323
openshell-isolation-interface = { path = "../openshell-isolation-interface" }
24+
openshell-sandbox-backend = { path = "../openshell-sandbox-backend" }
2425
openshell-ocsf = { path = "../openshell-ocsf" }
2526
openshell-policy = { path = "../openshell-policy" }
2627

‎crates/openshell-sandbox/src/boundary_server.rs‎

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ mod linux {
3434
use openshell_core::jwt::{
3535
SandboxId, SessionJwtVerifier, SessionTokenProfile, SessionVerificationKey, SystemJwtClock,
3636
};
37-
#[cfg(test)]
38-
use openshell_core::proto::isolation::v1::isolation_boundary_client::IsolationBoundaryClient;
39-
use openshell_core::proto::isolation::v1::{
40-
BoundaryChunk,
41-
isolation_boundary_server::{IsolationBoundary, IsolationBoundaryServer},
42-
};
4337
use openshell_core::provider_credentials::ProviderCredentialState;
4438
use openshell_isolation_interface::contract::{
4539
BoundaryExec, BoundaryLoopbackConnector, BoundaryProcess, BoundaryTerminal,
4640
CapabilityEvidence, ExecSession, LoopbackTarget, ResolvedWorkloadIdentity,
4741
SandboxConfirmEvidence,
4842
};
49-
use openshell_isolation_interface::mediation::{
43+
use openshell_sandbox_backend::mediation::{
5044
self, DnsQueryWire, MediationFrame, MediationFrameKind,
5145
};
52-
use openshell_isolation_interface::sandbox_auth::{
46+
#[cfg(test)]
47+
use openshell_sandbox_backend::proto::isolation_boundary_client::IsolationBoundaryClient;
48+
use openshell_sandbox_backend::proto::{
49+
BoundaryChunk,
50+
isolation_boundary_server::{IsolationBoundary, IsolationBoundaryServer},
51+
};
52+
use openshell_sandbox_backend::sandbox_auth::{
5353
SandboxConnectionId, SandboxConnectionRegistry, SandboxProtocolAuthenticator,
5454
SandboxProtocolPrincipal,
5555
};
5656
use tokio::io::{AsyncReadExt as _, AsyncWriteExt as _};
5757
use tokio_stream::wrappers::ReceiverStream;
5858

59-
use openshell_isolation_interface::boundary_protocol::{
59+
use openshell_sandbox_backend::boundary_protocol::{
6060
AgentSpecWire, BinaryIdentityWire, BoundaryConfig, BoundaryErrorKind,
6161
BoundaryListener as BoundaryListenerConfig, DnsQueryResultWire, ExecSpecWire,
6262
ExitStatusWire, MediationTimingWire, OutputWindowWire, ProcessKindWire,
@@ -261,7 +261,7 @@ mod linux {
261261
}
262262

263263
fn tls_paths_are_absolute(
264-
tls: &openshell_isolation_interface::boundary_protocol::SandboxTlsServerConfig,
264+
tls: &openshell_sandbox_backend::boundary_protocol::SandboxTlsServerConfig,
265265
) -> bool {
266266
tls.certificate_chain_path.is_absolute() && tls.private_key_path.is_absolute()
267267
}
@@ -673,7 +673,7 @@ mod linux {
673673
) -> Result<(), String> {
674674
let request: RequestEnvelope = tokio::time::timeout(
675675
CONTROL_IO_TIMEOUT,
676-
openshell_isolation_interface::boundary_protocol::read_frame_async(&mut stream),
676+
openshell_sandbox_backend::boundary_protocol::read_frame_async(&mut stream),
677677
)
678678
.await
679679
.map_err(|_| "mediation attach timed out".to_string())?
@@ -2752,7 +2752,7 @@ mod linux {
27522752
}
27532753

27542754
fn load_tls_server_config(
2755-
tls: &openshell_isolation_interface::boundary_protocol::SandboxTlsServerConfig,
2755+
tls: &openshell_sandbox_backend::boundary_protocol::SandboxTlsServerConfig,
27562756
) -> io::Result<rustls::ServerConfig> {
27572757
let _ = rustls::crypto::ring::default_provider().install_default();
27582758
let certificate_bytes = std::fs::read(&tls.certificate_chain_path)?;
@@ -2991,7 +2991,7 @@ mod linux {
29912991
use openshell_core::jwt::{
29922992
CredentialEpoch, DEFAULT_SESSION_TOKEN_TTL, SandboxSessionIdentity, SessionJwtIssuer,
29932993
};
2994-
use openshell_isolation_interface::boundary_protocol::{
2994+
use openshell_sandbox_backend::boundary_protocol::{
29952995
GatewayVerificationKey, SandboxTlsClientConfig, SandboxTlsServerConfig,
29962996
generate_sandbox_tls_material,
29972997
};
@@ -3443,11 +3443,9 @@ mod linux {
34433443
.expect("attach test connection");
34443444
let (mut replacement, task) = request_test_mediation(runtime, principal).await;
34453445
let ready: ResponseEnvelope =
3446-
openshell_isolation_interface::boundary_protocol::read_frame_async(
3447-
&mut replacement,
3448-
)
3449-
.await
3450-
.unwrap();
3446+
openshell_sandbox_backend::boundary_protocol::read_frame_async(&mut replacement)
3447+
.await
3448+
.unwrap();
34513449
assert!(matches!(ready.response, Response::MediationReady));
34523450
drop(replacement);
34533451
task.await.unwrap().unwrap();
@@ -3486,14 +3484,14 @@ mod linux {
34863484
let (mut first, first_task) =
34873485
request_test_mediation(runtime.clone(), principal.clone()).await;
34883486
let ready: ResponseEnvelope =
3489-
openshell_isolation_interface::boundary_protocol::read_frame_async(&mut first)
3487+
openshell_sandbox_backend::boundary_protocol::read_frame_async(&mut first)
34903488
.await
34913489
.unwrap();
34923490
assert!(matches!(ready.response, Response::MediationReady));
34933491
let (mut denied, denied_task) =
34943492
request_test_mediation(runtime.clone(), principal.clone()).await;
34953493
let response: ResponseEnvelope =
3496-
openshell_isolation_interface::boundary_protocol::read_frame_async(&mut denied)
3494+
openshell_sandbox_backend::boundary_protocol::read_frame_async(&mut denied)
34973495
.await
34983496
.unwrap();
34993497
assert!(matches!(
@@ -3516,9 +3514,7 @@ mod linux {
35163514
first_task.await.unwrap().unwrap();
35173515
let ready: ResponseEnvelope = tokio::time::timeout(
35183516
Duration::from_secs(1),
3519-
openshell_isolation_interface::boundary_protocol::read_frame_async(
3520-
&mut replacement,
3521-
),
3517+
openshell_sandbox_backend::boundary_protocol::read_frame_async(&mut replacement),
35223518
)
35233519
.await
35243520
.unwrap()
@@ -3774,7 +3770,7 @@ mod linux {
37743770
frame.extend_from_slice(&chunk.data);
37753771
}
37763772
let response: ResponseEnvelope =
3777-
openshell_isolation_interface::boundary_protocol::decode_frame(&frame)
3773+
openshell_sandbox_backend::boundary_protocol::decode_frame(&frame)
37783774
.expect("decode logical response");
37793775
assert!(matches!(response.response, Response::Attached { .. }));
37803776
server.abort();

‎crates/openshell-supervisor/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ path = "src/main.rs"
1818
openshell-core = { path = "../openshell-core", default-features = false, features = ["jwt"] }
1919
openshell-extension-core = { path = "../openshell-extension-core" }
2020
openshell-isolation-interface = { path = "../openshell-isolation-interface" }
21+
openshell-sandbox-backend = { path = "../openshell-sandbox-backend" }
2122
openshell-ocsf = { path = "../openshell-ocsf" }
2223
openshell-policy = { path = "../openshell-policy" }
2324
openshell-supervisor-middleware = { path = "../openshell-supervisor-middleware" }

‎crates/openshell-supervisor/src/lib.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ pub async fn run_sandbox(
504504
let admitted_backend_name = admitted_isolation_backend.ok_or_else(|| {
505505
miette::miette!("protected topology supplied without an admitted isolation backend")
506506
})?;
507-
let topology: openshell_isolation_interface::boundary_protocol::BoundaryTopology =
507+
let topology: openshell_sandbox_backend::boundary_protocol::BoundaryTopology =
508508
serde_json::from_slice(&topology_descriptor.payload)
509509
.map_err(|error| miette::miette!("decode boundary topology: {error}"))?;
510510
if auth_bundle.session_id != topology.session_id {
@@ -515,14 +515,13 @@ pub async fn run_sandbox(
515515
let sandbox_bearer = openshell_core::grpc_client::install_supervisor_auth_bundle(&auth_bundle)?;
516516
let session_id = topology.session_id;
517517
let ca_file_paths = Arc::new(std::sync::Mutex::new(None));
518-
let backend: Arc<dyn openshell_isolation_interface::contract::IsolationBackend> = Arc::new(
519-
openshell_isolation_interface::remote::RemoteIsolationBackend::new(
518+
let backend: Arc<dyn openshell_isolation_interface::contract::IsolationBackend> =
519+
Arc::new(openshell_sandbox_backend::OpenShellRuntimeBackend::new(
520520
admitted_backend_name.clone(),
521521
ca_file_paths.clone(),
522522
provider_credentials.clone(),
523523
sandbox_bearer,
524-
),
525-
);
524+
));
526525
let mut registry = openshell_isolation_interface::contract::BackendRegistry::new();
527526
registry
528527
.register(backend)

0 commit comments

Comments
 (0)