Skip to content

Conversation

shaobo-he-aws
Copy link
Contributor

@shaobo-he-aws shaobo-he-aws commented May 13, 2024

Description of changes

There were two issues with the original function.

  1. It iterates over templates instead of policies.
  2. It zips over iterations coming from hashmaps, whose orders are non-deterministic.

Issue #, if available

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

  • A bug fix or other functionality change requiring a patch to cedar-policy.

I confirm that this PR (choose one, and delete the other options):

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).

I confirm that cedar-spec (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar formal model or DRT infrastructure.

Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case?

@shaobo-he-aws
Copy link
Contributor Author

Can we add a test case?

Good idea. Working on it.

Signed-off-by: Shaobo He <[email protected]>
Signed-off-by: Shaobo He <[email protected]>
Comment on lines +148 to +157
let p1 = r#"permit (principal, action, resource)
when { "
a
" };"#;
let p2 = r#"permit (principal, action, resource)
when { "
a
" };"#;
assert!(soundness_check(p2, &parse_policyset(p1).unwrap()).is_err());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a dumb question, but why does the change in this PR help identify the issue in #862? Looking at the diff, it seems like the only change is to add a comparison of policy ids, which doesn't seem related.

Or is this test case unrelated to the changed code?

Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

templates() to policies() I think (line 45)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, thanks. @shaobo-he-aws can you add a description to the PR so it's easy not to miss this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines -72 to +80
"policies differ in meaning or annotations:\noriginal: {p}\nformatted: {f_p}"
"policies differ in policy ids or meaning or annotations:\noriginal: {p}\nformatted: {f_p}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: probably easier for debugging if you separate these cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll leave it to future work

@shaobo-he-aws shaobo-he-aws merged commit 9bf308a into main May 13, 2024
@shaobo-he-aws shaobo-he-aws deleted the fix/shaobo/formatter-check branch May 13, 2024 19:40
khieta pushed a commit that referenced this pull request May 15, 2024
khieta pushed a commit that referenced this pull request May 15, 2024
khieta pushed a commit that referenced this pull request May 16, 2024
@khieta khieta mentioned this pull request May 16, 2024
khieta pushed a commit that referenced this pull request May 16, 2024
khieta pushed a commit that referenced this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants