Module cedar_policy_core::ast

source ·
Expand description

This module contains the AST datatypes.

Structs§

  • Struct which holds the value of a particular annotation
  • Struct which holds the annotations for a policy
  • Like Id, except this specifically can contain Cedar reserved identifiers. (It still can’t contain, for instance, spaces or characters like ‘+’.)
  • A borrowed version of LiteralPolicy exclusively for serialization
  • While RestrictedExpr wraps an owned Expr, BorrowedRestrictedExpr wraps a borrowed Expr, with the same invariants.
  • Context field of a Request
  • EID type is just a SmolStr for now
  • Entity datatype
  • Error type for evaluation errors when evaluating an entity attribute. Contains some extra contextual information and the underlying EvaluationError.
  • Unique ID for an entity. These represent entities in the AST.
  • Internal AST for expressions used by the policy evaluator. This structure is a wrapper around an ExprKind, which is the expression variant this object contains. It also contains source information about where the expression was written in policy source code, and some generic data which is stored on each node of the AST. Cloning is O(1).
  • Builder for constructing Expr objects annotated with some data (possibly taking default value) and optionally a source_loc.
  • This structure implements the iterator used to traverse subexpressions of an expression.
  • A new type wrapper around Expr that provides Eq and Hash implementations that ignore any source information or other generic data used to annotate the Expr.
  • Cedar extension.
  • Extension function. These can be called by the given name in Ceder expressions.
  • Object container for extension values, also stores the constructor-and-args that can reproduce the value (important for converting the value back to RestrictedExpr for instance)
  • Identifiers. Anything in Id should be a valid identifier, this means it does not contain, for instance, spaces or characters like ‘+’; and also is not one of the Cedar reserved identifiers (at time of writing, true | false | if | then | else | in | is | like | has).
  • Wrapper around std::convert::Infallible which also implements miette::Diagnostic
  • Wraps the BTreeMap` into an opaque type so we can change it later if need be
  • Represents either an static policy or a template linked policy This is the serializable version because it simply refers to the Template by its Id;
  • This is the Name type used to name types, functions, etc. The name can include namespaces. Clone is O(1).
  • PartialValue, but serialized as a RestrictedExpr.
  • Represent a pattern literal (the RHS of the like operator) Also provides an implementation of the Display trait as well as a wildcard matching method.
  • A Policy that contains: a pointer to its template an link ID (unless it’s an static policy) the bound values for slots in the template
  • A unique identifier for a policy statement
  • Represents a set of Policys
  • Template constraint on principal scope variables
  • Represents the request tuple <P, A, R, C> (see the Cedar design doc).
  • A RequestSchema that does no validation and always reports a passing result
  • Template constraint on resource scope variables
  • A few places in Core use these “restricted expressions” (for lack of a better term) which are in some sense the minimal subset of Expr required to express all possible Values.
  • Like ExprShapeOnly, but for restricted expressions.
  • Value’s internal representation of a Set
  • SlotId plus a source location
  • Identifier for a slot Clone is O(1).
  • Static Policies are policy that do not come from templates. They have the same structure as a template definition, but cannot contain slots
  • Top level structure for a policy template. Contains both the AST for template, and the list of open slots in the template.
  • Policy datatype. This is used for both templates (in which case it contains slots) and static policies (in which case it contains zero slots).
  • Representation of a partial-evaluation Unknown at the AST level
  • This describes all the values which could be the dynamic result of evaluating an Expr. Cloning is O(1).

Enums§

  • Constraint for action scope variables. Action variables can be constrained to be in any variable in a list.
  • Built-in operators with exactly two arguments
  • Which “style” is a function call
  • Errors while trying to create a Context
  • the Effect of a policy
  • A reference to an EntityUID that may be a Slot
  • We support two types of entities. The first is a nominal type (e.g., User, Action) and the second is an unspecified type, which is used (internally) to represent cases where the input request does not provide a principal, action, and/or resource.
  • An entry in a request for a Entity UID. It may either be a concrete EUID or an unknown in the case of partial evaluation
  • Errors when constructing an Expr
  • The possible expression variants. This enum should be matched on by code recursively traversing the AST.
  • The output of an extension call, either a value or an unknown
  • Errors instantiating templates
  • First-class values which may appear as literals in Expr::Lit.
  • An error that can be thrown converting an expression to a value
  • Intermediate results of partial evaluation
  • Errors when converting PartialValue to RestrictedExpr
  • Errors encountered when converting PartialValue to Value
  • Represent an element in a pattern literal (the RHS of the like operation)
  • Potential errors when working with PolicySets.
  • Potential errors when working with PolicySets.
  • Potential errors when removing policies from a PolicySet.
  • Potential errors when removing templates from a PolicySet.
  • Potential errors when unlinking from a PolicySet.
  • Subset of AST variables that have the same constraint form
  • Represents the constraints for principals and resources. Can either not constrain, or constrain via == or in for a single entity literal.
  • Errors that can happen during policy reification
  • Error when constructing a restricted expression from unrestricted
  • Errors possible from RestrictedExpr::from_str()
  • Enum for errors encountered during substitution
  • This represents the runtime type of a Cedar value. Nominal types: two entity types are equal if they have the same Name.
  • Built-in operators with exactly one argument
  • Error for unexpected slots
  • This describes all the values which could be the dynamic result of evaluating an Expr. Cloning is O(1).
  • AST variables

Traits§

  • Extension value.
  • Extensions provide a type implementing ExtensionValue, Eq, and Ord. We automatically implement InternalExtensionValue for that type (with the impl below). Internally, we use dyn InternalExtensionValue instead of dyn ExtensionValue.
  • Trait for schemas capable of validating Requests
  • Trait for everything in Cedar that has a type known statically.

Functions§

  • Collect an iterator of either residuals or values into one of the following a) An iterator over values, if everything evaluated to values b) An iterator over residuals expressions, if anything only evaluated to a residual Order is preserved.

Type Aliases§

  • Trait object that implements the extension function call.
  • The integer type we use when parsing input
  • The integer types we use (both internally and for parsing). By default this is i64, but you may change to some suitable Integer type. If you do change this, some tests for over/underflow will need to change as well. The integer type we use internally
  • Map from Slot Ids to Entity UIDs which fill the slots