Skip to content

EST allows annotation identifiers that are forbidden in human formated policies #623

@john-h-kastner-aws

Description

@john-h-kastner-aws

Before opening, please confirm:

Bug Category

Cedar Parser

Describe the bug

In this EST JSON, there is an annotation identifier if

{
  "annotations": {
    "if": ""
  },
  "effect": "permit",
  "principal": {
    "op": "All"
  },
  "action": {
    "op": "All"
  },
  "resource": {
    "op": "All"
  },
  "conditions": []
}

We can parse this and obtain a Policy object, but printing that policy to a string gives

@if("") 
permit(principal, action, resource);

Which does not parse because if is a reserved identifier.

    let est = serde_json::json!(
        {
            "annotations": {
              "if": ""
            },
            "effect": "permit",
            "principal": {
              "op": "All"
            },
            "action": {
              "op": "All"
            },
            "resource": {
              "op": "All"
            },
            "conditions": []
        }
    );
    let p = Policy::from_json(None, est).unwrap();
    let human_src = p.to_string();
    Policy::from_str(&human_src).unwrap(); // This panics

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

    bugSomething isn't working. This is as high priority issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions