How extrasafe works: SafetyContext, RuleSet, and SeccompRule
masterextrasafe operates on a default-deny principle. It uses a logical framework to group syscalls into manageable sets, allowing you to build a security policy without needing deep knowledge of seccomp internals.
The core abstractions are:
SafetyContext: The entry point. You create a context, gather rules viaRuleSets, and then apply the resulting seccomp filters. Once applied viaapply*()methods, the filters cannot be removed.RuleSet: A trait representing a facet of a security policy (e.g., allowing IO, network, or clock access). You can use built-in implementors or define your own.SeccompRule: Defines a specific syscall and optionalSeccompArgumentFilterconditions.
Logic Rules:
- Argument Filters: Within a single
SeccompRule, multiple conditions are AND-ed together (all must be true to allow the syscall). - Rulesets: If multiple
SeccompRules are loaded for the same syscall, they are OR-ed together (the syscall is allowed if any rule allows it). - Limitations: Argument filters cannot dereference pointers; therefore, you cannot perform string comparisons on file paths.