Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast: Disallowing partial object rules to have other partial object rule within their immediate extent #5864

Conversation

johanfylling
Copy link
Contributor

The compiler should disallow single-value rules to have other rules within their extent. Previously, the compiler would erroneously allow such overlaps, where the immediate "child" rule of a partial object rule in the rule tree was also a partial object rule. This condition is not expected during evaluation, which will result in a broken object merge.

Fixes: #5855

…le within their immediate extent

The compiler should disallow single-value rules to have other rules within their extent.
Previously, the compiler would erroneously allow such overlaps, where the immediate "child" rule
of a partial object rule in the rule tree was also a partial object rule.
This condition is not expected during evaluation, which will result in a broken object merge.

Fixes: open-policy-agent#5855
Signed-off-by: Johan Fylling <[email protected]>
@netlify
Copy link

netlify bot commented Apr 25, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 01210a1
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/6447c7789a4a410008930112
😎 Deploy Preview https://deploy-preview-5864--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

srenatus
srenatus previously approved these changes Apr 25, 2023
singleValueConflicts = append(singleValueConflicts, childRule.Ref())
}
}
}
if len(c.Children) > 0 {
singleValueConflicts = node.flattenChildren()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just from looking at the code, it looks like singleValueConflicts could be set in line 912, and end up being overwritten here. But I guess the two branches are mutually exclusive?

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 they are 🤔 .
But you have a good point. I'll make this an append to be on the safe side. Don't think its worthwhile looking for duplicates, though.

@johanfylling johanfylling merged commit 3311587 into open-policy-agent:main Apr 25, 2023
@johanfylling johanfylling deleted the jf/invalid_partial_object_merge branch April 25, 2023 13:01
kjothen pushed a commit to kjothen/opa that referenced this pull request Apr 25, 2023
…le within their immediate extent (open-policy-agent#5864)

The compiler should disallow single-value rules to have other rules within their extent.
Previously, the compiler would erroneously allow such overlaps, where the immediate "child" rule
of a partial object rule in the rule tree was also a partial object rule.
This condition is not expected during evaluation, which will result in a broken object merge.

Fixes: open-policy-agent#5855
Signed-off-by: Johan Fylling <[email protected]>
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.

Partial object rules with ref-heads erroneously merges values
2 participants