Stefan de Kooter
07/29/2025, 2:44 PMAnne-Leslie Dean
07/29/2025, 11:11 PMStefan de Kooter
07/30/2025, 9:23 AM- expr: |
!R.action.matches("^a_b_c")
Invalid expression `!R.action.matches("^a_b_c")
`: [undefined field 'action']
Sam Lock (Cerbos)
07/30/2025, 10:38 AM:
) delimiters are strict on their boundaries, so if your actions were of the form a:b:*
rather than a_b*
(etc), then I believe it behaves the way you're anticipating.
This example policy:
---
apiVersion: api.cerbos.dev/v1
resourcePolicy:
version: "default"
resource: foo
rules:
- actions: ["a:b:c:*"]
effect: EFFECT_ALLOW
roles: ["user"]
- actions: ["a:b:*"]
effect: EFFECT_DENY
roles: ["user"]
With this request:
{
"requestId": "test",
"principal": {
"id": "sam",
"policyVersion": "default",
"scope": "",
"roles": [
"user"
]
},
"resources": [
{
"actions": [
"a:b:c:d",
"a:b:d",
"a:b:c",
"a:b:c:"
],
"resource": {
"kind": "foo",
"policyVersion": "default",
"id": "XX125"
}
}
]
}
Returns the following:
{
"requestId": "test",
"results": [
{
"resource": {
"id": "XX125",
"kind": "foo",
"policyVersion": "default"
},
"actions": {
"a:b:c": "EFFECT_DENY",
"a:b:c:": "EFFECT_ALLOW",
"a:b:c:d": "EFFECT_ALLOW",
"a:b:d": "EFFECT_DENY"
}
}
],
"cerbosCallId": "01K1DEH8EC29KKK83R6GK73RBV"
}
Sam Lock (Cerbos)
07/30/2025, 10:40 AMI don't know the special variable name for the 'action':This isn't supported (actions are used to match requests to given policy rules, rather than for conditional logic in the expressions).