alien-bindings 3.3.17

Alien direct in-process resource bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
//! GCP sandbox provider.
//!
//! A Cloud Run sandbox is a subprocess of the workload's own instance, created through a CLI on
//! the container's filesystem. There is no control plane to call, no credential to hold and no
//! capability to mint: the boundary is the launcher, and the launcher is already there.
//!
//! Every command is passed as argv rather than a shell string, including file paths and file
//! contents, so nothing a caller supplies is ever parsed by a shell.

use std::collections::BTreeMap;
use std::time::Duration;

use async_trait::async_trait;
use base64::engine::general_purpose::STANDARD as BASE64;
use base64::Engine as _;
use futures::stream::BoxStream;
use futures::StreamExt;
use tokio::sync::mpsc;

use crate::error::{ErrorData, Result};
use crate::traits::{
    Binding, CommandOutput, CreateSessionRequest, PreviewCapability, RunCommandRequest, Sandbox,
    SandboxSession, SandboxSessionState,
};
use alien_core::bindings::GcpSandboxBinding;
use alien_core::sandbox_process::{self, ProcessFrame, ProcessStream, FRAME_CHANNEL_DEPTH};
use alien_core::{Platform, SandboxCapabilities};
use alien_error::AlienError;

/// How much of one command's output is kept before the terminal frame reports truncation.
const OUTPUT_CAP: usize = 8 * 1024 * 1024;

/// Ceiling on a launcher call that is not the caller's command, such as a create or a delete.
const CONTROL_DEADLINE: Duration = Duration::from_secs(60);

/// A Sandbox backed by the Cloud Run sandbox launcher.
#[derive(Debug)]
pub struct GcpSandbox {
    launcher_path: String,
    allow_egress: bool,
    binding_name: String,
}

impl GcpSandbox {
    /// Builds a provider from its binding.
    pub fn new(binding_name: &str, binding: &GcpSandboxBinding) -> Result<Self> {
        let launcher_path = binding
            .launcher_path
            .clone()
            .into_value(binding_name, "launcherPath")
            .map_err(|error| {
                AlienError::new(ErrorData::BindingConfigInvalid {
                    binding_name: binding_name.to_string(),
                    env_var: alien_core::bindings::binding_env_var_name(binding_name),
                    reason: error.to_string(),
                })
            })?;

        let allow_egress = binding
            .allow_egress
            .clone()
            .into_value(binding_name, "allowEgress")
            .map_err(|error| {
                AlienError::new(ErrorData::BindingConfigInvalid {
                    binding_name: binding_name.to_string(),
                    env_var: alien_core::bindings::binding_env_var_name(binding_name),
                    reason: error.to_string(),
                })
            })?;

        Ok(Self {
            launcher_path,
            allow_egress,
            binding_name: binding_name.to_string(),
        })
    }

    /// Runs the launcher and returns its stdout, failing on a non-zero exit.
    ///
    /// Used for the control verbs. A caller's own command goes through [`Self::frames`] instead,
    /// which streams rather than collecting.
    async fn control(&self, operation: &str, arguments: &[String]) -> Result<Vec<u8>> {
        let child = sandbox_process::spawn(&self.launcher_path, arguments)
            .and_then(|mut command| command.spawn())
            .map_err(|error| {
                self.failed(operation, &format!("launcher would not start: {error}"))
            })?;

        let frames = sandbox_process::run(child, CONTROL_DEADLINE, OUTPUT_CAP).await;

        let mut stdout = Vec::new();
        let mut stderr = Vec::new();
        for frame in &frames {
            match frame {
                ProcessFrame::Output {
                    stream: ProcessStream::Stdout,
                    data,
                    ..
                } => stdout.extend_from_slice(data),
                ProcessFrame::Output {
                    stream: ProcessStream::Stderr,
                    data,
                    ..
                } => stderr.extend_from_slice(data),
                _ => {}
            }
        }

        match frames.last() {
            Some(ProcessFrame::Exit { code: 0, .. }) => Ok(stdout),
            // stderr, not the exit code alone: the launcher puts the actual cause there, and a
            // bare status turns a specific failure into a guess.
            Some(ProcessFrame::Exit { code, .. }) => Err(self.failed(
                operation,
                &format!(
                    "launcher exited with {code}: {}",
                    String::from_utf8_lossy(&stderr).trim()
                ),
            )),
            Some(ProcessFrame::Failed { code, message }) => {
                Err(self.failed(operation, &format!("{code}: {message}")))
            }
            _ => Err(self.failed(operation, "launcher produced no terminal frame")),
        }
    }

    fn failed(&self, operation: &str, reason: &str) -> AlienError<ErrorData> {
        AlienError::new(ErrorData::OperationNotSupported {
            operation: operation.to_string(),
            reason: format!("{reason} (binding '{}')", self.binding_name),
        })
    }

    fn unsupported(&self, capability: &str, reason: &str) -> AlienError<ErrorData> {
        AlienError::new(ErrorData::OperationNotSupported {
            operation: capability.to_string(),
            reason: reason.to_string(),
        })
    }

    /// Refuses a path that traverses upward, the same lexical rule the in-sandbox agent applies.
    fn checked_path(&self, path: &str, operation: &str) -> Result<String> {
        if path.is_empty() || path.split('/').any(|part| part == "..") {
            return Err(self.failed(operation, &format!("path '{path}' traverses upward")));
        }
        Ok(path.to_string())
    }

    /// Builds `sandbox exec <session> -- <command...>`.
    fn exec_arguments(&self, session_id: &str, command: &[String]) -> Vec<String> {
        let mut arguments = vec!["exec".to_string(), session_id.to_string(), "--".to_string()];
        arguments.extend(command.iter().cloned());
        arguments
    }
}

impl Binding for GcpSandbox {}

#[async_trait]
impl Sandbox for GcpSandbox {
    fn as_any(&self) -> &dyn std::any::Any {
        self
    }

    fn capabilities(&self) -> SandboxCapabilities {
        SandboxCapabilities::for_platform(Platform::Gcp).expect("GCP has a sandbox backend")
    }

    /// Starts a sandbox with a caller-chosen id.
    ///
    /// Egress comes from the binding rather than the request: the launcher decides it at create
    /// time and an application must not be able to widen its own.
    async fn create(&self, request: CreateSessionRequest) -> Result<SandboxSession> {
        if !request.env.is_empty() {
            return Err(self.failed(
                "sandbox.create",
                "the Cloud Run sandbox launcher takes no session environment; bake it into the \
                 image or pass it in each command",
            ));
        }

        let session_id = request
            .session_id
            .unwrap_or_else(|| uuid::Uuid::new_v4().simple().to_string());

        let mut arguments = vec!["run".to_string(), "--id".to_string(), session_id.clone()];
        if self.allow_egress {
            arguments.push("--allow-egress".to_string());
        }

        self.control("sandbox.create", &arguments).await?;

        Ok(SandboxSession {
            session_id,
            state: SandboxSessionState::Running,
            // A sandbox is destroyed rather than fenced, so a session never outlives its own
            // generation and there is nothing for a second one to mean.
            generation: 1,
        })
    }

    /// Reconnecting is not offered, and the reason is measured rather than assumed.
    async fn get(&self, _session_id: &str) -> Result<Option<SandboxSession>> {
        Err(self.unsupported(
            "reconnect",
            "a Cloud Run sandbox id is scoped to one instance, and session affinity held 2 of \
             100 five-turn conversations",
        ))
    }

    async fn get_or_create(&self, request: CreateSessionRequest) -> Result<SandboxSession> {
        self.create(request).await
    }

    async fn list(&self) -> Result<Vec<SandboxSession>> {
        Err(self.unsupported(
            "reconnect",
            "the launcher has no enumeration verb, and an id reaches only the instance that \
             created it",
        ))
    }

    async fn run_command(
        &self,
        session_id: &str,
        request: RunCommandRequest,
    ) -> Result<BoxStream<'static, Result<CommandOutput>>> {
        if request.command.is_empty() {
            return Err(self.failed("sandbox.runCommand", "command is empty"));
        }

        if request.deadline.is_zero() {
            return Err(self.failed(
                "sandbox.runCommand",
                "a command must carry a non-zero deadline",
            ));
        }

        // The launcher takes no environment, and dropping what a caller asked for is the silent
        // no-op the capability contract forbids: a command reading a variable it was promised
        // would see nothing and fail somewhere far from here.
        if !request.env.is_empty() {
            return Err(self.failed(
                "sandbox.runCommand",
                "the Cloud Run sandbox launcher takes no per-command environment; bake it into \
                 the image or pass it in the command",
            ));
        }

        let mut arguments = self.exec_arguments(session_id, &request.command);
        if let Some(directory) = &request.working_directory {
            // Prepended rather than appended: everything after `--` is the caller's command.
            arguments.insert(2, directory.clone());
            arguments.insert(2, "--workdir".to_string());
        }

