markabrahams / node-net-snmp

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

Unmatched grouping characters in comments break MIB file loading #218

Closed cdx50 closed 1 year ago

cdx50 commented 1 year ago

I've run into an issue when loading a MIB file that has unmatched grouping characters inside comments.

The file in particular can be found in the cisco/cisco-mibs repository at /v2/CISCO-QOS-PIB-MIB.my.

On line 234, the qosPIBConformance object is the last thing to get loaded for the module when reading with ModuleStore.loadFromFile().

In the comments that follow, there are 2 opening ( and only 1 closing ). If I edit the MIB file and add an extra ) at the end of the last comment line, the file is read and processed correctly.

To reproduce this, you can run the following test

const snmp = require("net-snmp");

const store = snmp.createModuleStore();

store.loadFromFile("/tmp/cisco-mibs/v2/CISCO-SMI.my");
store.loadFromFile("/tmp/cisco-mibs/v2/CISCO-QOS-PIB-MIB.my");

Object.keys(store.getModule("CISCO-QOS-PIB-MIB"))
  .forEach(key => console.log(key));

and notice that the output stops at qosPIBConformance.

I've created PR #217 which appears to fix this issue in my limited testing of this file (and the other Cisco files I needed), but admittedly did not see any other examples of this occurring for my current needs.

markabrahams commented 1 year ago

Hi @cdx50 - thanks for the PR! I've merged this now and published in version 3.9.1 of the npm.