Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
aa1f59e
Entity slicing implementation
oflatt Jun 21, 2024
649649c
fix up imports and such
oflatt Jul 29, 2024
fff1e1d
remove unecessary functions for now
oflatt Jul 29, 2024
9aad9f9
revert test_impl.rs
oflatt Jul 29, 2024
b7495f1
remove human format for manifest
oflatt Jul 29, 2024
d827833
more clean up
oflatt Jul 29, 2024
d2a7507
rename
oflatt Jul 29, 2024
5564cfc
more removal of code
oflatt Jul 29, 2024
f2e456d
more cleanup and rename
oflatt Jul 29, 2024
e7d41d9
remove more simple api stuff
oflatt Jul 29, 2024
9bf73e5
better error message for non-analyzable policies
oflatt Jul 29, 2024
1a9b8d2
better error message and comment
oflatt Jul 29, 2024
56c92c0
better comments
oflatt Jul 30, 2024
dcfc1cd
much better docs
oflatt Jul 30, 2024
132ab4d
add experimental warning
oflatt Jul 30, 2024
b5eca9b
update changelog, remove cli for now
oflatt Jul 30, 2024
564dd1e
feature flag for entity manifests
oflatt Jul 30, 2024
1118d96
panic safety comments
oflatt Jul 30, 2024
906757d
remove line breaks from panic safety comments
oflatt Jul 30, 2024
18ec86e
fix doc comments
oflatt Jul 30, 2024
bce7c85
fix up build with unused import
oflatt Jul 30, 2024
66e5a52
re-name to entity manifest file
oflatt Jul 31, 2024
cd9f2e9
oops, add entity manifest file
oflatt Jul 31, 2024
f5e5c65
re-name entity manifest error
oflatt Jul 31, 2024
45b9c72
Update cedar-policy-core/src/ast/request.rs
oflatt Aug 1, 2024
dda91d0
Update cedar-policy-core/src/ast/request.rs
oflatt Aug 1, 2024
c444758
Update cedar-policy-validator/src/entity_manifest.rs
oflatt Aug 1, 2024
7528111
Update cedar-policy-validator/src/entity_manifest.rs
oflatt Aug 1, 2024
1a49a4c
Update cedar-policy/src/api.rs
oflatt Aug 1, 2024
a736421
Update cedar-policy/src/api.rs
oflatt Aug 1, 2024
84545d7
Respond to @cdisselkoen PR feedback
oflatt Aug 1, 2024
effb671
caught bug with new test case
oflatt Aug 1, 2024
34c461b
remove typechecking TODO
oflatt Aug 26, 2024
d45421e
add feature to validator crate as well
oflatt Aug 26, 2024
e0fd602
move public error to err.rs file
oflatt Aug 26, 2024
3700d54
caution on pub types
oflatt Aug 26, 2024
a3d3d37
undo bad merges
oflatt Aug 26, 2024
cadb083
use correct error macro
oflatt Aug 27, 2024
c3d2991
cedar schema str fn
oflatt Aug 27, 2024
3c19c99
address feedback from @john-h-kastner-aws
oflatt Aug 27, 2024
4f05181
docs and camel case
oflatt Aug 27, 2024
e81929a
add todo
oflatt Aug 27, 2024
50d604b
use validationresult
oflatt Aug 27, 2024
5f95c34
Revert "use validationresult"
oflatt Aug 27, 2024
2a3e365
working on error type
oflatt Aug 27, 2024
4862481
make error wrapper for entity manifest work
oflatt Aug 27, 2024
a2afe85
finish making wrapper for entity manifest errors
oflatt Aug 27, 2024
ff06de6
fmt, docs
oflatt Aug 27, 2024
4bf079e
fix up non-feature build
oflatt Aug 27, 2024
9ac723b
oops
oflatt Aug 28, 2024
ef363e4
Update cedar-policy/CHANGELOG.md
oflatt Aug 29, 2024
e0cdb82
Update cedar-policy-validator/src/entity_manifest.rs
oflatt Aug 29, 2024
fc5639a
Update cedar-policy-validator/src/entity_manifest.rs
oflatt Aug 29, 2024
5371391
Update cedar-policy-validator/src/entity_manifest.rs
oflatt Aug 29, 2024
1db288b
add issues for todos
oflatt Aug 29, 2024
ad96bd3
copyright at the top
oflatt Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions cedar-policy-core/src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,30 @@ impl From<PartialValue> for Expr {
}
}

impl<T> ExprKind<T> {
/// Describe this operator for error messages.
pub fn operator_description(self: &ExprKind<T>) -> String {
match self {
ExprKind::Lit(_) => "literal".to_string(),
ExprKind::Var(_) => "variable".to_string(),
ExprKind::Slot(_) => "slot".to_string(),
ExprKind::Unknown(_) => "unknown".to_string(),
ExprKind::If { .. } => "if".to_string(),
ExprKind::And { .. } => "&&".to_string(),
ExprKind::Or { .. } => "||".to_string(),
ExprKind::UnaryApp { op, .. } => op.to_string(),
ExprKind::BinaryApp { op, .. } => op.to_string(),
ExprKind::ExtensionFunctionApp { fn_name, .. } => fn_name.to_string(),
ExprKind::GetAttr { .. } => "get attribute".to_string(),
ExprKind::HasAttr { .. } => "has attribute".to_string(),
ExprKind::Like { .. } => "like".to_string(),
ExprKind::Is { .. } => "is".to_string(),
ExprKind::Set(_) => "set".to_string(),
ExprKind::Record(_) => "record".to_string(),
}
}
}

impl<T> Expr<T> {
fn new(expr_kind: ExprKind<T>, source_loc: Option<Loc>, data: T) -> Self {
Self {
Expand Down
31 changes: 28 additions & 3 deletions cedar-policy-core/src/ast/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use crate::evaluator::{EvaluationError, RestrictedEvaluator};
use crate::extensions::Extensions;
use crate::parser::Loc;
use miette::Diagnostic;
use serde::Serialize;
use serde::{Deserialize, Serialize};
use smol_str::SmolStr;
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
use thiserror::Error;

use super::{
BorrowedRestrictedExpr, EntityUID, Expr, ExprKind, ExpressionConstructionError, PartialValue,
RestrictedExpr, Unknown, Value, ValueKind, Var,
BorrowedRestrictedExpr, EntityType, EntityUID, Expr, ExprKind, ExpressionConstructionError,
PartialValue, RestrictedExpr, Unknown, Value, ValueKind, Var,
};

/// Represents the request tuple <P, A, R, C> (see the Cedar design doc).
Expand All @@ -49,6 +49,18 @@ pub struct Request {
pub(crate) context: Option<Context>,
}

/// Represents the principal type, resource type, and action UID.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RequestType {
/// Principal type
pub principal: EntityType,
/// Action type
pub action: EntityUID,
/// Resource type
pub resource: EntityType,
}

/// 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
Expand Down Expand Up @@ -186,6 +198,19 @@ impl Request {
pub fn context(&self) -> Option<&Context> {
self.context.as_ref()
}

/// Get the request types that correspond to this request.
/// This includes the types of the principal, action, and resource.
/// [`RequestType`] is used by the entity manifest.
/// The context type is implied by the action's type.
/// Returns `None` if the request is not fully concrete.
pub fn to_request_type(&self) -> Option<RequestType> {
Some(RequestType {
principal: self.principal().uid()?.entity_type().clone(),
action: self.action().uid()?.clone(),
resource: self.resource().uid()?.entity_type().clone(),
})
}
}

impl std::fmt::Display for Request {
Expand Down
1 change: 1 addition & 0 deletions cedar-policy-validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ arbitrary = ["dep:arbitrary", "cedar-policy-core/arbitrary"]
# Experimental features.
partial-validate = []
wasm = ["serde-wasm-bindgen", "tsify", "wasm-bindgen"]
entity-manifest = []

[dev-dependencies]
similar-asserts = "1.5.0"
Expand Down
Loading