        let child = sandbox_process::spawn(&self.launcher_path, &arguments)
            .and_then(|mut command| command.spawn())
            .map_err(|error| {
                self.failed(
                    "sandbox.runCommand",
                    &format!("launcher would not start: {error}"),
                )
            })?;

        let (sender, receiver) = mpsc::channel(FRAME_CHANNEL_DEPTH);
        tokio::spawn(sandbox_process::stream(
            child,
            request.deadline,
            OUTPUT_CAP,
            sender,
        ));

        // A failed frame becomes a stream error rather than a fabricated exit code: a deadline
        // that killed the command is not the command reporting -1.
        Ok(
            futures::stream::unfold(receiver, |mut receiver| async move {
                let frame = receiver.recv().await?;
                let item = match frame {
                    ProcessFrame::Failed { code, message } => {
                        Err(AlienError::new(ErrorData::OperationNotSupported {
                            operation: "sandbox.runCommand".to_string(),
                            reason: format!("{code}: {message}"),
                        }))
                    }
                    other => Ok(CommandOutput::from(other)),
                };
                Some((item, receiver))
            })
            .boxed(),
        )
    }

    async fn read_file(&self, session_id: &str, path: &str) -> Result<Vec<u8>> {
        let path = self.checked_path(path, "sandbox.readFile")?;
        let command = vec!["/bin/cat".to_string(), path];
        self.control(
            "sandbox.readFile",
            &self.exec_arguments(session_id, &command),
        )
        .await
    }

    /// Writes files by handing the contents to the sandbox base64-encoded **as an argument**.
    ///
    /// Not interpolated into a shell string, so a file's contents can never be parsed as code.
    /// The cost is `ARG_MAX`: a file larger than roughly a megabyte needs a different transport,
    /// and fails loudly here rather than being silently truncated.
    async fn write_files(&self, session_id: &str, files: BTreeMap<String, Vec<u8>>) -> Result<()> {
        for (path, contents) in files {
            let path = self.checked_path(&path, "sandbox.writeFiles")?;
            let encoded = BASE64.encode(&contents);

            let command = vec![
                "/bin/sh".to_string(),
                "-c".to_string(),
                // Parent directories are created, matching the in-sandbox agent, so one path
                // means the same thing on every backend.
                "mkdir -p \"$(dirname \"$2\")\" && printf %s \"$1\" | base64 -d > \"$2\""
                    .to_string(),
                "sh".to_string(),
                encoded,
                path,
            ];

            self.control(
                "sandbox.writeFiles",
                &self.exec_arguments(session_id, &command),
            )
            .await?;
        }

        Ok(())
    }

    async fn mkdir(&self, session_id: &str, path: &str) -> Result<()> {
        let path = self.checked_path(path, "sandbox.mkdir")?;
        let command = vec!["/bin/mkdir".to_string(), "-p".to_string(), path];
        self.control("sandbox.mkdir", &self.exec_arguments(session_id, &command))
            .await?;
        Ok(())
    }

    async fn preview(&self, _session_id: &str, _port: u16) -> Result<PreviewCapability> {
        Err(self.unsupported(
            "preview",
            "a Cloud Run sandbox has no ingress of its own and no addressable endpoint",
        ))
    }

    async fn suspend(&self, _session_id: &str) -> Result<()> {
        Err(self.unsupported("suspendResume", "the launcher has no suspend verb"))
    }

    async fn resume(&self, _session_id: &str) -> Result<()> {
        Err(self.unsupported("suspendResume", "the launcher has no resume verb"))
    }

    async fn snapshot(&self, _session_id: &str) -> Result<String> {
        Err(self.unsupported(
            "snapshot",
            "`sandbox fork` produces another live sandbox rather than a durable artifact",
        ))
    }

    async fn terminate(&self, session_id: &str) -> Result<()> {
        self.control(
            "sandbox.terminate",
            &["delete".to_string(), session_id.to_string()],
        )
        .await?;
        Ok(())
    }
}

