pub struct NativeRunner;Expand description
Native process runner using std::process::Command.
NativeRunner provides secure process execution using argv-style APIs only.
It is the primary implementation of ProcessRunner for native execution
without shell interpretation.
§Security
NativeRunner enforces the following security properties:
- Uses
Command::new().args()only - NO shell string evaluation - Arguments are passed as discrete
OsStringelements - No
sh -corcmd /Cshell invocation - Shell metacharacters in arguments are NOT interpreted
§Threading
NativeRunner is a synchronous interface. It internally uses a thread-based
approach for timeout handling to avoid exposing async in the public API.
This aligns with NFR-ASYNC requirements.
§Example
use xchecker_utils::runner::{NativeRunner, ProcessRunner, CommandSpec};
use std::time::Duration;
let runner = NativeRunner::new();
let cmd = CommandSpec::new("echo")
.arg("hello")
.arg("world");
let output = runner.run(&cmd, Duration::from_secs(30)).unwrap();
assert!(output.success());Implementations§
Trait Implementations§
Source§impl Clone for NativeRunner
impl Clone for NativeRunner
Source§fn clone(&self) -> NativeRunner
fn clone(&self) -> NativeRunner
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NativeRunner
impl Debug for NativeRunner
Source§impl Default for NativeRunner
impl Default for NativeRunner
Source§fn default() -> NativeRunner
fn default() -> NativeRunner
Returns the “default value” for a type. Read more
Source§impl ProcessRunner for NativeRunner
impl ProcessRunner for NativeRunner
Source§fn run(
&self,
cmd: &CommandSpec,
timeout: Duration,
) -> Result<ProcessOutput, RunnerError>
fn run( &self, cmd: &CommandSpec, timeout: Duration, ) -> Result<ProcessOutput, RunnerError>
Execute a command natively using argv-style APIs.
This implementation:
- Uses
Command::new().args()only (no shell) - Handles timeout via thread-based waiting
- Captures stdout and stderr
- Returns exit code or timeout error
§Arguments
cmd- The command specification to executetimeout- Maximum duration to wait for the process to complete
§Returns
Ok(ProcessOutput)- The process completed (possibly with non-zero exit code)Err(RunnerError::Timeout)- The process timed outErr(RunnerError::NativeExecutionFailed)- Failed to spawn or wait for process
§Security
This method uses CommandSpec::to_command() which builds a Command
using Command::new().args() only. No shell string evaluation occurs.
impl Copy for NativeRunner
Auto Trait Implementations§
impl Freeze for NativeRunner
impl RefUnwindSafe for NativeRunner
impl Send for NativeRunner
impl Sync for NativeRunner
impl Unpin for NativeRunner
impl UnsafeUnpin for NativeRunner
impl UnwindSafe for NativeRunner
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