Closed CarlHenrik closed 7 months ago
Hi @CarlHenrik - thanks for logging this. Can you provide a link to or text of an example MIB with an unannotated numeric middle entry (or entries) in the OID? I haven't come across such a MIB definition before, and would like to add such a real-world example MIB to my test collection. Thanks!
Sure, here are two examples attached (provided as .txt so that github allows it):
Thanks again @CarlHenrik - I've fixed this now and published the fix in version 3.10.4 of the npm.
Issue
Some MIBs have middle entries in their object identifier information, associating object names for the middle entries, such as:
::= { enterprises custom(1234) object(5) names(67) 8 }
This works fine. However, many MIBs have middle entries without providing object name annotations, such as:
::= { enterprises 1234 5 67 8 }
The above example fails, compared to the conventional annotation that includes object name. In this case, the compiler skips the middle entries, and the output result is the same as
::= { enterprises 8 }
.Code
https://github.com/markabrahams/node-net-snmp/blob/fe4fdf6e1f2be0f1c57ba7e3e5fa422cad9cdd81/lib/mib.js#L762-L780
How to reproduce
MODULE-IDENTITY
orOBJECT IDENTIFIER
with middle entries of numbers only in their object identifier, like in the second example above.oid
andnamespace
properties of the compiled nodes from themoduleStore
, or set breakpoints in the referenced code.Proposed solution
The regex in the referenced code does not capture middle entries with numbers only. The code should be reworked to handle middle entries without annotations, as this is not uncommon.
For reference, other MIB tools handle this by building a custom placeholder for object names, so that:
::= { enterprises 1234 5 67 8 }
becomes[...].enterprises.enterprises-1234.enterprises-1234-5.enterprises-1234-5-67.8
, which is not pretty, but it can be handled at a later stage.