net-snmp 3.18.2 → 3.19.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.
package/README.md CHANGED
@@ -3461,6 +3461,14 @@ Example programs are included under the module's `example` directory.
3461
3461
 
3462
3462
  * Add conversion of scalar defVal enumeration name to number on assignment
3463
3463
 
3464
+ ## Version 3.19.0 - 06/02/2025
3465
+
3466
+ * Remove deprecated isArray call and fix agent string constraints check
3467
+
3468
+ ## Version 3.19.1 - 03/03/2025
3469
+
3470
+ * Fix integer constraints check
3471
+
3464
3472
  # License
3465
3473
 
3466
3474
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/index.js CHANGED
@@ -672,7 +672,7 @@ ObjectTypeUtil.isValid = function (type, value, constraints) {
672
672
  if ( isNaN(parsedValue) || ! Number.isInteger(parsedValue) || parsedValue < MIN_SIGNED_INT32 || parsedValue > MAX_SIGNED_INT32 ) {
673
673
  return false;
674
674
  }
675
- if ( constraints && ObjectTypeUtil.doesIntegerMeetConstraints (parsedValue, constraints) ) {
675
+ if ( constraints && ! ObjectTypeUtil.doesIntegerMeetConstraints (parsedValue, constraints) ) {
676
676
  return false;
677
677
  }
678
678
  return true;
@@ -682,7 +682,7 @@ ObjectTypeUtil.isValid = function (type, value, constraints) {
682
682
  if ( typeof value != "string" && ! (value instanceof Buffer) ) {
683
683
  return false;
684
684
  }
685
- if ( constraints && ObjectTypeUtil.doesStringMeetConstraints (value, constraints) ) {
685
+ if ( constraints && ! ObjectTypeUtil.doesStringMeetConstraints (value, constraints) ) {
686
686
  return false;
687
687
  }
688
688
  return true;
@@ -4723,7 +4723,7 @@ Mib.convertOidToAddress = function (oid) {
4723
4723
  var oidArray;
4724
4724
  var i;
4725
4725
 
4726
- if (typeof (oid) === 'object' && util.isArray(oid)) {
4726
+ if (typeof (oid) === 'object' && Array.isArray(oid)) {
4727
4727
  address = oid;
4728
4728
  } else if (typeof (oid) === 'string') {
4729
4729
  address = oid.split('.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.18.2",
3
+ "version": "3.19.1",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -72,6 +72,17 @@ describe('Object Types', function() {
72
72
  assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 2147483648), false);
73
73
  });
74
74
  });
75
+ // Tests for constraints
76
+ describe('An integer at the bottom of the valid range is a valid Integer type', function() {
77
+ it('returns true', function() {
78
+ assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 0, { ranges: [{ min: 0, max: 10 }] }), true);
79
+ });
80
+ });
81
+ describe('An integer outside the valid range is not an valid Integer type', function() {
82
+ it('returns false', function() {
83
+ assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.Integer, 11, { ranges: [{ min: 0, max: 10 }] }), false);
84
+ });
85
+ });
75
86
  });
76
87
 
77
88
  describe('isValid() - OctetString', function() {
@@ -85,6 +96,22 @@ describe('Object Types', function() {
85
96
  assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, Buffer.from('1.3.6.1.2.3.4.5')), true);
86
97
  });
87
98
  });
99
+ describe('A string with a length of 6 is valid for a size range of 2 - 7', function() {
100
+ it('returns true', function() {
101
+ const sizes = [
102
+ { min: 2, max: 7 },
103
+ ];
104
+ assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'sixlet', { sizes }), true);
105
+ });
106
+ });
107
+ describe('A string with a length of 6 is not valid for a size range of 2 - 5', function() {
108
+ it('returns true', function() {
109
+ const sizes = [
110
+ { min: 2, max: 5 },
111
+ ];
112
+ assert.equal(snmp.ObjectTypeUtil.isValid(snmp.ObjectType.OctetString, 'sixlet', { sizes }), false);
113
+ });
114
+ });
88
115
  });
89
116
 
90
117
  describe('isValid() - OID', function() {