impl From<ProcessFrame> for CommandOutput {
    fn from(frame: ProcessFrame) -> Self {
        match frame {
            ProcessFrame::Output {
                seq,
                stream: ProcessStream::Stdout,
                data,
            } => CommandOutput::Stdout { seq, data },
            ProcessFrame::Output {
                seq,
                stream: ProcessStream::Stderr,
                data,
            } => CommandOutput::Stderr { seq, data },
            ProcessFrame::Exit { code, truncated } => CommandOutput::Exit { code, truncated },
            // Handled as a stream error before it reaches here, because an exit code would
            // claim the command reported something it never did.
            ProcessFrame::Failed { code, message } => {
                unreachable!("a failed frame is mapped to an error: {code} {message}")
            }
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use alien_core::bindings::BindingValue;

    /// A fake launcher: it records the argv it was given and answers like the real one.
    ///
    /// Testing against a script rather than a mock is deliberate. What this provider gets wrong
    /// is argument construction, and a mock of the launcher would be built from the same
    /// misunderstanding as the code.
    fn launcher(body: &str) -> (tempfile::TempDir, GcpSandbox) {
        let directory = tempfile::tempdir().expect("temp dir");
        let path = directory.path().join("sandbox");
        std::fs::write(&path, format!("#!/bin/sh\n{body}\n")).expect("write launcher");

        #[cfg(unix)]
        {
            use std::os::unix::fs::PermissionsExt;
            std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o755))
                .expect("make executable");
        }

        let sandbox = GcpSandbox::new(
            "sbx",
            &GcpSandboxBinding {
                launcher_path: BindingValue::value(path.display().to_string()),
                allow_egress: BindingValue::value(false),
            },
        )
        .expect("binding is valid");

        (directory, sandbox)
    }

