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

When numeric regex validation fails, no backtrace is logged #5089

Closed
chrcoluk opened this issue Dec 14, 2022 · 21 comments
Closed

When numeric regex validation fails, no backtrace is logged #5089

chrcoluk opened this issue Dec 14, 2022 · 21 comments
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Milestone

Comments

@chrcoluk
Copy link

chrcoluk commented Dec 14, 2022

Describe the bug

Popup box which says this when going in and out of device settings, also happens on some other screens.


Sorry, we could not process your last action.

Save Failed due to field input errors (Check red fields).

Log says the following.

4/Dec/2022 20:53:02 - CMDPHP Form Validation Failed: Variable 'id' with Value '66' Failed REGEX '0'

To Reproduce

Steps to reproduce the behavior:

Do as above, whilst using PHP 8.0 or newer.

Expected behavior

No errors.

Desktop (please complete the following information)

Windows, Firefox (latest stable)

Additional context

Switching back to PHP 7.4, its error free, note PHP 7.4 is EOL.

@chrcoluk chrcoluk added bug Undesired behaviour unverified Some days we don't have a clue labels Dec 14, 2022
@chrcoluk
Copy link
Author

To add, there is no red fields.

@netniV
Copy link
Member

netniV commented Dec 14, 2022

This is not a php 8 issue. The issue is that the regex validation failed to pass on the input.

@netniV
Copy link
Member

netniV commented Dec 14, 2022

Was there a stack trace in the logs to go with that error?

@chrcoluk
Copy link
Author

chrcoluk commented Dec 14, 2022

Nope, I tried to set devel logging, and enable anything that would increase verbosity, but that was it.

I have just set 8.0 again to help debug if needed, host.php I selected for debug as well, but its just that line.

@TheWitness
Copy link
Member

Do you have any plugins installed? If so, please name them.

@TheWitness
Copy link
Member

Okay, I this is interesting. Basically you have an invalid REGEX in one of your Data Input Methods. If you run the following Query:

SELECT dtd.data_input_id, dl.host_id, dif.id, dif.input_output, dif.data_name, 
dif.regexp_match, dif.allow_nulls, dif.type_code
FROM data_template_data AS dtd
LEFT JOIN data_input_fields AS dif
ON dif.data_input_id = dtd.data_input_id
LEFT JOIN data_local AS dl
ON dtd.local_data_id = dl.id
WHERE dif.input_output='in' and regexp_match != '';

You will find a Data Input Method that specifies a Regex, and the value of the Regex is 0, which is not a valid regular expression.

Here is a Screen Shot of that inside of Cacti.

image

If you run that Query, it'll give you a Data Input ID, then Edit that ID and clear the Regex Match. I'm going to see about handing this error during save though, but as a separate issue.

@TheWitness
Copy link
Member

Okay, after more testing '0' is a valid Regex value, but it also means that there is something wrong with you Data Input Method such that no data is being provided. Let me know what comes back from the query. This is likely happening at Graph Creation Time.

@TheWitness
Copy link
Member

@chrcoluk, any Feedback?

@TheWitness TheWitness changed the title Cacti 1.2.22 not compatible with PHP 8.0+ Numeric form validation regexes fail when the value column is null Dec 17, 2022
@TheWitness TheWitness changed the title Numeric form validation regexes fail when the value column is null Numeric form validation regexes fail when the value column is null or an empty string Dec 17, 2022
@TheWitness TheWitness added not a bug Not a bug as determined by dev support Support related issue and removed bug Undesired behaviour unverified Some days we don't have a clue labels Dec 17, 2022
@TheWitness
Copy link
Member

You will notice that the regex is 0, which means the exact value allowed is only 0, which is bad. So, the Data Input Method needs to be altered and the Regex cleared from the input field. So, this is really not a bug. It's a developer issue who is writing the Data Input Method.

@chrcoluk
Copy link
Author

chrcoluk commented Dec 18, 2022

Hi I wasnt here for two days, I can run this query and give you the result, if you are still interested.

I wasnt actually trying to create a graph though, I was just going into the devices page and back out of it, without changing/saving anything.

Also ideally the logs should point this to me, as the warning/error was very vague?

I will get back to you on the query.

Do you have any reason as well as to why php 7.x doesnt detect this and 8.0 does?

@chrcoluk
Copy link
Author

chrcoluk commented Dec 18, 2022

I get an empty result, not even a 0, just nothing. This is probably correct as I dont think I use regex on any of them.

mysql> use cacti
Database changed
mysql> SELECT dtd.data_input_id, dl.host_id, dif.id, dif.input_output, dif.data_name, 
    -> dif.regexp_match, dif.allow_nulls, dif.type_code
    -> FROM data_template_data AS dtd
    -> LEFT JOIN data_input_fields AS dif
    -> ON dif.data_input_id = dtd.data_input_id
    -> LEFT JOIN data_local AS dl
    -> ON dtd.local_data_id = dl.id
    -> WHERE dif.input_output='in' and regexp_match != '';
Empty set (0.00 sec)

@chrcoluk
Copy link
Author

chrcoluk commented Dec 18, 2022

If I browse the data input methods, the majority will make the box popup and log an entry in the log, again no trace, also never anything highted red. PHP 7.4 no popups, no log entries.

Is there a way to disable this validation?

@TheWitness
Copy link
Member

What plugins do you have installed? If you do, mention their versions.

@TheWitness TheWitness reopened this Dec 18, 2022
@TheWitness
Copy link
Member

Yes, there is a way to turn it off, but before we do, let's find out where it's happening.

@chrcoluk
Copy link
Author

chrcoluk commented Dec 18, 2022

Ok list of plugins as presented in the GUI

Monitor Active 2.5
Fix64bit Installed 0.4
Ipsubnet Installed .4f
Thold Active 1.5.2

I have no care for the middle two so dont mind dropping tham as is.

@TheWitness
Copy link
Member

Okay, it's one of them. Can't you tgz and upload Fix64 and Ipsubnet?

@TheWitness
Copy link
Member

TheWitness commented Dec 18, 2022

To stop the message go to Settings > General and disable Log Input Validation Issues

@TheWitness
Copy link
Member

It's really a developer mode to catch bad behavior, which it did perfectly, well maybe a little less than perfectly.

@TheWitness TheWitness changed the title Numeric form validation regexes fail when the value column is null or an empty string When numeric regex validation fails, not backtrace message is logged in the Cacti log Dec 18, 2022
TheWitness added a commit that referenced this issue Dec 18, 2022
When numeric regex validation fails, not backtrace message is logged in the Cacti log
@TheWitness
Copy link
Member

I've made an update to lib/functions.php that will be a part of Cacti 1.2.23 that will give you a better clue as to where the bug is when in Log Validation Issues mode.

@TheWitness TheWitness added bug Undesired behaviour resolved A fixed issue confirmed Bug is confirm by dev team and removed not a bug Not a bug as determined by dev support Support related issue labels Dec 18, 2022
@TheWitness TheWitness added this to the v1.2.23 milestone Dec 18, 2022
@chrcoluk
Copy link
Author

Ok I will do the upload, and remove those 2, also when I toggled the option, it stopped the log but didnt remove the popup, could you please also make the option remove the popup?

@chrcoluk
Copy link
Author

fix64bit.tgz
ipsubnet.tgz

@netniV netniV changed the title When numeric regex validation fails, not backtrace message is logged in the Cacti log When numeric regex validation fails, no backtrace is logged Dec 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour confirmed Bug is confirm by dev team resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

3 participants