Skip to content

Commit 97feb0e

Browse files
committed
test: repair and update secure-exec test suites for current APIs
1 parent 01e2f9a commit 97feb0e

7 files changed

Lines changed: 515 additions & 127 deletions

File tree

crates/execution/tests/python.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,12 @@ export async function loadPyodide(options) {
725725
| PythonVfsRpcMethod::SubprocessRun => {
726726
panic!("unexpected non-filesystem Python RPC: {:?}", request.method)
727727
}
728+
other => {
729+
panic!(
730+
"unexpected Python VFS RPC method in this test: {other:?} for {}",
731+
request.path
732+
)
733+
}
728734
}
729735
}
730736
Some(PythonExecutionEvent::JavascriptSyncRpcRequest(request)) => {

crates/kernel/tests/api_surface.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,54 @@ fn kernel_process_umask_applies_to_created_files_and_directories() {
421421
kernel.waitpid(process.pid()).expect("wait for shell");
422422
}
423423

424+
#[test]
425+
fn read_dir_with_types_for_process_reports_entries_and_enforces_driver_ownership() {
426+
let mut config = KernelVmConfig::new("vm-api-readdir-types");
427+
config.permissions = Permissions::allow_all();
428+
let mut kernel = KernelVm::new(MemoryFileSystem::new(), config);
429+
kernel
430+
.register_driver(CommandDriver::new("shell", ["sh"]))
431+
.expect("register shell");
432+
kernel
433+
.register_driver(CommandDriver::new("other", ["other"]))
434+
.expect("register other driver");
435+
kernel
436+
.filesystem_mut()
437+
.write_file("/tmp/typed-file.txt", b"hello".to_vec())
438+
.expect("seed typed file");
439+
kernel
440+
.filesystem_mut()
441+
.mkdir("/tmp/typed-dir", true)
442+
.expect("seed typed dir");
443+
444+
let process = spawn_shell(&mut kernel);
445+
let entries = kernel
446+
.read_dir_with_types_for_process("shell", process.pid(), "/tmp")
447+
.expect("read typed entries");
448+
449+
let file_entry = entries
450+
.iter()
451+
.find(|entry| entry.name == "typed-file.txt")
452+
.expect("typed file entry");
453+
assert!(!file_entry.is_directory);
454+
assert!(!file_entry.is_symbolic_link);
455+
456+
let dir_entry = entries
457+
.iter()
458+
.find(|entry| entry.name == "typed-dir")
459+
.expect("typed dir entry");
460+
assert!(dir_entry.is_directory);
461+
assert!(!dir_entry.is_symbolic_link);
462+
463+
assert_kernel_error_code(
464+
kernel.read_dir_with_types_for_process("other", process.pid(), "/tmp"),
465+
"EPERM",
466+
);
467+
468+
process.finish(0);
469+
kernel.waitpid(process.pid()).expect("wait for shell");
470+
}
471+
424472
#[test]
425473
fn kernel_fd_surface_reads_exact_byte_counts_from_device_nodes() {
426474
let mut config = KernelVmConfig::new("vm-api-fd-devices");

crates/sidecar/tests/architecture_guards.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
//! * Build scripts (`build.rs`, `*_build_support.rs`, ...), `tests/` and
3636
//! `benches/` directories, and inline `#[cfg(test)]` modules are excluded
3737
//! from the scan (they are not production host-access surface).
38-
//! * `crates/execution/src/benchmark.rs` and `crates/execution/src/bin/` hold
39-
//! benchmarking/dev tooling and are excluded for the same reason.
38+
//! * `crates/execution/src/benchmark.rs`, `crates/execution/src/bin/`, and
39+
//! `crates/native-baseline/` hold benchmarking/dev tooling and are excluded
40+
//! for the same reason.
4041
//!
4142
//! If you are adding a genuinely new sanctioned chokepoint, add its
4243
//! repo-relative path to the relevant allowlist below WITH a comment
@@ -108,6 +109,7 @@ fn is_excluded_file(rel: &Path) -> bool {
108109
|| s.ends_with("v8_bridge_build.rs")
109110
// Benchmarking / dev tooling, not production host-access surface.
110111
|| s == "crates/execution/src/benchmark.rs"
112+
|| s.starts_with("crates/native-baseline/")
111113
|| s.contains("/src/bin/")
112114
}
113115

@@ -326,6 +328,10 @@ const ENV_ALLOW: &[&str] = &[
326328
// Node import cache reads an operator timeout knob before materializing
327329
// host-side runtime assets for VM startup.
328330
"crates/execution/src/node_import_cache.rs",
331+
// Host-side perf phase diagnostics toggles, read from operator env and not
332+
// guest-reachable.
333+
"crates/execution/src/javascript.rs",
334+
"crates/sidecar/src/filesystem.rs",
329335
"crates/v8-runtime/src/bridge.rs",
330336
"crates/sidecar/src/execution.rs",
331337
"crates/sidecar/src/plugins/s3_common.rs",

crates/sidecar/tests/fixtures/limits-inventory.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
"class": "invariant",
3131
"rationale": "Clamps a guest timer delay to the JS setTimeout ceiling (2^31-1 ms); a leak guard so a timer thread cannot outlive its session by pinning the session Arc, mirroring the standard setTimeout max rather than operator policy."
3232
},
33+
{
34+
"name": "NET_BRIDGE_MAX_RAW_WRITE_BYTES",
35+
"path": "crates/execution/assets/v8-bridge.source.js",
36+
"class": "invariant",
37+
"rationale": "Internal socket bridge flush granularity that preserves backpressure under the wired socket buffered-byte limit; not an operator policy cap."
38+
},
3339
{
3440
"name": "JAVASCRIPT_EVENT_CHANNEL_CAPACITY",
3541
"path": "crates/execution/src/javascript.rs",
@@ -90,6 +96,12 @@
9096
"rationale": "Python VFS RPC timeout.",
9197
"wired": "VmLimits.python.vfs_rpc_timeout_ms"
9298
},
99+
{
100+
"name": "PYTHON_SOCKET_MAX_RECV",
101+
"path": "crates/sidecar/src/execution.rs",
102+
"class": "policy-deferred",
103+
"rationale": "Guest Python socket recv request clamp for one synchronous host read; bounded by default, fold into Python/socket VmLimits if operators need to tune it."
104+
},
93105
{
94106
"name": "V8_SESSION_FRAME_CHANNEL_CAPACITY",
95107
"path": "crates/execution/src/v8_host.rs",

crates/sidecar/tests/protocol.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ fn checked_in_bare_schema_covers_all_top_level_frame_payload_types() {
923923
"CloseStdinRequest",
924924
"KillProcessRequest",
925925
"GetProcessSnapshotRequest",
926+
"GetResourceSnapshotRequest",
926927
"FindListenerRequest",
927928
"FindBoundUdpRequest",
928929
"GetSignalStateRequest",
@@ -951,6 +952,7 @@ fn checked_in_bare_schema_covers_all_top_level_frame_payload_types() {
951952
"StdinClosedResponse",
952953
"ProcessKilledResponse",
953954
"ProcessSnapshotResponse",
955+
"ResourceSnapshotResponse",
954956
"ListenerSnapshotResponse",
955957
"BoundUdpSnapshotResponse",
956958
"SignalStateResponse",

crates/sidecar/tests/python.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,6 @@ print(json.dumps({
13641364
assert_eq!(python_written, "from python");
13651365
}
13661366

1367-
#[test]
13681367
fn python_runtime_supports_file_delete_and_rename() {
13691368
assert_node_available();
13701369

@@ -1506,7 +1505,6 @@ print(json.dumps(results))
15061505
);
15071506
}
15081507

1509-
#[test]
15101508
fn python_runtime_supports_raw_tcp_and_udp_sockets() {
15111509
assert_node_available();
15121510

@@ -1594,7 +1592,6 @@ print(json.dumps(result))
15941592
assert_eq!(parsed["udp"], "ping udp");
15951593
}
15961594

1597-
#[test]
15981595
fn python_runtime_supports_symlink_readlink_and_metadata() {
15991596
assert_node_available();
16001597

@@ -3884,6 +3881,9 @@ fn python_suite() {
38843881
python_runtime_blocks_pyodide_js_escape_hatches();
38853882
concurrent_python_processes_stay_isolated_across_vms();
38863883
python_runtime_mounts_workspace_over_the_kernel_vfs();
3884+
python_runtime_supports_file_delete_and_rename();
3885+
python_runtime_supports_raw_tcp_and_udp_sockets();
3886+
python_runtime_supports_symlink_readlink_and_metadata();
38873887
workspace_files_are_shared_between_javascript_and_python_runtimes();
38883888
python_workspace_mount_respects_read_only_root_permissions();
38893889
python_runtime_blocks_mapped_pyodide_cache_symlink_metadata_escape();

0 commit comments

Comments
 (0)