net-snmp 3.28.1 → 3.29.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 +28 -1
  2. package/index.js +42 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -157,6 +157,18 @@ constants are defined in this object:
157
157
  * `NotWritable`
158
158
  * `InconsistentName`
159
159
 
160
+ Only the first six of these - `NoError` through `GeneralError` - are defined by
161
+ SNMPv1. The agent produces error statuses using the full SNMPv2 set regardless
162
+ of the version of the request, then translates them when responding to an
163
+ SNMPv1 request, using the mapping given in RFC 2089 section 2.1 (repeated in
164
+ RFC 3584 section 4.4). So an SNMPv1 manager sees `NoSuchName` where an SNMPv2c
165
+ or SNMPv3 manager would see `NoAccess`, `NoCreation`, `NotWritable`,
166
+ `InconsistentName` or `AuthorizationError`; `BadValue` in place of `WrongType`,
167
+ `WrongLength`, `WrongEncoding`, `WrongValue` or `InconsistentValue`; and
168
+ `GeneralError` in place of `ResourceUnavailable`, `CommitFailed` or
169
+ `UndoFailed`. `ReadOnly` is listed for completeness, since SNMPv1 defines it,
170
+ but no conformant agent generates it - see RFC 1908 section 3.1.2.
171
+
160
172
  ## snmp.ObjectType
161
173
 
162
174
  This object contains constants used to specify syntax for varbind objects,
@@ -2171,7 +2183,12 @@ level provided by this provider. The allowable values are the
2171
2183
  numeric values from the MaxAccess export. If a `maxAccess` value is
2172
2184
  specified, a `get` request to the agent will return a `noAccess`
2173
2185
  error if `maxAccess` is not at least "read-only" (2). `maxAccess`
2174
- must be at least "read-write" (3) for a `set` request to succeed.
2186
+ must be at least "read-write" (3) for a `set` request to succeed;
2187
+ a `set` below that level returns a `notWritable` error, which is the
2188
+ code RFC 3416 section 4.2.5 reserves for a variable that exists but
2189
+ cannot be modified whatever value is supplied. Note that `noAccess`
2190
+ there means something narrower - a variable denied because it is not
2191
+ in the requester's MIB view.
2175
2192
  * `defVal` *(optional)* - the default value to assign for scalar
2176
2193
  objects automatically created, when `maxAccess` is set to
2177
2194
  "read-create" (4). Note that table columns can specify such `defVal`
@@ -3785,6 +3802,16 @@ Example programs are included under the module's `example` directory.
3785
3802
 
3786
3803
  * Decode index parts declared with a fixed `length` without consuming a leading length component, matching the way they are encoded - an index value of `AB` in such a column previously read back as `B`
3787
3804
 
3805
+ # Version 3.29.0 - 13/09/2026
3806
+
3807
+ * Answer a SetRequest for an object whose `maxAccess` is below "read-write" with a `notWritable` error instead of `noAccess`, for both the agent and the AgentX subagent - RFC 3416 section 4.2.5 reserves `noAccess` for a variable denied because it is not in the requester's MIB view, and gives `notWritable` for one that exists but cannot be modified whatever value is supplied
3808
+
3809
+ * Translate error statuses to their SNMPv1 equivalents when the agent responds to a version 1 request, using the mapping in RFC 2089 section 2.1 - the agent produces statuses from the SNMPv2 set whatever version it is answering, and previously sent codes such as `noAccess` and `notWritable` to SNMPv1 managers unchanged, even though SNMPv1 defines no such values. A SetRequest for a read-only object now returns `noSuchName` to an SNMPv1 manager
3810
+
3811
+ # Version 3.29.1 - 13/09/2026
3812
+
3813
+ * Upgrade the Mocha test framework to version 12, clearing the outstanding `serialize-javascript` and `diff` security advisories from the dependency tree - both were development-only transitive dependencies of the test toolchain and were never part of the published package, so no user of the library was exposed. Running the test suite now requires Node.js `^20.19.0 || >=22.12.0`; the library itself is unaffected
3814
+
3788
3815
  # License
3789
3816
 
3790
3817
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/index.js CHANGED
@@ -71,6 +71,27 @@ var ErrorStatus = {
71
71
 
72
72
  _expandConstantObject (ErrorStatus);
73
73
 
74
+ // SNMPv2 introduced error-status values that carry no meaning for an SNMPv1
75
+ // manager, whose ErrorStatus ASN.1 stops at genErr(5). A multi-lingual agent
76
+ // must therefore translate before responding to a version 1 request. Table
77
+ // from RFC 2089 section 2.1, repeated in RFC 3584 section 4.4. Values absent
78
+ // from this table - noError, tooBig, noSuchName, badValue, readOnly and
79
+ // genErr - are already valid in SNMPv1 and pass through untouched.
80
+ var ErrorStatusV2ToV1 = {};
81
+ ErrorStatusV2ToV1[ErrorStatus.NoAccess] = ErrorStatus.NoSuchName;
82
+ ErrorStatusV2ToV1[ErrorStatus.WrongType] = ErrorStatus.BadValue;
83
+ ErrorStatusV2ToV1[ErrorStatus.WrongLength] = ErrorStatus.BadValue;
84
+ ErrorStatusV2ToV1[ErrorStatus.WrongEncoding] = ErrorStatus.BadValue;
85
+ ErrorStatusV2ToV1[ErrorStatus.WrongValue] = ErrorStatus.BadValue;
86
+ ErrorStatusV2ToV1[ErrorStatus.NoCreation] = ErrorStatus.NoSuchName;
87
+ ErrorStatusV2ToV1[ErrorStatus.InconsistentValue] = ErrorStatus.BadValue;
88
+ ErrorStatusV2ToV1[ErrorStatus.ResourceUnavailable] = ErrorStatus.GeneralError;
89
+ ErrorStatusV2ToV1[ErrorStatus.CommitFailed] = ErrorStatus.GeneralError;
90
+ ErrorStatusV2ToV1[ErrorStatus.UndoFailed] = ErrorStatus.GeneralError;
91
+ ErrorStatusV2ToV1[ErrorStatus.AuthorizationError] = ErrorStatus.NoSuchName;
92
+ ErrorStatusV2ToV1[ErrorStatus.NotWritable] = ErrorStatus.NoSuchName;
93
+ ErrorStatusV2ToV1[ErrorStatus.InconsistentName] = ErrorStatus.NoSuchName;
94
+
74
95
  var ObjectType = {
75
96
  1: "Boolean",
76
97
  2: "Integer",
@@ -5508,14 +5529,19 @@ Agent.prototype.request = function (socket, requestMessage, rinfo) {
5508
5529
  });
5509
5530
  };
5510
5531
  } else if ( ! this.isAllowed(requestPdu.type, providerNode.provider, instanceNode ) ) {
5511
- // requested access not allowed (by MAX-ACCESS)
5532
+ // Requested access not allowed (by MAX-ACCESS). RFC 3416 section
5533
+ // 4.2.5 reserves noAccess for a variable denied because it is not
5534
+ // in the appropriate MIB view (rule 1); a variable that exists but
5535
+ // can not be modified no matter what value is supplied is
5536
+ // notWritable (rule 2). MAX-ACCESS below read-write is the latter.
5537
+ const accessErrorStatus = isSetRequest ? ErrorStatus.NotWritable : ErrorStatus.NoAccess;
5512
5538
  mibRequests[i] = new MibRequest ({
5513
5539
  operation: requestPdu.type,
5514
5540
  oid: requestPdu.varbinds[i].oid
5515
5541
  });
5516
5542
  mibRequests[i].handler = function getRanaHandler (mibRequestForRana) {
5517
5543
  mibRequestForRana.done ({
5518
- errorStatus: ErrorStatus.NoAccess,
5544
+ errorStatus: accessErrorStatus,
5519
5545
  type: ObjectType.Null,
5520
5546
  value: null
5521
5547
  });
@@ -5920,6 +5946,16 @@ Agent.prototype.setSingleVarbind = function (responsePdu, index, responseVarbind
5920
5946
  };
5921
5947
 
5922
5948
  Agent.prototype.sendResponse = function (socket, rinfo, requestMessage, responsePdu) {
5949
+ // The agent is multi-lingual: it answers each request in the version that
5950
+ // request arrived with. Error statuses are produced internally using the
5951
+ // SNMPv2 set, so a response to a version 1 request must be translated down
5952
+ // to something an SNMPv1 manager understands - RFC 2089 section 2.1.
5953
+ if ( requestMessage.version == Version1 ) {
5954
+ const version1ErrorStatus = ErrorStatusV2ToV1[responsePdu.errorStatus];
5955
+ if ( version1ErrorStatus !== undefined ) {
5956
+ responsePdu.errorStatus = version1ErrorStatus;
5957
+ }
5958
+ }
5923
5959
  var responseMessage = requestMessage.createResponseForRequest (responsePdu);
5924
5960
  this.listener.send (responseMessage, rinfo, socket);
5925
5961
  this.callback (null, Listener.formatCallbackData (responseMessage.pdu, rinfo) );
@@ -6749,8 +6785,11 @@ Subagent.prototype.request = function (pdu, requestVarbinds) {
6749
6785
  });
6750
6786
  mibRequests[i].handler = providerNode.provider.handler;
6751
6787
  if ( ! me.isAllowed(pdu.pduType, mibRequests[i].providerNode?.provider, mibRequests[i].instanceNode) ) {
6788
+ // A set below read-write MAX-ACCESS is notWritable, not
6789
+ // noAccess - RFC 3416 section 4.2.5 rule 2, and RFC 2741
6790
+ // section 7.2.1.4 for the AgentX TestSet phase.
6752
6791
  mibRequests[i].error = {
6753
- errorStatus: ErrorStatus.NoAccess,
6792
+ errorStatus: isSetRequest ? ErrorStatus.NotWritable : ErrorStatus.NoAccess,
6754
6793
  errorIndex: i + 1,
6755
6794
  type: ObjectType.Null,
6756
6795
  value: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.28.1",
3
+ "version": "3.29.1",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "author": "Mark Abrahams <mark@abrahams.co.nz>",
6
6
  "license": "MIT",
@@ -58,6 +58,6 @@
58
58
  "devDependencies": {
59
59
  "eslint": "^9.9.1",
60
60
  "getopts": "^2.3.0",
61
- "mocha": "^11.0.1"
61
+ "mocha": "^12.0.1"
62
62
  }
63
63
  }