-
Notifications
You must be signed in to change notification settings - Fork 0
Handle non-ascii community values in incoming traps without crashing #9
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
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
864a7ef
to
85972d7
Compare
Test results 4 files 4 suites 40s ⏱️ Results for commit 7bc9d71. ♻️ This comment has been updated with latest results. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9 +/- ##
==========================================
+ Coverage 72.05% 77.62% +5.56%
==========================================
Files 10 10
Lines 1256 1260 +4
==========================================
+ Hits 905 978 +73
+ Misses 351 282 -69 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7b5f2e6
to
6073f43
Compare
A device that sends traps with non-ascii community values will cause trap PDU processing to crash with a `UnicodeDecodeError`. community values are defined as ASCII in the SNMP specs, but some devices do not behave. netsnmp-cffi tries to be helpful to the client by automatically making a Python string from the community, but if there's a misbehaving device, this should not break everything.
If the community value of an incoming trap cannot be parsed as ASCII, we take care to just leave the raw bytes object for the client to inspect for themselves.
6073f43
to
7bc9d71
Compare
Really? RFC 1902 (yes, obsoleted), has
I would perhaps not have said it that way. Instead, I would have said that "it is a bad assumption to insist that everyone configuring SNMP community strings input only utf-8 valid sequences in the community string". Other than that, I think this change does the right thing and no longer insist on conformance to utf-8 coding, and instead just looks at this as an octet string. |
A device that sends traps with non-Ascii community values would cause trap PDU processing to crash with a
UnicodeDecodeError
.Community values are defined as ASCII in the SNMP specs, but some devices do not behave.
netsnmp-cffi
tries to be helpful to the client by automatically making a Python string from the community, but if there's a misbehaving device, this shouldn't break everything. This PR falls back to storing the raw bytes objects in the trap data structure if it cannot be successfully decoded as ASCII.