pub struct ContainerExecutor { /* private fields */ }Expand description
Executor that runs CLI commands inside ephemeral Docker containers
Each invocation creates a fresh docker run --rm container with
a read-only root filesystem, all capabilities dropped, and
no-new-privileges enforced. A writable scratch directory is
bind-mounted at /scratch for temporary files.
Implementations§
Source§impl ContainerExecutor
impl ContainerExecutor
Sourcepub const fn new(config: ContainerConfig) -> Self
pub const fn new(config: ContainerConfig) -> Self
Create a new container executor with the given configuration
Sourcepub async fn execute(
&self,
binary_name: &str,
args: &[&str],
input: Option<&str>,
timeout: Duration,
max_output_bytes: usize,
) -> Result<CliOutput, RunnerError>
pub async fn execute( &self, binary_name: &str, args: &[&str], input: Option<&str>, timeout: Duration, max_output_bytes: usize, ) -> Result<CliOutput, RunnerError>
Execute a CLI command inside an ephemeral container
The container is created with security hardening flags:
--rmto auto-remove after exit--read-onlyroot filesystem--cap-drop=ALLto drop all Linux capabilities--security-opt=no-new-privilegesto prevent privilege escalation- A writable
/scratchtmpfs for temporary files
If input is provided, it is written to a temp file inside the
scratch mount and piped as stdin to the command.
§Errors
Returns RunnerError if:
- The scratch directory cannot be created or written to
- The docker command fails to spawn or times out
- The container exits with a non-zero code
Trait Implementations§
Source§impl Clone for ContainerExecutor
impl Clone for ContainerExecutor
Auto Trait Implementations§
impl Freeze for ContainerExecutor
impl RefUnwindSafe for ContainerExecutor
impl Send for ContainerExecutor
impl Sync for ContainerExecutor
impl Unpin for ContainerExecutor
impl UnsafeUnpin for ContainerExecutor
impl UnwindSafe for ContainerExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.