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

Gathered_filter regex escape characters is too restrictive #579

Open
jgiroso opened this issue Aug 21, 2024 · 1 comment
Open

Gathered_filter regex escape characters is too restrictive #579

jgiroso opened this issue Aug 21, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jgiroso
Copy link

jgiroso commented Aug 21, 2024

Is your feature request related to a problem?

Utilizing the gathered_filter with regex requires very strict usage of escape characters, which is not consistent with other ansible filters/tasks. This means that as a user, local testing of the regex using a debug may return different results than when that regex is passed to the module.

I discovered this when the regex I had successfully tested locally with a regex_search filter was not returning any results with the palo gathered_filter even though I knew the objects existed

Current regex syntax to return results:

  • single quotes, double escape: 'name matches-regex \\w'
  • double quotes, quadruple escape: "name matches-regex \\\\w"

Describe the solution you'd like

Increased handling of regex escape characters when using regex for the gathered_filter.

In addition to the current behavior, I'd like to also see the following situations return results (note these are very over-simplified regex examples):

  • single quotes, single escape: 'name matches-regex \w'
  • double quotes, double escape: "name matches-regex \\w"

Additional context

Because the roles we create that utilize the palo modules can be consumed by other teams at our company that may not be aware of these restrictions, we've had to add a task to our roles to re-format the regex for them before the value is passed to the module

I'm including some screenshots of testing I did, including the playbook and printed output:

image
image
image

The playbook is run on localhost
Ansible versions:

  • ansible version 2.14.9
  • python version 3.9.16
  • paloaltonetworks.panos version 2.17.7 (I've tested with 2.20.0 and noticed the same behavior)
@jgiroso jgiroso added the enhancement New feature or request label Aug 21, 2024
@alperenkose alperenkose self-assigned this Sep 19, 2024
@alperenkose
Copy link
Collaborator

Hi @jgiroso ,

This has been implemented in the #583 PR which is merged to the beta branch for 3.0 release. This introduces a breaking change since the previous syntax for gathered_filter will not work but it accepts a valid regex now.
We don't have a release date yet for 3.0, however you may manually run the code from beta branch if you would like. I will keep the issue open for reference if people come across this for now.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants