fix(MESHCENT-004): CU-86akbhg5u 8 review findings across 6 files - #170
fix(MESHCENT-004): CU-86akbhg5u 8 review findings across 6 files#170flamingo[bot] wants to merge 6 commits into
Conversation
| /* jshint esversion: 6 */ | ||
| 'use strict'; | ||
|
|
||
| /** |
There was a problem hiding this comment.
🦩 🟠 mcrec.js missing jshint directives and 'use strict'
Added /* jshint node: true */, /* jshint esversion: 6 */, and 'use strict'; directives at the top of mcrec.js, before the existing JSDoc header comment, matching the convention described for meshaccelerator.js.
🤖 Prompt for AI agents
In mcrec.js around line 1, review and complete this code-review fix: mcrec.js missing jshint directives and 'use strict'.
What the draft fix changed: Added `/* jshint node: true */`, `/* jshint esversion: 6 */`, and `'use strict';` directives at the top of mcrec.js, before the existing JSDoc header comment, matching the convention described for meshaccelerator.js.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
| @@ -227,7 +231,6 @@ function readLastBlock(state, func) { | |||
| var magic = buf.toString('utf8', 16, 32); | |||
| if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX')) { | |||
There was a problem hiding this comment.
🦩 🟠 readLastBlock in mcrec.js references undefined variable extraMetadata
Removed the stray, unused extraMetadata = null; implicit-global assignment inside readLastBlock (in the if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX')) branch); the actual parsed metadata is still passed to func(...) via buf3 a few lines later, unaffected by this removal. Combined with the newly added 'use strict' from finding 1, any future reintroduction of an undeclared assignment like this would now throw instead of silently creating a global.
🤖 Prompt for AI agents
In mcrec.js around line 228, review and complete this code-review fix: readLastBlock in mcrec.js references undefined variable `extraMetadata`.
What the draft fix changed: Removed the stray, unused `extraMetadata = null;` implicit-global assignment inside `readLastBlock` (in the `if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX'))` branch); the actual parsed metadata is still passed to `func(...)` via `buf3` a few lines later, unaffected by this removal. Combined with the newly added `'use strict'` from finding 1, any future reintroduction of an undeclared assignment like this would now throw instead of silently creating a global.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
| limitations under the License. | ||
| */ | ||
|
|
||
| /*xjslint node: true */ |
There was a problem hiding this comment.
🦩 🟠 exeHandler.js jshint block includes non-standard /xjslint/ directives alongside jshint
Removed the three dead /*xjslint ...*/ comment lines at the top of exeHandler.js (lines 17-19), leaving only the active /*jshint node: true */, /*jshint strict: false */, and /*jshint esversion: 6 */ directives intact. This is a self-contained, mechanical deletion; the finding also notes the same typo exists in firebase.js and interceptor.js, but those files are out of scope for this fix.
🤖 Prompt for AI agents
In exeHandler.js around line 17, review and complete this code-review fix: exeHandler.js jshint block includes non-standard /*xjslint*/ directives alongside jshint.
What the draft fix changed: Removed the three dead `/*xjslint ...*/` comment lines at the top of `exeHandler.js` (lines 17-19), leaving only the active `/*jshint node: true */`, `/*jshint strict: false */`, and `/*jshint esversion: 6 */` directives intact. This is a self-contained, mechanical deletion; the finding also notes the same typo exists in `firebase.js` and `interceptor.js`, but those files are out of scope for this fix.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
| // Read the authenticode certificate, only one cert (only the first entry) | ||
| var hdr = Buffer.alloc(8); | ||
| fs.readSync(fd, hdr, 0, hdr.length, retVal.CertificateTableAddress); | ||
| retVal.certificate = Buffer.alloc(hdr.readUInt32LE(0)); | ||
| var certLength = hdr.readUInt32LE(0); | ||
| if (certLength > (128 * 1024 * 1024)) { // Sanity bound to guard against malformed/malicious length fields | ||
| fs.closeSync(fd); | ||
| throw ('certificate table length exceeds maximum allowed size'); | ||
| } | ||
| retVal.certificate = Buffer.alloc(certLength); | ||
| fs.readSync(fd, retVal.certificate, 0, retVal.certificate.length, retVal.CertificateTableAddress + hdr.length); | ||
| retVal.certificate = retVal.certificate.toString('base64'); | ||
| retVal.certificateDwLength = hdr.readUInt32LE(0); |
There was a problem hiding this comment.
🦩 🔵 exeHandler.js parseWindowsExecutable trusts embedded certificate length fields without bounds checking
In parseWindowsExecutable, added a bounds check on the certificate table length read from the untrusted PE header before allocating retVal.certificate: the value is now captured in certLength, checked against a sanity cap of 128MB, and an exception is thrown (after closing the file descriptor) if exceeded, before Buffer.alloc(certLength) is called. The 128MB threshold is a reasonable but somewhat arbitrary bound for legitimate authenticode certificates (which are normally tiny, KB-sized) — a reviewer may want a stricter limit (e.g. a few MB) or to derive the bound from the file size/remaining bytes instead of a fixed constant; this change prevents the most severe OOM/crash cases but the exact threshold is a judgment call.
🤖 Prompt for AI agents
In exeHandler.js around line 224, review and complete this code-review fix: exeHandler.js parseWindowsExecutable trusts embedded certificate length fields without bounds checking.
What the draft fix changed: In `parseWindowsExecutable`, added a bounds check on the certificate table length read from the untrusted PE header before allocating `retVal.certificate`: the value is now captured in `certLength`, checked against a sanity cap of 128MB, and an exception is thrown (after closing the file descriptor) if exceeded, before `Buffer.alloc(certLength)` is called. The 128MB threshold is a reasonable but somewhat arbitrary bound for legitimate authenticode certificates (which are normally tiny, KB-sized) — a reviewer may want a stricter limit (e.g. a few MB) or to derive the bound from the file size/remaining bytes instead of a fixed constant; this change prevents the most severe OOM/crash cases but the exact threshold is a judgment call.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 70 medium — react 👍/👎 to teach the reviewer
| @@ -1,155 +1,159 @@ | |||
| /** | |||
There was a problem hiding this comment.
🦩 🟠 mqttbroker.js server module missing jshint/strict-mode header
Added the standard /*jshint node: true */ and "use strict"; header lines at the very top of mqttbroker.js, before the existing JSDoc file comment block, matching the established convention used in other server modules (e.g. pass.js). No other code was altered.
🤖 Prompt for AI agents
In mqttbroker.js around line 1, review and complete this code-review fix: mqttbroker.js server module missing jshint/strict-mode header.
What the draft fix changed: Added the standard `/*jshint node: true */` and `"use strict";` header lines at the very top of mqttbroker.js, before the existing JSDoc file comment block, matching the established convention used in other server modules (e.g. pass.js). No other code was altered.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
| /*jshint esversion: 6 */ | ||
| "use strict"; | ||
|
|
||
| var fs = require('fs'); |
There was a problem hiding this comment.
🦩 🟠 agents/hashagents.js lacks jshint/strict-mode header conventions
Added the standard jshint directive block (/*jshint node: true */, /*jshint strict: false */, /*jshint esversion: 6 */) and a "use strict"; declaration at the top of agents/hashagents.js, before the existing var fs = require('fs'); line, matching the convention used in meshcentral.js and amt/amt-wsman.js. No other code was changed.
🤖 Prompt for AI agents
In agents/hashagents.js around line 1, review and complete this code-review fix: agents/hashagents.js lacks jshint/strict-mode header conventions.
What the draft fix changed: Added the standard jshint directive block (`/*jshint node: true */`, `/*jshint strict: false */`, `/*jshint esversion: 6 */`) and a `"use strict";` declaration at the top of agents/hashagents.js, before the existing `var fs = require('fs');` line, matching the convention used in meshcentral.js and amt/amt-wsman.js. No other code was changed.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
| * @version v0.0.1 | ||
| */ | ||
|
|
||
| /*xjslint node: true */ |
There was a problem hiding this comment.
🦩 🟠 meshmail.js uses xjslint hints instead of standard jshint node/strict directives layout
Removed the three legacy /*xjslint ... */ comment lines (node: true, plusplus: true, maxlen: 256) from the file header at the top of meshmail.js, leaving only the /*jshint node: true */, /*jshint strict: false */, /*jshint esversion: 6 */ directives immediately followed by "use strict";, matching the convention described (and used in sibling modules like multiserver.js). No other code was touched.
🤖 Prompt for AI agents
In meshmail.js around line 9, review and complete this code-review fix: meshmail.js uses xjslint hints instead of standard jshint node/strict directives layout.
What the draft fix changed: Removed the three legacy `/*xjslint ... */` comment lines (`node: true`, `plusplus: true`, `maxlen: 256`) from the file header at the top of meshmail.js, leaving only the `/*jshint node: true */`, `/*jshint strict: false */`, `/*jshint esversion: 6 */` directives immediately followed by `"use strict";`, matching the convention described (and used in sibling modules like multiserver.js). No other code was touched.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| * NOTE: This file is vendored third-party code from node-rdpjs and is | ||
| * licensed under the GNU General Public License v3 (GPLv3) as noted above, | ||
| * distinct from the Apache-2.0 license used by the rest of this project. | ||
| * See the project's licensing documentation for details on this | ||
| * third-party dependency and its license compatibility. | ||
| */ | ||
|
|
||
| var Levels = { |
There was a problem hiding this comment.
🦩 🟠 rdp/core/layer.js and rdp/core/log.js are third-party (node-rdpjs, GPLv3) and should not carry MeshCentral conventions but are bundled under rdp/ scope for MESHCENT-006 rule
Added a short note appended to the existing GPLv3 header comment block in rdp/core/log.js flagging that this file is vendored third-party code under GPLv3, distinct from the project's Apache-2.0 license, and pointing to project licensing docs for compatibility details. This is a documentation-only annotation; it does not resolve the underlying GPLv3/Apache-2.0 licensing-compatibility question, which requires a maintainer/legal decision (e.g., isolating the subtree, obtaining relicensing, or documenting an approved linking exception) that cannot be completed by a code edit in this single file.
🤖 Prompt for AI agents
In rdp/core/log.js around line 1, review and complete this code-review fix: rdp/core/layer.js and rdp/core/log.js are third-party (node-rdpjs, GPLv3) and should not carry MeshCentral conventions but are bundled under rdp/ scope for MESHCENT-006 rule.
What the draft fix changed: Added a short note appended to the existing GPLv3 header comment block in rdp/core/log.js flagging that this file is vendored third-party code under GPLv3, distinct from the project's Apache-2.0 license, and pointing to project licensing docs for compatibility details. This is a documentation-only annotation; it does not resolve the underlying GPLv3/Apache-2.0 licensing-compatibility question, which requires a maintainer/legal decision (e.g., isolating the subtree, obtaining relicensing, or documenting an approved linking exception) that cannot be completed by a code edit in this single file.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 25 low — review closely — react 👍/👎 to teach the reviewer
Closes 8 review findings across 6 files.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
mcrec.js:1extraMetadatamcrec.js:228exeHandler.js:17exeHandler.js:224mqttbroker.js:1agents/hashagents.js:1meshmail.js:9rdp/core/log.js:1What 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:
a271a374-6235-40d2-8fdd-b6d4de951f4bMerging 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.
ClickUp task: CU-86akbhg5u MeshCentral webauthn and plugin JS fixes (6 PRs)