Skip to main content

SeccompManager

Struct SeccompManager 

Source
pub struct SeccompManager { /* private fields */ }
Expand description

Seccomp filter manager

Implements syscall whitelisting for the security state machine (NucleusSecurity_Seccomp_SeccompEnforcement.tla)

Implementations§

Source§

impl SeccompManager

Source

pub fn new() -> Self

Source

pub fn validate_extra_syscalls_for_production( allow_network: bool, extra_syscalls: &[String], ) -> Result<()>

Validate --seccomp-allow entries for production mode.

Development runs warn and ignore unsupported names at filter construction time. Production mode rejects them early so operators cannot accidentally believe a weakened or unsupported syscall fragment was applied.

Source

pub fn compile_minimal_filter() -> Result<BpfProgram>

Compile the minimal BPF filter without applying it

This is useful for benchmarking filter compilation overhead without the irreversible side effect of applying the filter.

Uses bitmap-based BPF compilation for O(1) syscall dispatch.

Source

pub fn apply_minimal_filter(&mut self) -> Result<bool>

Apply seccomp filter

This implements the transition: no_filter -> whitelist_active in the seccomp state machine (NucleusSecurity_Seccomp_SeccompEnforcement.tla)

Once applied, the filter cannot be removed (irreversible property) In rootless mode or if seccomp setup fails, this will warn and continue

Source

pub fn apply_minimal_filter_with_mode( &mut self, best_effort: bool, log_denied: bool, ) -> Result<bool>

Apply seccomp filter with configurable failure behavior

When best_effort is true, failures are logged and execution continues. When false, seccomp setup is fail-closed.

Source

pub fn apply_filter_for_network_mode( &mut self, allow_network: bool, best_effort: bool, log_denied: bool, extra_syscalls: &[String], ) -> Result<bool>

Apply seccomp filter with network-mode-aware socket restrictions

When allow_network is false, SYS_socket is restricted to AF_UNIX only, preventing creation of network sockets (AF_INET, AF_INET6, etc.). When allow_network is true, all socket domains are permitted.

When best_effort is true, failures are logged and execution continues. When false, seccomp setup is fail-closed.

Source

pub fn apply_profile_from_file( &mut self, profile_path: &Path, expected_sha256: Option<&str>, audit_mode: bool, ) -> Result<bool>

Apply a seccomp profile loaded from a JSON file.

The profile format is a JSON object with:

{
  "defaultAction": "SCMP_ACT_ERRNO",
  "syscalls": [
    { "names": ["read", "write", "open", ...], "action": "SCMP_ACT_ALLOW" }
  ]
}

This is a subset of the OCI seccomp profile format. Only the syscall name allowlist is used; argument-level filtering from the built-in profile is not applied when using a custom profile.

If expected_sha256 is provided, the file’s SHA-256 hash is verified against it before loading. This prevents silent profile tampering.

Source

pub fn apply_trace_filter(&mut self) -> Result<bool>

Install an allow-all seccomp filter with SECCOMP_FILTER_FLAG_LOG.

Used in trace mode: all syscalls are allowed but logged to the kernel audit subsystem. A separate reader collects the logged syscalls.

Source

pub fn is_applied(&self) -> bool

Check if seccomp filter has been applied

Trait Implementations§

Source§

impl Default for SeccompManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more