    #[tokio::test]
    async fn create_names_the_session_and_withholds_egress() {
        let (_dir, sandbox) = launcher(r#"echo "$@""#);

        let session = sandbox
            .create(CreateSessionRequest {
                session_id: Some("s1".to_string()),
                tenant_key: None,
                env: BTreeMap::new(),
            })
            .await
            .expect("create succeeds");

        assert_eq!(session.session_id, "s1");
        assert_eq!(session.state, SandboxSessionState::Running);
    }

    /// The launcher takes `--allow-egress` per sandbox, so an application that could pass its
    /// own would choose its own confinement. The binding decides it.
    #[tokio::test]
    async fn egress_comes_from_the_binding_and_not_from_the_request() {
        let (dir, _) = launcher(r#"echo "$@" > "$(dirname "$0")/argv""#);
        let path = dir.path().join("sandbox");

        for (allow, expected) in [(false, false), (true, true)] {
            let sandbox = GcpSandbox::new(
                "sbx",
                &GcpSandboxBinding {
                    launcher_path: BindingValue::value(path.display().to_string()),
                    allow_egress: BindingValue::value(allow),
                },
            )
            .expect("binding is valid");

            sandbox
                .create(CreateSessionRequest {
                    session_id: Some("s1".to_string()),
                    tenant_key: None,
                    env: BTreeMap::new(),
                })
                .await
                .expect("create succeeds");

            let argv = std::fs::read_to_string(dir.path().join("argv")).expect("argv recorded");
            assert_eq!(
                argv.contains("--allow-egress"),
                expected,
                "binding said allow_egress={allow}, argv was: {argv}"
            );
        }
    }

    /// A launcher that fails must not report a session. The cause is on stderr, and losing it
    /// turns a specific failure into a guess.
    #[tokio::test]
    async fn a_failing_launcher_surfaces_its_stderr() {
        let (_dir, sandbox) = launcher(r#"echo "quota exhausted" 1>&2; exit 7"#);

        let error = sandbox
            .create(CreateSessionRequest {
                session_id: Some("s1".to_string()),
                tenant_key: None,
                env: BTreeMap::new(),
            })
            .await
            .expect_err("a non-zero launcher exit is a failure");

        let rendered = format!("{error:?}");
        assert!(rendered.contains("quota exhausted"), "got: {rendered}");
        assert!(
            rendered.contains('7'),
            "the exit code belongs in the error: {rendered}"
        );
    }

    #[tokio::test]
    async fn a_command_streams_output_and_a_real_exit_code() {
        let (_dir, sandbox) = launcher(r#"echo hello; echo problem 1>&2; exit 3"#);

        let frames: Vec<_> = sandbox
            .run_command(
                "s1",
                RunCommandRequest {
                    command: vec!["/bin/true".to_string()],
                    working_directory: None,
                    env: BTreeMap::new(),
                    deadline: Duration::from_secs(10),
                },
            )
            .await
            .expect("the command runs")
            .collect()
            .await;

        let decoded: String = frames
            .iter()
            .filter_map(|frame| match frame {
                Ok(CommandOutput::Stdout { data, .. }) => {
                    Some(String::from_utf8_lossy(data).to_string())
                }
                _ => None,
            })
            .collect();
        assert!(decoded.contains("hello"), "stdout was: {decoded}");

        assert!(
            frames
                .iter()
                .any(|frame| matches!(frame, Ok(CommandOutput::Stderr { .. }))),
            "stderr must be framed, not dropped"
        );

        assert!(
            matches!(frames.last(), Some(Ok(CommandOutput::Exit { code: 3, .. }))),
            "the terminal frame must carry the real exit code: {:?}",
            frames.last()
        );
    }

    /// The launcher carries no environment, so a caller that asks for one has to hear about it.
    /// Accepting the request and running the command without those variables is the silent no-op
    /// the capability contract exists to prevent — the failure would surface inside the sandbox,
    /// far from the call that caused it.
    #[tokio::test]
    async fn an_environment_the_launcher_cannot_carry_is_refused() {
        let (_dir, sandbox) = launcher("exit 0");
        let env = BTreeMap::from([("TOKEN".to_string(), "secret".to_string())]);

        let on_create = sandbox
            .create(CreateSessionRequest {
                session_id: Some("s1".to_string()),
                tenant_key: None,
                env: env.clone(),
            })
            .await
            .expect_err("a session environment cannot be honoured here");
        assert_eq!(on_create.code, "OPERATION_NOT_SUPPORTED");

        // `let else` rather than `expect_err`: the Ok side is a stream and carries no Debug.
        let Err(on_command) = sandbox
            .run_command(
                "s1",
                RunCommandRequest {
                    command: vec!["true".to_string()],
                    working_directory: None,
                    env,
                    deadline: Duration::from_secs(5),
                },
            )
            .await
        else {
            panic!("a command environment cannot be honoured here");
        };
        assert_eq!(on_command.code, "OPERATION_NOT_SUPPORTED");

        // The control: the same calls without an environment are accepted, so the assertions
        // above cannot pass against a provider that refuses everything.
        sandbox
            .create(CreateSessionRequest {
                session_id: Some("s2".to_string()),
                tenant_key: None,
                env: BTreeMap::new(),
            })
            .await
            .expect("a session with no environment is fine");
    }

    /// A command with no deadline is a hang waiting for a slow day, in a sandbox running code the
    /// caller does not control. Every other backend refuses it; this one did not.
    #[tokio::test]
    async fn a_command_without_a_deadline_is_refused() {
        let (_dir, sandbox) = launcher("exit 0");

        let Err(error) = sandbox
            .run_command(
                "s1",
                RunCommandRequest {
                    command: vec!["true".to_string()],
                    working_directory: None,
                    env: BTreeMap::new(),
                    deadline: Duration::ZERO,
                },
            )
            .await
        else {
            panic!("a zero deadline is not a deadline");
        };
        assert_eq!(error.code, "OPERATION_NOT_SUPPORTED");
        assert!(
            error.to_string().contains("non-zero deadline"),
            "the message should say what was wrong, got: {error}"
        );
    }

    /// Declared capabilities and actual behaviour have to agree, or a caller branches on a lie.
    #[tokio::test]
    async fn unsupported_capabilities_error_rather_than_pretend() {
        let (_dir, sandbox) = launcher("exit 0");
        let capabilities = sandbox.capabilities();

        assert!(!capabilities.reconnect);
        assert!(!capabilities.preview);
        assert!(!capabilities.suspend_resume);
        assert!(!capabilities.snapshot);

        sandbox
            .get("s1")
            .await
            .expect_err("reconnect is not offered");
        sandbox
            .list()
            .await
            .expect_err("enumeration is not offered");
        sandbox
            .preview("s1", 8080)
            .await
            .expect_err("preview is not offered");
        sandbox
            .suspend("s1")
            .await
            .expect_err("suspend is not offered");
        sandbox
            .resume("s1")
            .await
            .expect_err("resume is not offered");
        sandbox
            .snapshot("s1")
            .await
            .expect_err("snapshot is not offered");
    }

    /// The lexical rule the agent applies, applied here too, so one path means one thing.
    #[tokio::test]
    async fn a_traversing_path_is_refused_before_the_launcher_sees_it() {
        let (_dir, sandbox) = launcher("exit 0");

        sandbox
            .read_file("s1", "../etc/passwd")
            .await
            .expect_err("a traversing path must be refused");
        sandbox
            .write_files(
                "s1",
                BTreeMap::from([("../etc/passwd".to_string(), b"x".to_vec())]),
            )
            .await
            .expect_err("a traversing path must be refused on write too");
    }
}