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

fix(gathered_filter): Fix error handling for no-value operators #489

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion plugins/module_utils/panos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,14 +1201,24 @@ def matches_gathered_filter(self, item, logic):
except StopIteration:
raise Exception(err_msg)

operator_list = operator.split(")")
operator = operator_list[0]
if operator == "is-none":
evaler.append("{0}".format(item_config[field] is None))
elif operator == "is-not-none":
evaler.append("{0}".format(item_config[field] is not None))
elif operator == "is-true":
evaler.append("{0}".format(bool(item_config[field])))
elif operator == "is-false":
evaler.append("{0}".format(bool(not item_config[field])))
evaler.append("{0}".format(not bool(item_config[field])))

if operator in ["is-none", "is-not-none", "is-true", "is-false"]:
evaler.extend(")" * (len(operator_list) - 1))
pdepth -= len(operator_list) - 1
continue

if len(operator_list) != 1:
raise Exception(err_msg)

try:
value = next(token_iter)
Expand Down
Loading