markabrahams / node-net-snmp

JavaScript implementation of the Simple Network Management Protocol (SNMP)
206 stars 97 forks source link

OID construction fails when object identifiers are out of order #253

Closed CarlHenrik closed 1 week ago

CarlHenrik commented 3 weeks ago

Issue

MIBs that have object identifiers out of order fails to compile correctly, as the OID at some point fails to mount onto parent. Example:

powerMIB MODULE-IDENTITY
    ::= { global 1 }    

ees OBJECT IDENTIFIER ::= { enterprises 6302 }

global OBJECT IDENTIFIER ::= { ees 2 }

The powerMIB object fails to get an OID, since the parent global object has not yet been parsed. https://github.com/markabrahams/node-net-snmp/blob/ce3691a01ca2e5a5ac8993f3dc96861f337421bb/lib/mib.js#L768-L788

I assume you are already aware of this, as comments on line 782-783 mention this particular scenario. I have provided a real MIB with this exact issue (again from Emerson...), and this compiles fine in other MIB tools: M530S-power.mib.txt

I don't know if this out of order dependency is violating the SMI standard, but since other tools can handle it so should probably this one as well.

How to reproduce

  1. Load provided MIB.
  2. Inspect the powerMIB object in module store.

Proposed solution

markabrahams commented 1 week ago

Hi @CarlHenrik - thanks for raising this. I haven't been able to find a steer in either RFC 1155 (SMIv1) or RFC 2578 (SMIv2) on whether out-of-order references should be supported or not.

So in the absence of RFC guidance, I agree that this would be good to support. I'm open to a PR here, or to implementing this myself.

CarlHenrik commented 1 week ago

I'll see if I can find time to create a PR within the next few days.

CarlHenrik commented 1 week ago

Created pull request #254 to resolve this issue.

markabrahams commented 1 week ago

Thanks heaps @CarlHenrik - I've merged #254 now and published in version 3.13.0 of the npm.