Skip to content

Fix level checking for access on an if expression #1507

@john-h-kastner-aws

Description

@john-h-kastner-aws

Before opening, please confirm:

Bug Category

Schemas and Validation

Describe the bug

It looks like the guard of an if expression is being considered when level checking any access on an if expression. Only the branches should be considered (though the guard should of course be checked independently).

For example, and error is reported for this policy

permit(principal, action, resource) when {
  (
    if principal.jobLevel == 0 then
      principal
    else
      principal
  ).jobLevel == 0
};

I think this happens because it looks at the guard where there was already an attribute access, and then reports an error when it sees another access in the outer expression

Expected behavior

.

Reproduction steps

.

Code Snippet

// Put your code below this line.

Log output

// Put your output below this line

Additional configuration

No response

Operating System

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    papercutSmall annoyances in the Cedar SDK. Lower priority fixes than bugs. Smaller than a feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions