bctx_forge/intercept/
mod.rs1pub mod chain;
2pub mod classifier;
3
4use crate::signal::SignalKind;
5
6#[derive(Debug, Clone)]
7pub enum InterceptDecision {
8 Capture(CaptureOpts),
9 Passthrough,
10 Reject(String),
11}
12
13#[derive(Debug, Clone, Default)]
14pub struct CaptureOpts {
15 pub capture_stderr: bool,
16 pub timeout_secs: u64,
17}
18
19impl Default for InterceptDecision {
20 fn default() -> Self {
21 Self::Capture(CaptureOpts {
22 capture_stderr: true,
23 timeout_secs: 30,
24 })
25 }
26}
27
28pub trait CommandInterceptor: Send + Sync {
29 fn intercept(&self, program: &str, args: &[String]) -> InterceptDecision;
30}
31
32pub struct DefaultInterceptor;
34
35impl CommandInterceptor for DefaultInterceptor {
36 fn intercept(&self, program: &str, args: &[String]) -> InterceptDecision {
37 let kind = SignalKind::from_program(program, args);
38 match kind {
39 SignalKind::Unknown => InterceptDecision::Passthrough,
40 _ => InterceptDecision::Capture(CaptureOpts {
41 capture_stderr: true,
42 timeout_secs: 60,
43 }),
44 }
45 }
46}