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

Correct inclusion of parentheses when outputing constraints #133

Merged
merged 1 commit into from
May 6, 2024

Conversation

marshalljmiller
Copy link
Contributor

The existing algorithm to convert constraints from postfix to infix notation does not insert parentheses correctly. This change addresses the problem.

For example, given the following expression in the source policy:
( t2 == ssh_client_packet_t or t2 == ssh_server_packet_t ) and t1 == sshd_t

The output currently returned would be:
t2 == ssh_client_packet_t or ( t2 == ssh_server_packet_t ) and ( t1 == sshd_t )

Which of course is not equivalent to the actual expression due to the lack of parentheses surrounding the "or" expression.

Comment on lines 201 to 204
class StackObj:
def __init__(self, precedence, expression):
self.precedence = precedence
self.expression = expression
Copy link
Member

Choose a reason for hiding this comment

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

Please use a dataclass.

@marshalljmiller marshalljmiller requested a review from pebenito May 6, 2024 18:55
@pebenito
Copy link
Member

pebenito commented May 6, 2024

Please squash to 1 commit, then I'll merge.

@pebenito pebenito merged commit 305c8fa into SELinuxProject:main May 6, 2024
9 checks passed
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.

2 participants