net-snmp 3.5.7 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +18 -6
  2. package/index.js +68 -49
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -243,8 +243,8 @@ This object contains constants to select a supported encryption algorithm for
243
243
  SNMPv3 messages that require privacy:
244
244
  * `des` - for DES encryption (CBC-DES)
245
245
  * `aes` - for 128-bit AES encryption (CFB-AES-128)
246
- * `aes256b` - for 256-bit AES encryption (CFB-AES-256) with "Blumenthal" key localiztaion
247
- * `aes256r` - for 256-bit AES encryption (CFB-AES-256) with "Reeder" key localiztaion
246
+ * `aes256b` - for 256-bit AES encryption (CFB-AES-256) with "Blumenthal" key localization
247
+ * `aes256r` - for 256-bit AES encryption (CFB-AES-256) with "Reeder" key localization
248
248
 
249
249
  DES is the sole encryption algorithm specified in the original SNMPv3 User-Based
250
250
  Security Model RFC (RFC 3414); 128-bit AES for SNMPv3 was added later in RFC 3826.
@@ -1062,7 +1062,7 @@ The `table()` method fetches the value for all OIDs lexicographically
1062
1062
  following a specified OID in the MIB tree which have the specified OID as
1063
1063
  their base, much like the `subtree()` method.
1064
1064
 
1065
- This method is designed to fetch conceptial tables, for example the ifTable
1065
+ This method is designed to fetch conceptual tables, for example the ifTable
1066
1066
  (`1.3.6.1.2.1.2.2`) table. The values for returned varbinds will be structured
1067
1067
  into objects to represent conceptual rows. Each row is then placed into an
1068
1068
  object with the rows index being the key, e.g.:
@@ -1171,7 +1171,7 @@ be in the resulting table.
1171
1171
 
1172
1172
  This method should be used when only selected columns are required, and
1173
1173
  will be many times faster than the `table()` method since a much smaller
1174
- amount of data will be fected.
1174
+ amount of data will be fetched.
1175
1175
 
1176
1176
  The following example fetches the ifTable (`1.3.6.1.2.1.2.2`) table, and
1177
1177
  specifies that only the ifDescr (`1.3.6.1.2.1.2.2.1.2`) and ifPhysAddress
@@ -1259,7 +1259,7 @@ returned by the `process.uptime ()` function multiplied by `100`.
1259
1259
  SNMP version 2c messages are quite different in comparison with version 1.
1260
1260
  The version 2c trap has a much simpler format, simply a sequence of varbinds.
1261
1261
  The first varbind to be placed in the trap message will be for the
1262
- `sysUptime.0` OID (`1.3.6.1.6.3.1.1.4.1.0`). The value for this varbind will
1262
+ `sysUptime.0` OID (`1.3.6.1.2.1.1.3.0`). The value for this varbind will
1263
1263
  be the value returned by the `process.uptime ()` function multiplied by 100
1264
1264
  (this can be overridden by providing `upTime` in the optional `options`
1265
1265
  parameter, as documented below).
@@ -1280,7 +1280,7 @@ following items:
1280
1280
 
1281
1281
  * `agentAddr` - IP address used to populate the agent-addr field for SNMP
1282
1282
  version 1 type traps, and defaults to `127.0.0.1`
1283
- * `upTime` - Value of the `sysUptime.0` OID (`1.3.6.1.6.3.1.1.4.1.0`) in the
1283
+ * `upTime` - Value of the `sysUptime.0` OID (`1.3.6.1.2.1.1.3.0`) in the
1284
1284
  trap, defaults to the value returned by the `process.uptime ()` function
1285
1285
  multiplied by 100
1286
1286
 
@@ -3162,6 +3162,18 @@ Example programs are included under the module's `example` directory.
3162
3162
 
3163
3163
  * Fix handing of null varbinds in walk
3164
3164
 
3165
+ ## Version 3.5.8 - 24/11/2021
3166
+
3167
+ * Fix processing of negative integers larger than 32 bits
3168
+
3169
+ ## Version 3.6.0 - 18/02/2022
3170
+
3171
+ * Add calculated key cache to remove authNoPriv and authPriv performance bottleneck
3172
+
3173
+ ## Version 3.6.1 - 21/03/2022
3174
+
3175
+ * Add v3 context to non-initial PDUs
3176
+
3165
3177
  # License
3166
3178
 
3167
3179
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/index.js CHANGED
@@ -428,13 +428,15 @@ function readUint (buffer, isSigned) {
428
428
  value += buffer.readByte ();
429
429
 
430
430
  if (isSigned && i <= 0) {
431
- if ((value & 0x80) == 0x80)
431
+ if ((value & 0x80) == 0x80) {
432
432
  signedBitSet = true;
433
+ }
433
434
  }
434
435
  }
435
436
 
436
- if (signedBitSet)
437
- value -= (1 << (i * 8));
437
+ if (signedBitSet) {
438
+ value -= 2 ** (i * 8);
439
+ }
438
440
 
439
441
  return value;
440
442
  }
@@ -932,17 +934,32 @@ Authentication.algorithms[AuthProtocols.sha] = {
932
934
  CRYPTO_ALGORITHM: 'sha1'
933
935
  };
934
936
 
937
+ Authentication.authToKeyCache = {};
938
+
939
+ Authentication.computeCacheKey = function (authProtocol, authPasswordString, engineID) {
940
+ var engineIDString = engineID.toString('base64');
941
+ return authProtocol + authPasswordString + engineIDString;
942
+ };
943
+
935
944
  // Adapted from RFC3414 Appendix A.2.1. Password to Key Sample Code for MD5
936
945
  Authentication.passwordToKey = function (authProtocol, authPasswordString, engineID) {
937
946
  var hashAlgorithm;
938
947
  var firstDigest;
939
948
  var finalDigest;
940
- var buf = Buffer.alloc (Authentication.HMAC_BUFFER_SIZE);
949
+ var buf;
941
950
  var bufOffset = 0;
942
951
  var passwordIndex = 0;
943
952
  var count = 0;
944
- var password = Buffer.from (authPasswordString);
953
+ var password;
945
954
  var cryptoAlgorithm = Authentication.algorithms[authProtocol].CRYPTO_ALGORITHM;
955
+
956
+ var cacheKey = Authentication.computeCacheKey(authProtocol, authPasswordString, engineID);
957
+ if (Authentication.authToKeyCache[cacheKey] !== undefined) {
958
+ return Authentication.authToKeyCache[cacheKey];
959
+ }
960
+
961
+ buf = Buffer.alloc (Authentication.HMAC_BUFFER_SIZE);
962
+ password = Buffer.from (authPasswordString);
946
963
 
947
964
  while (count < Authentication.HMAC_BUFFER_SIZE) {
948
965
  for (var i = 0; i < Authentication.HMAC_BLOCK_SIZE; i++) {
@@ -962,6 +979,7 @@ Authentication.passwordToKey = function (authProtocol, authPasswordString, engin
962
979
  finalDigest = hashAlgorithm.digest();
963
980
  // debug ("Localized key: " + finalDigest.toString('hex'));
964
981
 
982
+ Authentication.authToKeyCache[cacheKey] = finalDigest;
965
983
  return finalDigest;
966
984
  };
967
985
 
@@ -2320,6 +2338,7 @@ Session.prototype.set = function (varbinds, responseCb) {
2320
2338
  Session.prototype.simpleGet = function (pduClass, feedCb, varbinds,
2321
2339
  responseCb, options) {
2322
2340
  var id = _generateId (this.idBitsSize);
2341
+ options = Object.assign({}, options, { context: this.context });
2323
2342
  var pdu = SimplePdu.createFromVariables (pduClass, id, varbinds, options);
2324
2343
  var message;
2325
2344
  var req;
@@ -3544,11 +3563,11 @@ MibNode.prototype.getConstraintsFromProvider = function () {
3544
3563
  };
3545
3564
 
3546
3565
  MibNode.prototype.setValue = function (newValue) {
3547
- var len;
3548
- var min;
3549
- var max;
3550
- var range;
3551
- var found = false;
3566
+ var len;
3567
+ var min;
3568
+ var max;
3569
+ var range;
3570
+ var found = false;
3552
3571
  var constraints = this.getConstraintsFromProvider ();
3553
3572
  if ( ! constraints ) {
3554
3573
  this.value = newValue;
@@ -3559,35 +3578,35 @@ MibNode.prototype.setValue = function (newValue) {
3559
3578
  return false;
3560
3579
  }
3561
3580
  } else if ( constraints.ranges ) {
3562
- for ( range of constraints.ranges ) {
3563
- min = "min" in range ? range.min : Number.MIN_SAFE_INTEGER;
3564
- max = "max" in range ? range.max : Number.MAX_SAFE_INTEGER;
3565
- if ( newValue >= min && newValue <= max ) {
3566
- found = true;
3567
- break;
3568
- }
3569
- }
3570
- if ( ! found ) {
3571
- return false;
3572
- }
3573
- } else if ( constraints.sizes ) {
3574
- // if size is constrained, value must have a length property
3575
- if ( ! ( "length" in newValue ) ) {
3576
- return false;
3577
- }
3578
- len = newValue.length;
3579
- for ( range of constraints.sizes ) {
3580
- min = "min" in range ? range.min : Number.MIN_SAFE_INTEGER;
3581
- max = "max" in range ? range.max : Number.MAX_SAFE_INTEGER;
3582
- if ( len >= min && len <= max ) {
3583
- found = true;
3584
- break;
3585
- }
3586
- }
3587
- if ( ! found ) {
3588
- return false;
3589
- }
3590
- }
3581
+ for ( range of constraints.ranges ) {
3582
+ min = "min" in range ? range.min : Number.MIN_SAFE_INTEGER;
3583
+ max = "max" in range ? range.max : Number.MAX_SAFE_INTEGER;
3584
+ if ( newValue >= min && newValue <= max ) {
3585
+ found = true;
3586
+ break;
3587
+ }
3588
+ }
3589
+ if ( ! found ) {
3590
+ return false;
3591
+ }
3592
+ } else if ( constraints.sizes ) {
3593
+ // if size is constrained, value must have a length property
3594
+ if ( ! ( "length" in newValue ) ) {
3595
+ return false;
3596
+ }
3597
+ len = newValue.length;
3598
+ for ( range of constraints.sizes ) {
3599
+ min = "min" in range ? range.min : Number.MIN_SAFE_INTEGER;
3600
+ max = "max" in range ? range.max : Number.MAX_SAFE_INTEGER;
3601
+ if ( len >= min && len <= max ) {
3602
+ found = true;
3603
+ break;
3604
+ }
3605
+ }
3606
+ if ( ! found ) {
3607
+ return false;
3608
+ }
3609
+ }
3591
3610
  this.value = newValue;
3592
3611
  return true;
3593
3612
  };
@@ -3975,25 +3994,25 @@ Mib.prototype.setTableRowDefaultValues = function (name, values) {
3975
3994
  };
3976
3995
 
3977
3996
  Mib.prototype.setScalarRanges = function (name, ranges ) {
3978
- let provider = this.getProvider(name);
3979
- provider.constraints = { ranges };
3997
+ let provider = this.getProvider(name);
3998
+ provider.constraints = { ranges };
3980
3999
  };
3981
4000
 
3982
4001
  Mib.prototype.setTableColumnRanges = function(name, column, ranges ) {
3983
- let provider = this.getProvider(name);
3984
- let tc = provider.tableColumns;
3985
- tc[column].constraints = { ranges };
4002
+ let provider = this.getProvider(name);
4003
+ let tc = provider.tableColumns;
4004
+ tc[column].constraints = { ranges };
3986
4005
  };
3987
4006
 
3988
4007
  Mib.prototype.setScalarSizes = function (name, sizes ) {
3989
- let provider = this.getProvider(name);
3990
- provider.constraints = { sizes };
4008
+ let provider = this.getProvider(name);
4009
+ provider.constraints = { sizes };
3991
4010
  };
3992
4011
 
3993
4012
  Mib.prototype.setTableColumnSizes = function(name, column, sizes ) {
3994
- let provider = this.getProvider(name);
3995
- let tc = provider.tableColumns;
3996
- tc[column].constraints = { sizes };
4013
+ let provider = this.getProvider(name);
4014
+ let tc = provider.tableColumns;
4015
+ tc[column].constraints = { sizes };
3997
4016
  };
3998
4017
 
3999
4018
  Mib.prototype.registerProviders = function (providers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.5.7",
3
+ "version": "3.6.1",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {