-
Notifications
You must be signed in to change notification settings - Fork 127
Description
Before opening, please confirm:
- I have searched for duplicate or closed issues.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Bug Category
Schemas and Validation
Describe the bug
When a schema contains multiple namesapces, it is possible to generate an in operator hierarchy respect error that claims one of the namespace's actions are not a descendant of the others.
This manifests when one of the actions that is a transitive member of the other namespace's actions specifies an appliesTo that points to the other namespace as well.
This might not be a bug, it may be an edge case that I'm not aware of.
Expected behavior
Create a schema with two namespaces, entities and actions in each NS1, NS2. NS2 will have entities that are members of NS1's entities, and NS2 will have actions that are direct and transitive members of NS1's actions.
Have an action in NS2 be a transitive member of an NS1 action group, and specify that NS2's action applies to a principal type within NS1.
Reproduction steps
- Create the repro files as in this issue
- Run the following command:
cedar validate --schema repro.cedarschema.json --policies repro.policy.txt --deny-warnings
Code Snippet
repro.cedarschema.json
{
"NS1": {
"entityTypes": {
"PrincipalEntity": {},
"SystemEntity1": {},
"SystemEntity2": {
"memberOfTypes": [
"SystemEntity1"
]
}
},
"actions": {
"Group1": {
"appliesTo": {
"principalTypes": [],
"resourceTypes": []
}
}
}
},
"NS2": {
"entityTypes": {
"SystemEntity1": {
"memberOfTypes": [
"NS1::SystemEntity2"
]
}
},
"actions": {
"Group1": {
"memberOf": [
{"id": "Group1", "type": "NS1::Action"}
],
"appliesTo": {
"principalTypes": [],
"resourceTypes": []
}
},
"Action1": {
"memberOf": [
{"id": "Group1"}
],
"appliesTo": {
"principalTypes": [
"NS1::PrincipalEntity"
],
"resourceTypes": [
"NS2::SystemEntity1"
]
}
}
}
}
}
repro.policy.txt
permit(
principal in NS1::PrincipalEntity::"user1",
action in NS1::Action::"Group1",
resource in NS1::SystemEntity1::"entity1"
);
Log output
Validation Failed
Validation Errors:
validation error on `policy `policy0``: operands to `in` do not respect the entity hierarchy. `NS2::Action` is not a descendant of `NS1::Action`
NOTE:
Remove the entire "appliesTo" in NS2::Action::Action1 and get this:
Validation Failed
Validation Errors:
validation error on `policy `policy0``: policy is impossible. The policy expression evaluates to false for all valid requests
Additional configuration
No response
Operating System
No response
Additional information and screenshots
No response