Really excited to see this crate, and very impressed by your work so far.
Reading over the code, I see a few places where the ExtraSafeError could be tweaked to align cleanly with Rust's naming practices.
- Name the enum
Error - this is consistent with how std::io::Error, reqwest::Error and others behave.
- Remove the word
Error from the variant names, since it's redundant
- Make a struct called
ConditionalNoEffectError which includes named accessors for the fields
#[derive(Debug, thiserror::Error)]
/// The error type produced by [`SafetyContext`]
pub enum Error {
#[error("extrasafe is only usable on Linux.")]
/// Error created when trying to apply filters on non-Linux operating systems. Should never
/// occur.
UnsupportedOS,
#[error(transparent)]
/// Error created when a simple rule would override a conditional rule.
ConditionalNoEffect(#[from] ConditionalNoEffectError),
#[error("A libseccomp error occured. {0:?}")]
/// An error from the underlying seccomp library.
Seccomp(#[from] libseccomp::error::SeccompError),
}
#[derive(Debug, thiserror::Error)]
#[error("A conditional rule on syscall `{syscall}` from RuleSet `{ruleset}` would be overridden by a simple rule from RuleSet `{overridden_by}`.")]
pub struct ConditionalNoEffectError {
syscall: syscalls::Sysno,
ruleset: &'static str,
overridden_by: &'static str,
}
impl ConditionalNoEffectError {
// Should this be pub, or pub(crate)?
pub fn new(syscall: syscalls::Sysno, ruleset: &'static str, overridden_by: &'static str) -> Self {
Self { syscall, ruleset, overridden_by }
}
pub fn syscall(&self) -> syscalls::Sysno {
self.syscall
}
pub fn ruleset(&self) -> &str {
self.ruleset
}
pub fn overridden_by(&self) -> &str {
self.overridden_by
}
}
Really excited to see this crate, and very impressed by your work so far.
Reading over the code, I see a few places where the
ExtraSafeErrorcould be tweaked to align cleanly with Rust's naming practices.Error- this is consistent with howstd::io::Error,reqwest::Errorand others behave.Errorfrom the variant names, since it's redundantConditionalNoEffectErrorwhich includes named accessors for the fields