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

Cacti regular expression searching does not quote expressions #4080

Closed
andyb2000 opened this issue Jan 22, 2021 · 7 comments
Closed

Cacti regular expression searching does not quote expressions #4080

andyb2000 opened this issue Jan 22, 2021 · 7 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@andyb2000
Copy link

Describe the bug

A clear and concise description of what the bug is.
I use an external tool to link and search specific graphs, I do this by referencing graph_view.php with get variables to carry out the search. An example url is:
/cacti/graph_view.php?action=preview&external_id=191&rfilter=Gi1/0/12

This returns no matches, and the "Search" filter box is empty. If you then type in Gi1/0/12 into the Search filter box it works. (POST'd variable?)

There appears to be a bug in the parser for rfilter that uses get_request_var (lib/html_utility.php) called from graph_view.php Some work and some do not. So for example:

/cacti/graph_view.php?action=preview&external_id=191&rfilter=Gi1/0/1
WORKS
/cacti/graph_view.php?action=preview&external_id=191&rfilter=Gi1/0/10
DOES NOT

It appears to be when two digits or more are on the end of the gig int variable. I suspect this is due to the slashes being stripped/interpreted.

To Reproduce

Use a get/query to search for something that is known to exist using the Gi1/0/12 prefix or similar Cisco naming convention:

/cacti/graph_view.php?action=preview&external_id=191&rfilter=Gi1/0/12

Fails, whilst:
/cacti/graph_view.php?action=preview&external_id=191&rfilter=Gi1/0/1
Would succeed.

Expected behavior

Search would return values and Search box would show the get query.

Desktop (please complete the following information)

  • OS: Windows 10 enterprise

  • Browser Chrome (Also tested with Edge and firefox on different operating systems)

Additional context

Cacti version 1.2.10
Ubuntu 20.04.1

@andyb2000 andyb2000 added bug Undesired behaviour unverified Some days we don't have a clue labels Jan 22, 2021
@TheWitness
Copy link
Member

That's quite odd.

@TheWitness TheWitness changed the title graph_view rfilter bug Cacti Regular Expression Searching does not quote expressions Jan 23, 2021
@TheWitness TheWitness changed the title Cacti Regular Expression Searching does not quote expressions Cacti regular expression searching does not quote expressions Jan 23, 2021
@TheWitness
Copy link
Member

@andyb2000, I'm going to commit a simple fix and I need you to test it out. Let me know if it fixes the issue. The issue is with regular expression quoting for special character handling I think, but you will need to update graph_view.php to the 1.2.x branch version and then test and provide feedback. If you don't want to take the whole file, just look at the diff. The changes are very small.

TheWitness added a commit that referenced this issue Jan 23, 2021
- Cacti regular expression searching does not quote expressions
@TheWitness
Copy link
Member

Okay, changes are in.

@TheWitness TheWitness added resolved A fixed issue and removed unverified Some days we don't have a clue labels Jan 23, 2021
@TheWitness TheWitness added this to the v1.2.17 milestone Jan 23, 2021
@andyb2000
Copy link
Author

Thanks for taking a look @TheWitness
Unfortunately no luck, I grabbed the changes in graph_view.php and applied, however same problem.
A url like this:
/cacti/graph_view.php?action=preview&external_id=535&rfilter=Gi1/0/14

No search results and in the search box it doesn't populate Gi1/0/14

@TheWitness
Copy link
Member

Is external_id even included. I have to check that.

@TheWitness
Copy link
Member

So, open graph view, and goto line ~458 and add the following:

cacti_log(str_replace("\n", " ", $sql_where));

Then run your tests and post back what you find in the Cacti log. Then, play with the following logic, using the regular expression:

SELECT title_cache FROM graph_templates_graph RLIKE 'whatever from thelog';

Let me know what you find.

TheWitness added a commit that referenced this issue Feb 7, 2021
This change provides additional fixups.  Though the problems is really the regular expression and beyond Cacti's control.
@TheWitness
Copy link
Member

I've made another change. I think this may go back to a MySQL/MariaDB issue. They have made some changes recently to the way they handle regular expressions. You should upgrade your database, implement the minor changes that I have made, and if you still have problems, use my advice above. It's all working for simple cases for me.

@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants