markabrahams / node-net-snmp

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

SNMPv3 / SHA: TypeError: Cannot read properties of undefined (reading 'AUTHENTICATION_CODE_LENGTH') #219

Closed mcm1957 closed 1 year ago

mcm1957 commented 1 year ago

I have some code which was running without problems with previous versions upgraded to v3.9.0. Now I receive the follwoing error TypeError: Cannot read properties of undefined (reading 'AUTHENTICATION_CODE_LENGTH') from session.get.

Environment: net-snmp V3.9.0 (v3.9.1 has no fixed according to releasenotes which could be relevant to this topic)

SNMP v3 Method Authentication only Authentication type: SHA

Target is a synology nas which supports snmpv3 with MD5 and SHA. Using MD5 works without an error.

Is there any possibility to track this issue down further to check whether net-snmp has a issue, my code is faulty or synology responds with an incorrect answer ?

mcm1957 commented 1 year ago

HOLD ON - I just detected a possible problem within my code. I'll be back in some minutes.

mcm1957 commented 1 year ago

OK, it was definitly a problem with my code. I referred to your constants as

snmpAuthProtocol = snmp.AuthProtocols.SHA;

instead of

snmpAuthProtocol = snmp.AuthProtocols.sha;

So thereas no problem with your code at all.

BUT I would suggest the following improvements:

-) Check parameters passed directly a call entry for valid values so that no unrelated errors "(reading AUTHENTICATION_CODE_ENGTH)" are reported and the user could faster detect it's error

-) check interface description as SHA is not reported as an error by vscode / eslint

markabrahams commented 1 year ago

Hi @mcm1957 - thanks for following up with the solution.

On your suggested improvements, introducing TypeScript to the project is for mind the best solution to this kind of problem. Any code that violates the defined types will throw a compile-time error, and the likes of VS Code will highlight these errors as soon as they enter the IDE.

Issue #129 already requests TypeScript for this library, and has the history and progress of this, so I will close this issue, and you can track #129 for the strong-typing solution.