fix(MESHCENT-004-2): 3 review findings in amt_heci.js - #92
Conversation
| @@ -262,32 +262,32 @@ function amt_heci() { | |||
| fn.apply(this, opt); | |||
| }, callback, optional); | |||
| } | |||
There was a problem hiding this comment.
🦩 🔴 getProtocolVersion uses undefined 'opt' instead of 'optional' when building the optional args array
In getProtocolVersion, changed opt.push(arguments[i]) to optional.push(arguments[i]) in the argument-collection loop, matching the declared var optional = [] and mirroring the pattern used by every other method in the file.
🤖 Prompt for AI agents
In modules/amt_heci.js around line 264, review and complete this code-review fix: getProtocolVersion uses undefined 'opt' instead of 'optional' when building the optional args array.
What the draft fix changed: In getProtocolVersion, changed `opt.push(arguments[i])` to `optional.push(arguments[i])` in the argument-collection loop, matching the declared `var optional = []` and mirroring the pattern used by every other method in the file.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
| fn.apply(this, opt); | ||
| }, callback, optional); | ||
| } | ||
| this.startConfiguration = function () { | ||
| this.startConfiguration = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x29, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x29, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.stopConfiguration = function () { | ||
| this.stopConfiguration = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x5E, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x5E, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.openUserInitiatedConnection = function () { | ||
| this.openUserInitiatedConnection = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x44, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x44, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.closeUserInitiatedConnection = function () { | ||
| this.closeUserInitiatedConnection = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x45, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x45, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.getRemoteAccessConnectionStatus = function () { | ||
| this.getRemoteAccessConnectionStatus = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x46, data, function (header, fn, opt) { | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x46, null, function (header, fn, opt) { | ||
| if (header.Status == 0) { | ||
| var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString() | ||
| var hostname = header.Data.slice(14, header.Data.readUInt16LE(12) + 14).toString() | ||
| opt.unshift({ status: header.Status, networkStatus: header.Data.readUInt32LE(0), remoteAccessStatus: header.Data.readUInt32LE(4), remoteAccessTrigger: header.Data.readUInt32LE(8), mpsHostname: hostname, raw: header.Data }); | ||
| } else { | ||
| opt.unshift({ status: header.Status }); |
There was a problem hiding this comment.
🦩 🔴 amt_heci.js sendCommand references undefined 'callback' variable via unshifted arguments, and multiple call sites reference undefined 'data'
Fixed startConfiguration, stopConfiguration, openUserInitiatedConnection, closeUserInitiatedConnection, and getRemoteAccessConnectionStatus: each now declares callback as its named parameter (function signature changed from function () to function (callback)), the optional-args loop starts at index 1 instead of 2 (consistent with callback now being argument 0), and the undefined data variable passed to sendCommand was replaced with null since none of these commands send a request payload in the original code. This resolves the ReferenceErrors on data and callback in all five methods.
(Automatically downgraded: no change in this fix lands near this finding's line — verify whether it was actually addressed.)
🤖 Prompt for AI agents
In modules/amt_heci.js around line 233, review and complete this code-review fix: amt_heci.js sendCommand references undefined 'callback' variable via unshifted arguments, and multiple call sites reference undefined 'data'.
What the draft fix changed: Fixed startConfiguration, stopConfiguration, openUserInitiatedConnection, closeUserInitiatedConnection, and getRemoteAccessConnectionStatus: each now declares `callback` as its named parameter (function signature changed from `function ()` to `function (callback)`), the optional-args loop starts at index 1 instead of 2 (consistent with callback now being argument 0), and the undefined `data` variable passed to `sendCommand` was replaced with `null` since none of these commands send a request payload in the original code. This resolves the ReferenceErrors on `data` and `callback` in all five methods.
_(Automatically downgraded: no change in this fix lands near this finding's line — verify whether it was actually addressed.)_
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 40 low — review closely — react 👍/👎 to teach the reviewer
| fn.apply(this, opt); | ||
| }, callback, optional); | ||
| } | ||
| this.startConfiguration = function () { | ||
| this.startConfiguration = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x29, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x29, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.stopConfiguration = function () { | ||
| this.stopConfiguration = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x5E, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x5E, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.openUserInitiatedConnection = function () { | ||
| this.openUserInitiatedConnection = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x44, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x44, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.closeUserInitiatedConnection = function () { | ||
| this.closeUserInitiatedConnection = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x45, data, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x45, null, function (header, fn, opt) { opt.unshift(header.Status); fn.apply(this, opt); }, callback, optional); | ||
| } | ||
| this.getRemoteAccessConnectionStatus = function () { | ||
| this.getRemoteAccessConnectionStatus = function (callback) { | ||
| var optional = []; | ||
| for (var i = 2; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x46, data, function (header, fn, opt) { | ||
| for (var i = 1; i < arguments.length; ++i) { optional.push(arguments[i]); } | ||
| this.sendCommand(0x46, null, function (header, fn, opt) { | ||
| if (header.Status == 0) { | ||
| var hostname = v.slice(14, header.Data.readUInt16LE(12) + 14).toString() | ||
| var hostname = header.Data.slice(14, header.Data.readUInt16LE(12) + 14).toString() | ||
| opt.unshift({ status: header.Status, networkStatus: header.Data.readUInt32LE(0), remoteAccessStatus: header.Data.readUInt32LE(4), remoteAccessTrigger: header.Data.readUInt32LE(8), mpsHostname: hostname, raw: header.Data }); | ||
| } else { | ||
| opt.unshift({ status: header.Status }); |
There was a problem hiding this comment.
🦩 🔴 getRemoteAccessConnectionStatus references undefined variable 'v' when parsing hostname
In getRemoteAccessConnectionStatus's sendCommand callback, replaced the undefined v.slice(...) with header.Data.slice(...), since header.Data is the buffer actually available in that closure (there is no analog to getVersion's local v here) and the surrounding code already reads offsets 0/4/8/12 from header.Data, making it the correct source buffer for the hostname bytes at offset 14.
🤖 Prompt for AI agents
In modules/amt_heci.js around line 251, review and complete this code-review fix: getRemoteAccessConnectionStatus references undefined variable 'v' when parsing hostname.
What the draft fix changed: In getRemoteAccessConnectionStatus's sendCommand callback, replaced the undefined `v.slice(...)` with `header.Data.slice(...)`, since `header.Data` is the buffer actually available in that closure (there is no analog to getVersion's local `v` here) and the surrounding code already reads offsets 0/4/8/12 from `header.Data`, making it the correct source buffer for the hostname bytes at offset 14.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
Closes 3 review findings in
modules/amt_heci.js.Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
modules/amt_heci.js:264modules/amt_heci.js:233modules/amt_heci.js:251What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
36292efa-450d-4316-bb92-99897b2455bdMerging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.