IP::fromHexString handle ascii#15504
Merged
murrant merged 2 commits intolibrenms:masterfrom Oct 26, 2023
Merged
Conversation
Some bad MIBs convert the hex to ascii on display. Attempt to decode that if the situation is detected. fixes librenms#15501
Jellyfrog
reviewed
Oct 25, 2023
|
|
||
| // check if hex was incorrectly converted to ascii | ||
| $len = strlen($hex); | ||
| if (($len == 4 || $len == 16) && preg_match('/[^0-9a-fA-F]/', $hex)) { |
Member
There was a problem hiding this comment.
Do we have some tests for this? It’s really hard to understand why it’s needed else, or what the length check is
Member
Author
There was a problem hiding this comment.
Juniper doesn't know how to set their MIB display hint correctly.
From the linked issue: https://supportportal.juniper.net/s/article/Junos-Values-for-show-snmp-mib-walk-jnxBgpM2PeerLocalAddr-don-t-appear-correct?language=en_US
Basically any hex in the ascii range gets converted to ascii. Because IPs are fixed length, IPv4 will be 4 characters and IPv6 will be 16 characters. The length check is to avoid running the preg_match every time and improve the accuracy of the check.
Member
Author
There was a problem hiding this comment.
Tests would be a good idea ;)
gdepeyrot
pushed a commit
to gdepeyrot/librenms
that referenced
this pull request
Nov 29, 2023
* IP::fromHexString handle ascii Some bad MIBs convert the hex to ascii on display. Attempt to decode that if the situation is detected. fixes librenms#15501 * add ascii tests
gunkaaa
pushed a commit
to gunkaaa/librenms
that referenced
this pull request
Jan 8, 2024
* IP::fromHexString handle ascii Some bad MIBs convert the hex to ascii on display. Attempt to decode that if the situation is detected. fixes librenms#15501 * add ascii tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some bad MIBs convert the hex to ascii on display.
Attempt to decode that if the situation is detected.
fixes #15501
Please give a short description what your pull request is for
DO NOT DELETE THE UNDERLYING TEXT
Please note
Testers
If you would like to test this pull request then please run:
./scripts/github-apply <pr_id>, i.e./scripts/github-apply 5926After you are done testing, you can remove the changes with
./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.