Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions cedar-policy-core/src/entities/json/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,21 +502,21 @@ impl CedarValueJson {
self,
mapping: &BTreeMap<EntityUID, EntityUID>,
) -> Result<Self, JsonDeserializationError> {
match self.clone() {
match self {
// Since we are modifying an already legal policy, this should be unreachable.
CedarValueJson::ExprEscape { __expr } => Err(JsonDeserializationError::ExprTag(
Box::new(JsonDeserializationErrorContext::Unknown),
)),
CedarValueJson::EntityEscape { __entity } => {
let euid = EntityUID::try_from(__entity);
let euid = EntityUID::try_from(__entity.clone());
match euid {
Ok(euid) => match mapping.get(&euid) {
Some(new_euid) => Ok(CedarValueJson::EntityEscape {
__entity: new_euid.into(),
}),
None => Ok(self),
None => Ok(CedarValueJson::EntityEscape { __entity }),
},
Err(_) => Ok(self),
Err(_) => Ok(CedarValueJson::EntityEscape { __entity }),
}
}
CedarValueJson::ExtnEscape { __extn } => Ok(CedarValueJson::ExtnEscape {
Expand All @@ -525,9 +525,9 @@ impl CedarValueJson {
arg: Box::new((*__extn.arg).sub_entity_literals(mapping)?),
},
}),
CedarValueJson::Bool(_) => Ok(self),
CedarValueJson::Long(_) => Ok(self),
CedarValueJson::String(_) => Ok(self),
v @ CedarValueJson::Bool(_) => Ok(v),
v @ CedarValueJson::Long(_) => Ok(v),
v @ CedarValueJson::String(_) => Ok(v),
CedarValueJson::Set(v) => Ok(CedarValueJson::Set(
v.into_iter()
.map(|e| e.sub_entity_literals(mapping))
Expand All @@ -540,7 +540,7 @@ impl CedarValueJson {
}
Ok(CedarValueJson::Record(JsonRecord { values: new_m }))
}
CedarValueJson::Null => Ok(self),
v @ CedarValueJson::Null => Ok(v),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions cedar-policy-core/src/est/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,13 @@ impl Expr {
self,
mapping: &BTreeMap<EntityUID, EntityUID>,
) -> Result<Self, JsonDeserializationError> {
match self.clone() {
match self {
Expr::ExprNoExt(e) => match e {
ExprNoExt::Value(v) => Ok(Expr::ExprNoExt(ExprNoExt::Value(
v.sub_entity_literals(mapping)?,
))),
ExprNoExt::Var(_) => Ok(self),
ExprNoExt::Slot(_) => Ok(self),
v @ ExprNoExt::Var(_) => Ok(Expr::ExprNoExt(v)),
s @ ExprNoExt::Slot(_) => Ok(Expr::ExprNoExt(s)),
ExprNoExt::Not { arg } => Ok(Expr::ExprNoExt(ExprNoExt::Not {
arg: Arc::new(Arc::unwrap_or_clone(arg).sub_entity_literals(mapping)?),
})),
Expand Down
Loading