openvet-policy 0.6.0

Requirement language and Kleene evaluator for OpenVet audit policies.
Documentation
/// Error returned by the policy parser and validator.
#[derive(Debug, thiserror::Error)]
pub enum PolicyError {
    /// I/O error reading the policy file.
    #[error("io error: {0}")]
    Io(#[from] std::io::Error),
    /// TOML parse error.
    #[error("toml parse error: {0}")]
    Toml(#[from] toml::de::Error),
    /// A requirement expression failed to parse (bad token,
    /// trailing tokens, unbalanced parens, empty input, etc.).
    #[error("expression: {0}")]
    ExprParse(String),
    /// A requirement's condition expression failed to parse. Carries
    /// the requirement name as context; the wrapped error is the
    /// underlying [`ExprParse`](Self::ExprParse).
    #[error("requirement {name:?}: {source}")]
    RequirementExpression {
        /// The requirement whose expression failed to parse.
        name: String,
        /// The underlying parse error.
        #[source]
        source: Box<PolicyError>,
    },
    /// An `[[override]]` block references a requirement name that
    /// isn't defined in `[requirement]`.
    #[error("override references unknown requirement {name:?}")]
    UnknownRequirement {
        /// The name referenced by the override.
        name: String,
    },
    /// An `[alias]` entry isn't in `log:claim-name` form (missing
    /// the `:` separator).
    #[error("alias {canonical:?}: entry {entry:?} must be `log:claim-name`")]
    InvalidAliasEntry {
        /// The canonical claim name the alias was being defined for.
        canonical: String,
        /// The offending right-hand-side entry.
        entry: String,
    },
}

/// Convenience type alias for `Result<T, PolicyError>`.
pub type Result<T, E = PolicyError> = std::result::Result<T, E>;