-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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(inputs.snmp_trap): Handle octet strings #14619
Conversation
Thanks so much for the pull request! |
!signed-cla as CCLA |
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
When did you send in the signed CCLA? Trying to ensure you get added to the right list. |
It was sent to [email protected] on 24.01.2024 11:53 EET |
Thanks! I'll follow up with folks internally. |
!signed-cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your contribution @JuhaKS!
(cherry picked from commit 4c6df8d)
Summary
As discussed in #9113, any octetString data that goes beyond valid UTF-8 values will first be converted to a Golang string as the data is instantiated as a Metric. This step changes the presentation of the data but doesn't yet destroy anything, but the following json.Marshal that happens in use cases where the desired output format is JSON, the non-UTF characters get replaced with Unicode replacement characters, overwriting data octets in the process
This fix adds a check for SNMP data of type OctetString, that validates whether the data can be converted into valid UTF-8 or not. If yes, the data is passed unchanged. If not, the data is considered hex and processed with hex.EncodeToString. The end result with our test material is that the hex format timestamp is then passed correctly through processing, preserving both the data and its original presentation unchanged
Checklist
Related issues
resolves #9113