Sign in

    jaredzhou/mooncedar/evaluator does not have a README file

    EntityStore

    pub(open) trait EntityStore {
    fn get_entity(Self,
    EntityUID
    ) ->
    Entity
    ?
    }

    Pluggable entity storage. Implement this trait to provide entity lookups from any backing store (in-memory Map, database, cache, etc.).

    EvalError

    pub(all) suberror EvalError {
    TypeMismatch(String)
    IntegerOverflow
    EntityNotFound(String)
    InvalidOperator(String)
    ExtensionNotSupported(String)
    SlotNotSupported
    } derive(Eq,
    Debug
    )

    Errors that can occur during expression evaluation.

    Context

    Request context — three states matching Rust's CPE:
    • Concrete(Value::Record(...)): fully known context
    • Unknown(Expr): entirely unknown (e.g., Expr::Unknown("context", None))
    • Partial(Expr): partially known, containing an Expr::Record where individual fields may be Expr::Unknown nodes.

    Dereference

    Result of looking up an entity in the store.

    EntityUIDEntry

    A PARC slot: either a known EntityUID (concrete eval) or a typed Unknown (partial eval).

    Request

    pub(all) struct Request {
    principal : EntityUIDEntry
    action : EntityUIDEntry
    resource : EntityUIDEntry
    context : Context
    } derive(Eq,
    Debug
    )

    The PARC authorization request.

    concrete_context

    fn concrete_context(value :
    Value
    ) -> Context

    construct a concrete Context from a Value.

    concrete_uid

    fn concrete_uid(type_ : String, id : String) -> EntityUIDEntry

    Helper: construct a concrete EntityUIDEntry.

    eval_binary

    Evaluate a binary operator on two concrete values. Does NOT handle In_ — that requires EntityStore access and is handled in expr_eval.mbt.

    eval_expr

    Evaluate a Cedar expression in the context of a Request and EntityStore. Returns Value(concrete) for fully-reducible expressions, or Residual(expr) for expressions that cannot be fully reduced (partial evaluation).

    eval_policy

    Evaluate a single policy against a Request and EntityStore. Returns: Value(Bool(true)) — policy satisfied (scope matched, all conditions passed) Value(Bool(false)) — policy not satisfied (scope didn't match, or condition failed) Residual(Expr) — partial eval: scope matched but some conditions are residual raise EvalError — evaluation error

    eval_unary

    Evaluate a unary operator on a concrete value.

    is_descendant

    Check if uid is equal to or a descendant of ancestor in the entity hierarchy. Uses BFS to traverse parent chains.

    partial_context

    fn partial_context(expr :
    Expr
    ) -> Context

    construct a partial Context from an Expr.

    scope_match

    Check whether a scope constraint matches the given entity variable.

    unknown_context

    fn unknown_context() -> Context

    construct an unknown Context.

    unknown_uid

    fn unknown_uid(type_ : String) -> EntityUIDEntry

    construct a unknown EntityUIDEntry.

    value_to_expr

    Convert a concrete Value back into an Expr (inverse of lit_to_value).

    wildcard_match

    fn wildcard_match(text : String, pattern :
    Pattern
    ) -> Bool

    Match a string against a Cedar like-pattern. * matches any sequence of characters (including empty). \* matches a literal * (already parsed as PatternElem::Char('*')).

    Uses two-pointer backtracking: on Wildcard, record the star position and advance the text pointer; on mismatch, backtrack to the last star.