From d53ba18d647638f90fced97256003d36844172cd Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:53 +0000
Subject: [PATCH 01/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
pkcs7-modified.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pkcs7-modified.js b/pkcs7-modified.js
index 661904a6bb..5f36b2248d 100644
--- a/pkcs7-modified.js
+++ b/pkcs7-modified.js
@@ -27,7 +27,7 @@ try {
require('../node-forge/lib/pkcs7asn1');
require('../node-forge/lib/random');
require('../node-forge/lib/util');
- require('../node-forge/lib/x509'); f
+ require('../node-forge/lib/x509');
} catch (ex) { }
if (forge == null) {
@@ -1277,3 +1277,4 @@ function _decryptContent(msg) {
msg.content = ciph.output;
}
}
+
From 1d4ec6d7493cdc72459c1f472e7338177316ac02 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:54 +0000
Subject: [PATCH 02/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
agents/modules_meshcmd/amt-scanner.js | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/agents/modules_meshcmd/amt-scanner.js b/agents/modules_meshcmd/amt-scanner.js
index 7b7339655c..ed4a6075ae 100644
--- a/agents/modules_meshcmd/amt-scanner.js
+++ b/agents/modules_meshcmd/amt-scanner.js
@@ -64,7 +64,9 @@ function AMTScanner() {
if (masknum <= 16 || masknum > 32) return null;
masknum = 32 - masknum;
for (var i = 0; i < masknum; i++) { mask = (mask << 1); mask++; }
- return { min: (ip & (0xFFFFFFFF - mask))+1, max: (ip & (0xFFFFFFFF - mask)) + mask -1 };//remove network and broadcast address to avoid irrecoverable socket error
+ var netmin = (ip & (0xFFFFFFFF - mask)), netmax = (ip & (0xFFFFFFFF - mask)) + mask;
+ if (netmin < netmax) { netmin++; netmax--; } // remove network and broadcast address to avoid irrecoverable socket error, unless range is too small
+ return { min: netmin, max: netmax };
}
x = this.parseIpv4Addr(range);
if (x == null) return null;
@@ -89,7 +91,15 @@ function AMTScanner() {
var server = this.dgram.createSocket({ type: 'udp4' });
server.parent = this;
server.scanResults = [];
- server.on('error', function (err) { console.log('Error:' + err); });
+ server.on('error', function (err) {
+ console.log('Error:' + err);
+ clearTimeout(tmout);
+ try { server.close(); } catch (e) { }
+ if (callback) {
+ callback(server.scanResults);
+ }
+ server.parent.emit('found', server.scanResults);
+ });
server.on('message', function (msg, rinfo) { if (rinfo.size > 4) { this.parent.parseRmcpPacket(this, msg, rinfo, function (s, res) { s.scanResults.push(res); }) }; });
server.on('listening', function () { for (var i = iprange.min; i <= iprange.max; i++) {
server.send(rmcp, 623, server.parent.IPv4NumToStr(i)); } });
@@ -101,7 +111,7 @@ function AMTScanner() {
callback(server.scanResults);
}
server.parent.emit('found', server.scanResults);
- delete server;
+ server = null;
}, timeout);
};
}
From feba40d639de42924ecfc95860f88b7467772784 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:55 +0000
Subject: [PATCH 03/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
plugins/openframe.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/plugins/openframe.js b/plugins/openframe.js
index 6a3a1a4b7b..b8570814d2 100644
--- a/plugins/openframe.js
+++ b/plugins/openframe.js
@@ -6,6 +6,12 @@ const path = require('path');
const MESH_DIR = process.env.MESH_DIR || '/opt/mesh';
const MESH_DEVICE_GROUP = process.env.MESH_DEVICE_GROUP || '';
+// Hostname/IPv4 validation for the /generate-msh `host` parameter: restricts to a safe
+// charset and structure (labels separated by dots, optional :port) to prevent SSRF-style
+// redirection and config injection (e.g. via newlines/control characters) into the
+// generated .msh file. Does not attempt DNS-based allowlisting of specific servers.
+const HOST_PATTERN = /^[A-Za-z0-9]([A-Za-z0-9-]{0,62})?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,62})?)*(:[0-9]{1,5})?$/;
+
// --- Helpers ---
function corsHeaders(res) {
@@ -74,6 +80,15 @@ module.exports.openframe = function (pluginHandler) {
var protocol = host.startsWith('http://') ? 'ws' : 'wss';
var cleanHost = host.replace(/^https?:\/\//, '').replace(/^wss?:\/\//, '');
+
+ // Validate the cleaned host against a strict allowlist pattern before it is embedded
+ // into the generated agent config. Rejects control characters, newlines, and any
+ // value that isn't a plain hostname/IPv4 with an optional port, preventing both
+ // agent-redirection (SSRF-like) and MSH config injection via crafted `host` values.
+ if (!HOST_PATTERN.test(cleanHost)) {
+ return sendError(res, 400, 'Invalid host parameter');
+ }
+
var meshServerUrl = protocol + '://' + cleanHost + '/ws/tools/agent/meshcentral-server/agent.ashx';
var mshContent = [
@@ -113,6 +128,7 @@ module.exports.openframe = function (pluginHandler) {
// 1. Verify device exists in DB
db.Get(nodeId, function (err, docs) {
+ if (err) log('db.Get error for ' + nodeId + ': ' + err);
if (docs == null || docs.length !== 1) return sendError(res, 404, 'Device not found');
// 2. Live connectivity state from MeshCentral in-memory store
@@ -121,6 +137,7 @@ module.exports.openframe = function (pluginHandler) {
// 3. Last connection record from DB
db.Get('lc' + nodeId, function (err, docs) {
+ if (err) log('db.Get error for lc' + nodeId + ': ' + err);
var lc = (docs != null && docs.length === 1) ? docs[0] : null;
res.json({
From e5b0138c30ed162da0c6c8bb99bba2e7e05132d1 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:56 +0000
Subject: [PATCH 04/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
amtprovisioningserver.js | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/amtprovisioningserver.js b/amtprovisioningserver.js
index d31b7b8387..6f879cfdaa 100644
--- a/amtprovisioningserver.js
+++ b/amtprovisioningserver.js
@@ -6,9 +6,6 @@
* @version v0.0.1
*/
-/*xjslint node: true */
-/*xjslint plusplus: true */
-/*xjslint maxlen: 256 */
/*jshint node: true */
/*jshint strict: false */
/*jshint esversion: 6 */
@@ -39,7 +36,7 @@ module.exports.CreateAmtProvisioningServer = function (parent, config) {
socket.on('error', function (err) { })
socket.on('close', function () { if (this.data != null) { processHelloData(this.data, this.ra); } delete this.ra; this.removeAllListeners(); })
socket.on('data', function (data) {
- if (this.data == null) { this.data = data; } else { Buffer.concat([this.data, data]); }
+ if (this.data == null) { this.data = data; } else { this.data = Buffer.concat([this.data, data]); }
var str = this.data.toString();
if (str.startsWith('GET ') && (str.indexOf('\r\n\r\n') >= 0)) {
this.data = null;
@@ -696,3 +693,4 @@ module.exports.CreateAmtProvisioningServer = function (parent, config) {
return obj;
};
+
From 4e8d02e44371d671bb60ea692e3080fa7e00669c Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:57 +0000
Subject: [PATCH 05/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
meshscanner.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/meshscanner.js b/meshscanner.js
index 5eb630af13..8d3d2fdc37 100644
--- a/meshscanner.js
+++ b/meshscanner.js
@@ -97,7 +97,7 @@ module.exports.CreateMeshScanner = function (parent) {
server4.bind(bindOptions, function () {
try {
var doscan = true;
- try { this.setBroadcast(true); this.setMulticastTTL(128); this.addMembership(membershipIPv4, this.xxlocal); } catch (e) { doscan = false; }
+ try { this.setBroadcast(true); this.setMulticastTTL(128); this.addMembership(membershipIPv4, this.xxlocal); } catch (e) { doscan = false; if (obj.parent && obj.parent.debug) { obj.parent.debug('meshscanner', 'IPv4 multicast setup failed on ' + this.xxlocal + ': ' + e); } }
this.on('error', function (error) { /*console.log('Error: ' + error);*/ });
this.on('message', function (msg, info) { onUdpPacket(msg, info, this); });
if (doscan == true) { obj.performScan(this); obj.performScan(this); }
@@ -105,7 +105,7 @@ module.exports.CreateMeshScanner = function (parent) {
});
obj.servers4[localAddress] = server4;
} catch (e) {
- console.log(e);
+ console.log('meshscanner: Failed to create IPv4 socket for ' + localAddress + ': ' + e);
}
}
}
@@ -128,7 +128,7 @@ module.exports.CreateMeshScanner = function (parent) {
server6.bind(bindOptions, function () {
try {
var doscan = true;
- try { this.setBroadcast(true); this.setMulticastTTL(128); this.addMembership(membershipIPv6, this.xxlocal); } catch (e) { doscan = false; }
+ try { this.setBroadcast(true); this.setMulticastTTL(128); this.addMembership(membershipIPv6, this.xxlocal); } catch (e) { doscan = false; if (obj.parent && obj.parent.debug) { obj.parent.debug('meshscanner', 'IPv6 multicast setup failed on ' + this.xxlocal + ': ' + e); } }
this.on('error', function (error) { console.log('Error: ' + error); });
this.on('message', function (msg, info) { onUdpPacket(msg, info, this); });
if (doscan == true) { obj.performScan(this); obj.performScan(this); }
@@ -136,7 +136,7 @@ module.exports.CreateMeshScanner = function (parent) {
});
obj.servers6[localAddress] = server6;
} catch (e) {
- console.log(e);
+ console.log('meshscanner: Failed to create IPv6 socket for ' + localAddress + ': ' + e);
}
}
}
@@ -166,7 +166,7 @@ module.exports.CreateMeshScanner = function (parent) {
if ((typeof obj.parent.config.domains[''].title2 == 'string') && (obj.parent.config.domains[''].title2.length > 0)) {
info = obj.common.replacePlaceholders(obj.parent.config.domains[''].title2, {
'serverversion': obj.parent.currentVer,
- 'servername': obj.getWebServerName(domain, req),
+ 'servername': parent.certificates.CommonName,
'agentsessions': Object.keys(parent.webserver.wsagents).length,
'connectedusers': Object.keys(parent.webserver.wssessions).length,
'userssessions': Object.keys(parent.webserver.wssessions2).length,
@@ -276,4 +276,4 @@ module.exports.CreateMeshScanner = function (parent) {
};
return obj;
-};
\ No newline at end of file
+};
From 7d6eb540a9dc97bd66648d04906b59586e517522 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:58 +0000
Subject: [PATCH 06/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
rdp/protocol/t125/gcc.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/rdp/protocol/t125/gcc.js b/rdp/protocol/t125/gcc.js
index 42a17a1c8d..adb258a911 100644
--- a/rdp/protocol/t125/gcc.js
+++ b/rdp/protocol/t125/gcc.js
@@ -444,8 +444,8 @@ function readConferenceCreateResponse(s) {
throw new error.ProtocolError('NODE_RDP_PROTOCOL_T125_GCC_BAD_H221_SC_KEY');
}
- length = per.readLength(s);
- serverSettings = settings(null, { readLength : new type.CallableValue(length) });
+ var length = per.readLength(s);
+ var serverSettings = settings(null, { readLength : new type.CallableValue(length) });
// Object magic
return serverSettings.read(s).obj.blocks.obj.map(function(e) {
@@ -479,7 +479,7 @@ function readConferenceCreateRequest (s) {
per.readOctetStream(s, h221_cs_key, 4);
- length = per.readLength(s);
+ var length = per.readLength(s);
var clientSettings = settings(null, { readLength : new type.CallableValue(length) });
// Object magic
@@ -537,4 +537,4 @@ module.exports = {
readConferenceCreateRequest : readConferenceCreateRequest,
writeConferenceCreateRequest : writeConferenceCreateRequest,
writeConferenceCreateResponse : writeConferenceCreateResponse
-};
\ No newline at end of file
+};
From 2cbc35e7cc447dd63392c63666b9e69b76b83d71 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:13:59 +0000
Subject: [PATCH 07/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
agents/modules_meshcmd/amt-lme.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/agents/modules_meshcmd/amt-lme.js b/agents/modules_meshcmd/amt-lme.js
index 5f55ed5bdc..8dae6e2280 100644
--- a/agents/modules_meshcmd/amt-lme.js
+++ b/agents/modules_meshcmd/amt-lme.js
@@ -155,7 +155,7 @@ function lme_heci(options) {
break;
case APF_SERVICE_REQUEST:
var nameLen = chunk.readUInt32BE(1);
- var name = chunk.slice(5, nameLen + 5);
+ var name = chunk.slice(5, nameLen + 5).toString();
//console.log("Service Request for: " + name);
if (name == 'pfwd@amt.intel.com' || name == 'auth@amt.intel.com') {
var outBuffer = Buffer.alloc(5 + nameLen);
@@ -214,7 +214,7 @@ function lme_heci(options) {
this.LMS.emit('bind', this._binded);
} catch (ex)
{
- console.info1(ex, 'Port ' + port);
+ console.info(ex, 'Port ' + port);
if(!this._emitConnected)
{
this._emitConnected = true;
From 2d3da8e430ce8ad91c33a38bfc1c7eaaada3fe81 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:00 +0000
Subject: [PATCH 08/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
agents/modules_meshcmd/smbios.js | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/agents/modules_meshcmd/smbios.js b/agents/modules_meshcmd/smbios.js
index ea6abe6720..6575f24799 100644
--- a/agents/modules_meshcmd/smbios.js
+++ b/agents/modules_meshcmd/smbios.js
@@ -14,6 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
+/*jslint node: true */
+/*jshint node: true */
+'use strict';
+
try { Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : undefined); } }); } catch (e) { }
try { Object.defineProperty(String.prototype, "replaceAll", { value: function replaceAll(oldVal, newVal) { return (this.split(oldVal).join(newVal)); } }); } catch (e) { }
@@ -279,7 +283,7 @@ function SMBiosTables()
retVal.storageRedirection = amt[6] ? true : false;
retVal.serialOverLan = amt[7] ? true : false;
retVal.kvm = amt[14] ? true : false;
- if (data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro')
+ if (data[131] && data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro')
{
var settings = data[131].peek();
if (settings[0] & 0x04) { retVal.TXT = (settings[0] & 0x08) ? true : false; }
@@ -300,7 +304,7 @@ function SMBiosTables()
}
if (!retVal.AMT)
{
- if (data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro')
+ if (data[131] && data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro')
{
var settings = data[131].peek();
if ((settings[20] & 0x08) == 0x08) { retVal.AMT = true; }
@@ -356,4 +360,4 @@ function SMBiosTables()
}
}
-module.exports = new SMBiosTables();
\ No newline at end of file
+module.exports = new SMBiosTables();
From 29e7329643f1cc3c455774c7242d0d07092537a4 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:01 +0000
Subject: [PATCH 09/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
agents/modules_meshcmd/sysinfo.js | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/agents/modules_meshcmd/sysinfo.js b/agents/modules_meshcmd/sysinfo.js
index 611a7b1af6..8a577327a9 100644
--- a/agents/modules_meshcmd/sysinfo.js
+++ b/agents/modules_meshcmd/sysinfo.js
@@ -201,6 +201,8 @@ function macos_memUtilization()
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = '';
child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
+ child.stderr.str = '';
+ child.stderr.on('data', function (chunk) { this.str += chunk.toString(); });
child.stdin.write('top -l 1 | grep -E "^Phys"\nexit\n');
child.waitExit();
@@ -214,12 +216,14 @@ function macos_memUtilization()
mem.MemFree = parseInt(bdown[1].trim().split(' ')[0]);
mem.percentFree = ((mem.MemFree / mem.MemTotal) * 100);//.toFixed(2);
mem.percentConsumed = (((mem.MemTotal - mem.MemFree) / mem.MemTotal) * 100);//.toFixed(2);
- return (mem);
+ ret._res(mem);
}
else
{
- throw ('Parse Error');
+ ret._rej('Parse Error');
}
+
+ return (ret);
}
function windows_thermals()
@@ -287,3 +291,4 @@ const platformConfig = {
};
module.exports = platformConfig[process.platform];
+
From 1c9868d92094f9e663ff9037c1311812c867e7ba Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:02 +0000
Subject: [PATCH 10/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
amtscanner.js | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/amtscanner.js b/amtscanner.js
index ae558f8af2..f2f087639e 100644
--- a/amtscanner.js
+++ b/amtscanner.js
@@ -57,6 +57,12 @@ module.exports.CreateAmtScanner = function (parent) {
obj.active = false;
for (var i in obj.servers) { obj.servers[i].close(); } // Stop all servers
obj.servers = {};
+ for (var i in obj.rserver) {
+ var rangeinfo = obj.rserver[i];
+ if (rangeinfo.timer != null) { clearTimeout(rangeinfo.timer); rangeinfo.timer = null; }
+ if (rangeinfo.server != null) { try { rangeinfo.server.close(); } catch (ex) { } delete rangeinfo.server; }
+ }
+ obj.rserver = {};
if (obj.mainTimer != null) { clearInterval(obj.mainTimer); obj.mainTimer = null; }
};
@@ -75,8 +81,9 @@ module.exports.CreateAmtScanner = function (parent) {
rangeinfo.server.on('listening', function() { for (var i = rangeinfo.min; i <= rangeinfo.max; i++) { rangeinfo.server.send(obj.rpacket, 623, obj.IPv4NumToStr(i)); } });
rangeinfo.timer = setTimeout(function () { // ************************* USE OF OUTER VARS!!!!!!!!!!!!!!!
obj.parent.DispatchEvent(['*', userid], obj, { action: 'scanamtdevice', range: rangeinfo.range, results: rangeinfo.results, nolog: 1 });
- rangeinfo.server.close();
- delete rangeinfo.server;
+ if (rangeinfo.server != null) { try { rangeinfo.server.close(); } catch (ex) { } delete rangeinfo.server; }
+ rangeinfo.timer = null;
+ delete obj.rserver[userid];
}, 3000);
return true;
};
@@ -151,7 +158,7 @@ module.exports.CreateAmtScanner = function (parent) {
*/
obj.ResolveName = function (hostname, func) {
- if ((hostname == '127.0.0.1') || (hostname == '::1') || (hostname == 'localhost')) { func(hostname, null); } // Don't scan localhost
+ if ((hostname == '127.0.0.1') || (hostname == '::1') || (hostname == 'localhost')) { func(hostname, null); return; } // Don't scan localhost
if (obj.net.isIP(hostname) > 0) { func(hostname, hostname); return; } // This is an IP address, already resolved.
obj.dns.lookup(hostname, function (err, address, family) { if (err == null) { func(hostname, address); } else { func(hostname, null); } });
};
@@ -426,4 +433,4 @@ module.exports.CreateAmtScanner = function (parent) {
//console.log(obj.getIntelAmtVersionFromHeaders("HTTP/1.1 303 See Other\r\nLocation: /logon.htm\r\nContent-Length: 0\r\nServer: Intel(R) Active Management Technology 7.1.91\r\n\r\n"));
return obj;
-};
\ No newline at end of file
+};
From 2bd9f002ad65f686bed5778ad7a44dd8154c07d7 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:03 +0000
Subject: [PATCH 11/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
interceptor.js | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/interceptor.js b/interceptor.js
index c6e4a87820..cedbb5b41f 100644
--- a/interceptor.js
+++ b/interceptor.js
@@ -197,38 +197,38 @@ module.exports.CreateHttpInterceptor = function (args) {
} else if (obj.ws.mode == 1) { // Length Body Mode
// Send the body of content-length size
var rl = obj.ws.count;
- if (rl < obj.ws.acc.length) rl = obj.ws.acc.length;
+ if (rl > obj.ws.acc.length) rl = obj.ws.acc.length;
r = obj.ws.acc.substring(0, rl);
obj.ws.acc = obj.ws.acc.substring(rl);
obj.ws.count -= rl;
if (obj.ws.count == 0) { obj.ws.mode = 0; }
return r;
- } else if (obj.amt.mode == 2) { // Chunked Body Mode
+ } else if (obj.ws.mode == 2) { // Chunked Body Mode
// Send data one chunk at a time
- headerend = obj.amt.acc.indexOf('\r\n');
+ headerend = obj.ws.acc.indexOf('\r\n');
if (headerend < 0) return '';
- var chunksize = parseInt(obj.amt.acc.substring(0, headerend), 16);
+ var chunksize = parseInt(obj.ws.acc.substring(0, headerend), 16);
if (isNaN(chunksize)) { // TODO: Check this path
// Chunk is not in this batch, move one
- r = obj.amt.acc.substring(0, headerend + 2);
- obj.amt.acc = obj.amt.acc.substring(headerend + 2);
+ r = obj.ws.acc.substring(0, headerend + 2);
+ obj.ws.acc = obj.ws.acc.substring(headerend + 2);
// Peek if we next is the end of chunked transfer
- headerend = obj.amt.acc.indexOf('\r\n');
+ headerend = obj.ws.acc.indexOf('\r\n');
if (headerend > 0) {
- chunksize = parseInt(obj.amt.acc.substring(0, headerend), 16);
- if (chunksize == 0) { obj.amt.mode = 0; }
+ chunksize = parseInt(obj.ws.acc.substring(0, headerend), 16);
+ if (chunksize == 0) { obj.ws.mode = 0; }
}
return r;
- } else if (chunksize == 0 && obj.amt.acc.length >= headerend + 4) {
+ } else if (chunksize == 0 && obj.ws.acc.length >= headerend + 4) {
// Send the ending chunk (NOTE: We do not support trailing headers)
- r = obj.amt.acc.substring(0, headerend + 4);
- obj.amt.acc = obj.amt.acc.substring(headerend + 4);
- obj.amt.mode = 0;
+ r = obj.ws.acc.substring(0, headerend + 4);
+ obj.ws.acc = obj.ws.acc.substring(headerend + 4);
+ obj.ws.mode = 0;
return r;
- } else if (chunksize > 0 && obj.amt.acc.length >= headerend + 4) {
+ } else if (chunksize > 0 && obj.ws.acc.length >= headerend + 4) {
// Send a chunk
- r = obj.amt.acc.substring(0, headerend + chunksize + 4);
- obj.amt.acc = obj.amt.acc.substring(headerend + chunksize + 4);
+ r = obj.ws.acc.substring(0, headerend + chunksize + 4);
+ obj.ws.acc = obj.ws.acc.substring(headerend + chunksize + 4);
return r;
}
} else if (obj.ws.mode == 3) { // Until Close Mode
@@ -457,4 +457,4 @@ module.exports.CreateRedirInterceptor = function (args) {
};
return obj;
-};
\ No newline at end of file
+};
From c4273c6a778dfe2b5c3b94d04ed5e79591fc23dd Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:05 +0000
Subject: [PATCH 12/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
pluginHandler.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pluginHandler.js b/pluginHandler.js
index 3b7ba2051c..7f2e580cb2 100644
--- a/pluginHandler.js
+++ b/pluginHandler.js
@@ -250,7 +250,7 @@ module.exports.pluginHandler = function (parent) {
obj.getPluginConfig = function (configUrl) {
return new Promise(function (resolve, reject) {
var http = (configUrl.indexOf('https://') >= 0) ? require('https') : require('http');
- if (configUrl.indexOf('://') === -1) reject("Unable to fetch the config: Bad URL (" + configUrl + ")");
+ if (configUrl.indexOf('://') === -1) { reject("Unable to fetch the config: Bad URL (" + configUrl + ")"); return; }
var options = require('url').parse(configUrl);
if (typeof parent.config.settings.plugins.proxy == 'string' || process.env['HTTP_PROXY'] || process.env['HTTPS_PROXY'] || process.env['http_proxy'] || process.env['https_proxy']) { // Proxy support
options.agent = new (require('https-proxy-agent').HttpsProxyAgent)(require('url').parse(parent.config.settings.plugins.proxy) || process.env['HTTP_PROXY'] || process.env['HTTPS_PROXY'] || process.env['http_proxy'] || process.env['https_proxy']);
@@ -956,3 +956,4 @@ module.exports.pluginHandler = function (parent) {
}
return obj;
};
+
From 295f8e726ccfc3332a82c5b7888e3fcc14cdf6b7 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:05 +0000
Subject: [PATCH 13/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
agents/agentrecoverycore.js | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/agents/agentrecoverycore.js b/agents/agentrecoverycore.js
index 842ef70cb0..3ad73b82c4 100644
--- a/agents/agentrecoverycore.js
+++ b/agents/agentrecoverycore.js
@@ -255,12 +255,12 @@ require('MeshAgent').AddCommandHandler(function (data)
break;
case 'mkdir': {
// Create a new empty folder
- fs.mkdirSync(cmd.path);
+ try { fs.mkdirSync(cmd.path); } catch (e) { this.write(new Buffer(JSON.stringify({ action: 'mkdirerror' }))); }
break;
}
case 'mkfile': {
// Create a new empty file
- fs.closeSync(fs.openSync(cmd.path, 'w'));
+ try { fs.closeSync(fs.openSync(cmd.path, 'w')); } catch (e) { this.write(new Buffer(JSON.stringify({ action: 'mkfileerror' }))); }
break;
}
case 'rm': {
@@ -336,7 +336,7 @@ require('MeshAgent').AddCommandHandler(function (data)
break;
}
default:
- // Unknown action, ignore it.
+ console.log('Unknown command action: ' + data.action);
break;
}
}
@@ -469,3 +469,4 @@ function deleteFolderRecursive(path, rec) {
fs.unlinkSync(path);
}
};
+
From d68ff996b71c38172a4ad887cb79230aca2e9f45 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:06 +0000
Subject: [PATCH 14/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
amt/amt-xml.js | 399 +++++++++++++++++++++++++------------------------
1 file changed, 204 insertions(+), 195 deletions(-)
diff --git a/amt/amt-xml.js b/amt/amt-xml.js
index 9c44195266..fb9ce865f1 100644
--- a/amt/amt-xml.js
+++ b/amt/amt-xml.js
@@ -1,195 +1,204 @@
-/*
-Copyright 2020-2021 Intel Corporation
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-@description Intel AMT XML parsing module
-@author Ylian Saint-Hilaire
-@version v0.3.0
-*/
-
-/*jslint node: true */
-/*jshint node: true */
-/*jshint strict:false */
-/*jshint -W097 */
-/*jshint esversion: 6 */
-"use strict";
-
-// Parse XML and return JSON
-module.exports.ParseWsman = function (xml) {
- try {
- if (!xml.childNodes) xml = _turnToXml(xml);
- var r = { Header: {} }, header = xml.getElementsByTagName("Header")[0], t;
- if (!header) header = xml.getElementsByTagName("a:Header")[0];
- if (!header) return null;
- for (var i = 0; i < header.childNodes.length; i++) {
- var child = header.childNodes[i];
- r.Header[child.localName] = child.textContent;
- }
- var body = xml.getElementsByTagName("Body")[0];
- if (!body) body = xml.getElementsByTagName("a:Body")[0];
- if (!body) return null;
- if (body.childNodes.length > 0) {
- t = body.childNodes[0].localName;
- var x = t.indexOf('_OUTPUT');
- if ((x != -1) && (x == (t.length - 7))) { t = t.substring(0, t.length - 7); }
- r.Header['Method'] = t;
- r.Body = _ParseWsmanRec(body.childNodes[0]);
- }
- return r;
- } catch (e) {
- console.log("Unable to parse XML: " + xml);
- return null;
- }
-}
-
-// Private method
-function _ParseWsmanRec(node) {
- var data, r = {};
- for (var i = 0; i < node.childNodes.length; i++) {
- var child = node.childNodes[i];
- if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
- if (data == 'true') data = true; // Convert 'true' into true
- if (data == 'false') data = false; // Convert 'false' into false
- if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
-
- var childObj = data;
- if ((child.attributes != null) && (child.attributes.length > 0)) {
- childObj = { 'Value': data };
- for (var j = 0; j < child.attributes.length; j++) {
- childObj['@' + child.attributes[j].name] = child.attributes[j].value;
- }
- }
-
- if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
- else if (r[child.localName] == null) { r[child.localName] = childObj; }
- else { r[child.localName] = [r[child.localName], childObj]; }
- }
- return r;
-}
-
-function _PutObjToBodyXml(resuri, putObj) {
- if (!resuri || putObj == null) return '';
- var objname = obj.GetNameFromUrl(resuri);
- var result = '';
-
- for (var prop in putObj) {
- if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
- if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
- if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
- result += '' + putObj[prop].Address + '' + putObj[prop]['ReferenceParameters']["ResourceURI"] + '';
- var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
- if (Array.isArray(selectorArray)) {
- for (var i = 0; i < selectorArray.length; i++) {
- result += '' + selectorArray[i]['Value'] + '';
- }
- }
- else {
- result += '' + selectorArray['Value'] + '';
- }
- result += '';
- }
- else {
- if (Array.isArray(putObj[prop])) {
- for (var i = 0; i < putObj[prop].length; i++) {
- result += '' + putObj[prop][i].toString() + '';
- }
- } else {
- result += '' + putObj[prop].toString() + '';
- }
- }
- }
-
- result += '';
- return result;
-}
-
-// This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
-try { Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : null); } }); } catch (ex) { }
-function _treeBuilder() {
- this.tree = [];
- this.push = function (element) { this.tree.push(element); };
- this.pop = function () { var element = this.tree.pop(); if (this.tree.length > 0) { var x = this.tree.peek(); x.childNodes.push(element); x.childElementCount = x.childNodes.length; } return (element); };
- this.peek = function () { return (this.tree.peek()); }
- this.addNamespace = function (prefix, namespace) { this.tree.peek().nsTable[prefix] = namespace; if (this.tree.peek().attributes.length > 0) { for (var i = 0; i < this.tree.peek().attributes; ++i) { var a = this.tree.peek().attributes[i]; if (prefix == '*' && a.name == a.localName) { a.namespace = namespace; } else if (prefix != '*' && a.name != a.localName) { var pfx = a.name.split(':')[0]; if (pfx == prefix) { a.namespace = namespace; } } } } }
- this.getNamespace = function (prefix) { for (var i = this.tree.length - 1; i >= 0; --i) { if (this.tree[i].nsTable[prefix] != null) { return (this.tree[i].nsTable[prefix]); } } return null; }
-}
-function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
-function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
-function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
-function _getChildElementsByTagName(name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name) { ret.push(this.childNodes[node]); } } } return (ret); }
-function _getChildElementsByTagNameNS(ns, name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name && (ns == '*' || this.childNodes[node].namespace == ns)) { ret.push(this.childNodes[node]); } } } return (ret); }
-function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
-function _turnToXmlRec(text) {
- var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
- for (var i in x1) {
- var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
- if ((elementName.length > 0) && (elementName[0] != '?')) {
- if (elementName[0] != '/') {
- var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
- Object.defineProperty(attributes, "get",
- {
- value: function () {
- if (arguments.length == 1) {
- for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
- }
- else if (arguments.length == 2) {
- for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
- }
- else {
- throw ('attributes.get(): Invalid number of parameters');
- }
- }
- });
- elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
- // Parse Attributes
- if (x3.length > 0) {
- var skip = false;
- for (var j in x3) {
- if (x3[j] == '/') {
- // This is an empty Element
- elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
- elementStack.peek().textContent = '';
- lastElement = elementStack.pop();
- skip = true;
- break;
- }
- var k = x3[j].indexOf('=');
- if (k > 0) {
- var attrName = x3[j].substring(0, k);
- var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
- var attrNS = elementStack.getNamespace('*');
-
- if (attrName == 'xmlns') {
- elementStack.addNamespace('*', attrValue);
- attrNS = attrValue;
- } else if (attrName.startsWith('xmlns:')) {
- elementStack.addNamespace(attrName.substring(6), attrValue);
- } else {
- var ax = attrName.split(':');
- if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
- }
- var x = { name: attrName, value: attrValue }
- if (attrNS != null) x.namespace = attrNS;
- elementStack.peek().attributes.push(x);
- }
- }
- if (skip) { continue; }
- }
- elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
- if (x2[1]) { elementStack.peek().textContent = x2[1]; }
- } else { lastElement = elementStack.pop(); }
- }
- }
- return lastElement;
-}
\ No newline at end of file
+/*
+Copyright 2020-2021 Intel Corporation
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+@description Intel AMT XML parsing module
+@author Ylian Saint-Hilaire
+@version v0.3.0
+*/
+
+/*jslint node: true */
+/*jshint node: true */
+/*jshint strict:false */
+/*jshint -W097 */
+/*jshint esversion: 6 */
+"use strict";
+
+// Parse XML and return JSON
+module.exports.ParseWsman = function (xml) {
+ try {
+ if (!xml.childNodes) xml = _turnToXml(xml);
+ var r = { Header: {} }, header = xml.getElementsByTagName("Header")[0], t;
+ if (!header) header = xml.getElementsByTagName("a:Header")[0];
+ if (!header) return null;
+ for (var i = 0; i < header.childNodes.length; i++) {
+ var child = header.childNodes[i];
+ r.Header[child.localName] = child.textContent;
+ }
+ var body = xml.getElementsByTagName("Body")[0];
+ if (!body) body = xml.getElementsByTagName("a:Body")[0];
+ if (!body) return null;
+ if (body.childNodes.length > 0) {
+ t = body.childNodes[0].localName;
+ var x = t.indexOf('_OUTPUT');
+ if ((x != -1) && (x == (t.length - 7))) { t = t.substring(0, t.length - 7); }
+ r.Header['Method'] = t;
+ r.Body = _ParseWsmanRec(body.childNodes[0]);
+ }
+ return r;
+ } catch (e) {
+ console.log("Unable to parse XML: exception occurred while parsing, length=" + (xml && xml.length != null ? xml.length : 'unknown'));
+ return null;
+ }
+}
+
+// Private method
+function _ParseWsmanRec(node) {
+ var data, r = {};
+ for (var i = 0; i < node.childNodes.length; i++) {
+ var child = node.childNodes[i];
+ if ((child.childElementCount == null) || (child.childElementCount == 0)) { data = child.textContent; } else { data = _ParseWsmanRec(child); }
+ if (data == 'true') data = true; // Convert 'true' into true
+ if (data == 'false') data = false; // Convert 'false' into false
+ if ((parseInt(data) + '') === data) data = parseInt(data); // Convert integers
+
+ var childObj = data;
+ if ((child.attributes != null) && (child.attributes.length > 0)) {
+ childObj = { 'Value': data };
+ for (var j = 0; j < child.attributes.length; j++) {
+ childObj['@' + child.attributes[j].name] = child.attributes[j].value;
+ }
+ }
+
+ if (r[child.localName] instanceof Array) { r[child.localName].push(childObj); }
+ else if (r[child.localName] == null) { r[child.localName] = childObj; }
+ else { r[child.localName] = [r[child.localName], childObj]; }
+ }
+ return r;
+}
+
+function _EscapeXml(value) {
+ return value.toString()
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
+function _PutObjToBodyXml(resuri, putObj) {
+ if (!resuri || putObj == null) return '';
+ var objname = obj.GetNameFromUrl(resuri);
+ var result = '';
+
+ for (var prop in putObj) {
+ if (!putObj.hasOwnProperty(prop) || prop.indexOf('__') === 0 || prop.indexOf('@') === 0) continue;
+ if (putObj[prop] == null || typeof putObj[prop] === 'function') continue;
+ if (typeof putObj[prop] === 'object' && putObj[prop]['ReferenceParameters']) {
+ result += '' + _EscapeXml(putObj[prop].Address) + '' + _EscapeXml(putObj[prop]['ReferenceParameters']["ResourceURI"]) + '';
+ var selectorArray = putObj[prop]['ReferenceParameters']['SelectorSet']['Selector'];
+ if (Array.isArray(selectorArray)) {
+ for (var i = 0; i < selectorArray.length; i++) {
+ result += '' + _EscapeXml(selectorArray[i]['Value']) + '';
+ }
+ }
+ else {
+ result += '' + _EscapeXml(selectorArray['Value']) + '';
+ }
+ result += '';
+ }
+ else {
+ if (Array.isArray(putObj[prop])) {
+ for (var i = 0; i < putObj[prop].length; i++) {
+ result += '' + _EscapeXml(putObj[prop][i]) + '';
+ }
+ } else {
+ result += '' + _EscapeXml(putObj[prop]) + '';
+ }
+ }
+ }
+
+ result += '';
+ return result;
+}
+
+// This is a drop-in replacement to _turnToXml() that works without xml parser dependency.
+try { Object.defineProperty(Array.prototype, "peek", { value: function () { return (this.length > 0 ? this[this.length - 1] : null); } }); } catch (ex) { }
+function _treeBuilder() {
+ this.tree = [];
+ this.push = function (element) { this.tree.push(element); };
+ this.pop = function () { var element = this.tree.pop(); if (this.tree.length > 0) { var x = this.tree.peek(); x.childNodes.push(element); x.childElementCount = x.childNodes.length; } return (element); };
+ this.peek = function () { return (this.tree.peek()); }
+ this.addNamespace = function (prefix, namespace) { this.tree.peek().nsTable[prefix] = namespace; if (this.tree.peek().attributes.length > 0) { for (var i = 0; i < this.tree.peek().attributes; ++i) { var a = this.tree.peek().attributes[i]; if (prefix == '*' && a.name == a.localName) { a.namespace = namespace; } else if (prefix != '*' && a.name != a.localName) { var pfx = a.name.split(':')[0]; if (pfx == prefix) { a.namespace = namespace; } } } } }
+ this.getNamespace = function (prefix) { for (var i = this.tree.length - 1; i >= 0; --i) { if (this.tree[i].nsTable[prefix] != null) { return (this.tree[i].nsTable[prefix]); } } return null; }
+}
+function _turnToXml(text) { if (text == null) return null; return ({ childNodes: [_turnToXmlRec(text)], getElementsByTagName: _getElementsByTagName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS }); }
+function _getElementsByTagNameNS(ns, name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name && (node.namespace == ns || ns == '*')) { ret.push(node); } }); return ret; }
+function _getElementsByTagName(name) { var ret = []; _xmlTraverseAllRec(this.childNodes, function (node) { if (node.localName == name) { ret.push(node); } }); return ret; }
+function _getChildElementsByTagName(name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name) { ret.push(this.childNodes[node]); } } } return (ret); }
+function _getChildElementsByTagNameNS(ns, name) { var ret = []; if (this.childNodes != null) { for (var node in this.childNodes) { if (this.childNodes[node].localName == name && (ns == '*' || this.childNodes[node].namespace == ns)) { ret.push(this.childNodes[node]); } } } return (ret); }
+function _xmlTraverseAllRec(nodes, func) { for (var i in nodes) { func(nodes[i]); if (nodes[i].childNodes) { _xmlTraverseAllRec(nodes[i].childNodes, func); } } }
+function _turnToXmlRec(text) {
+ var elementStack = new _treeBuilder(), lastElement = null, x1 = text.split('<'), ret = [], element = null, currentElementName = null;
+ for (var i in x1) {
+ var x2 = x1[i].split('>'), x3 = x2[0].split(' '), elementName = x3[0];
+ if ((elementName.length > 0) && (elementName[0] != '?')) {
+ if (elementName[0] != '/') {
+ var attributes = [], localName, localname2 = elementName.split(' ')[0].split(':'), localName = (localname2.length > 1) ? localname2[1] : localname2[0];
+ Object.defineProperty(attributes, "get",
+ {
+ value: function () {
+ if (arguments.length == 1) {
+ for (var a in this) { if (this[a].name == arguments[0]) { return (this[a]); } }
+ }
+ else if (arguments.length == 2) {
+ for (var a in this) { if (this[a].name == arguments[1] && (arguments[0] == '*' || this[a].namespace == arguments[0])) { return (this[a]); } }
+ }
+ else {
+ throw ('attributes.get(): Invalid number of parameters');
+ }
+ }
+ });
+ elementStack.push({ name: elementName, localName: localName, getChildElementsByTagName: _getChildElementsByTagName, getElementsByTagNameNS: _getElementsByTagNameNS, getChildElementsByTagNameNS: _getChildElementsByTagNameNS, attributes: attributes, childNodes: [], nsTable: {} });
+ // Parse Attributes
+ if (x3.length > 0) {
+ var skip = false;
+ for (var j in x3) {
+ if (x3[j] == '/') {
+ // This is an empty Element
+ elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
+ elementStack.peek().textContent = '';
+ lastElement = elementStack.pop();
+ skip = true;
+ break;
+ }
+ var k = x3[j].indexOf('=');
+ if (k > 0) {
+ var attrName = x3[j].substring(0, k);
+ var attrValue = x3[j].substring(k + 2, x3[j].length - 1);
+ var attrNS = elementStack.getNamespace('*');
+
+ if (attrName == 'xmlns') {
+ elementStack.addNamespace('*', attrValue);
+ attrNS = attrValue;
+ } else if (attrName.startsWith('xmlns:')) {
+ elementStack.addNamespace(attrName.substring(6), attrValue);
+ } else {
+ var ax = attrName.split(':');
+ if (ax.length == 2) { attrName = ax[1]; attrNS = elementStack.getNamespace(ax[0]); }
+ }
+ var x = { name: attrName, value: attrValue }
+ if (attrNS != null) x.namespace = attrNS;
+ elementStack.peek().attributes.push(x);
+ }
+ }
+ if (skip) { continue; }
+ }
+ elementStack.peek().namespace = elementStack.peek().name == elementStack.peek().localName ? elementStack.getNamespace('*') : elementStack.getNamespace(elementStack.peek().name.substring(0, elementStack.peek().name.indexOf(':')));
+ if (x2[1]) { elementStack.peek().textContent = x2[1]; }
+ } else { lastElement = elementStack.pop(); }
+ }
+ }
+ return lastElement;
+}
From 6e5667c0d80815d4578c47d56a3e9377b452c44b Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:07 +0000
Subject: [PATCH 15/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
rdp/core/layer.js | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/rdp/core/layer.js b/rdp/core/layer.js
index 7aa92d3b43..71bb7b0fd9 100644
--- a/rdp/core/layer.js
+++ b/rdp/core/layer.js
@@ -154,9 +154,10 @@ BufferLayer.prototype.startTLS = function(callback) {
socket: this.socket,
secureContext: tls.createSecureContext(),
isServer: false,
- requestCert: false,
- rejectUnauthorized: false
+ requestCert: (process.env.MESHCENTRAL_RDP_STRICT_TLS == '1'),
+ rejectUnauthorized: (process.env.MESHCENTRAL_RDP_STRICT_TLS == '1')
}, (err) => {
+ if (err) { console.log('RDP startTLS error: ' + err); }
log.warn(err);
callback(err);
});
@@ -194,9 +195,10 @@ BufferLayer.prototype.listenTLS = function(keyFilePath, crtFilePath, callback) {
cert: fs.readFileSync(crtFilePath),
}),
isServer: true,
- requestCert: false,
- rejectUnauthorized: false
+ requestCert: (process.env.MESHCENTRAL_RDP_STRICT_TLS == '1'),
+ rejectUnauthorized: (process.env.MESHCENTRAL_RDP_STRICT_TLS == '1')
}, (err) => {
+ if (err) { console.log('RDP listenTLS error: ' + err); }
log.warn(err);
callback(err);
});
@@ -227,3 +229,4 @@ BufferLayer.prototype.close = function() {
module.exports = {
BufferLayer : BufferLayer
};
+
From 4cc5a0081d0a590c0a67222d5382a5844f285347 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:08 +0000
Subject: [PATCH 16/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
amt/amt-redir-mesh.js | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/amt/amt-redir-mesh.js b/amt/amt-redir-mesh.js
index 0dae49a12e..a48dc804ea 100644
--- a/amt/amt-redir-mesh.js
+++ b/amt/amt-redir-mesh.js
@@ -77,6 +77,7 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
// Older NodeJS does not support the keyword "class", so we do without using this syntax
// TODO: Validate that it's the same as above and that it works.
+ // TODO: This is duplicated in apprelays.js as well, consider extracting into a shared module.
function SerialTunnel(options) {
var obj = new require('stream').Duplex(options);
obj.forwardwrite = null;
@@ -226,6 +227,10 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
var port = 16994;
if (node.intelamt.tls > 0) port = 16995; // This is a direct connection, use TLS when possible
+ // Record the expected certificate fingerprint (if known) so we can verify it once the TLS handshake completes,
+ // since rejectUnauthorized is disabled below to allow AMT's self-signed firmware certificates.
+ obj.xtlsFingerprint = (node.intelamt.mpsCert && node.intelamt.mpsCert.fingerprint) ? node.intelamt.mpsCert.fingerprint : ((node.intelamt.tlsFingerprint) ? node.intelamt.tlsFingerprint : 0);
+
if (node.intelamt.tls != 1) {
// If this is TCP (without TLS) set a normal TCP socket
obj.forwardclient = new obj.net.Socket();
@@ -241,6 +246,9 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
obj.forwardclient = obj.tls.connect(port, node.host, tlsoptions, function () {
// The TLS connection method is the same as TCP, but located a bit differently.
Debug(2, 'TLS Intel AMT transport connected to ' + node.host + ':' + port + '.');
+ // Verify the peer certificate fingerprint (if one is known) before allowing data to flow,
+ // since rejectUnauthorized is disabled above for AMT's self-signed firmware certificates.
+ obj.xtls = true;
obj.xxOnSocketConnected();
});
obj.forwardclient.setEncoding('binary');
@@ -289,8 +297,8 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
//console.log('xxOnSocketConnected');
if (!obj.xtlsoptions || !obj.xtlsoptions.meshServerConnect) {
if (obj.xtls == true) {
- obj.xtlsCertificate = obj.socket.getPeerCertificate();
- if ((obj.xtlsFingerprint != 0) && (obj.xtlsCertificate.fingerprint.split(':').join('').toLowerCase() != obj.xtlsFingerprint)) { obj.Stop(); return; }
+ obj.xtlsCertificate = obj.forwardclient.getPeerCertificate ? obj.forwardclient.getPeerCertificate() : obj.socket.getPeerCertificate();
+ if (obj.xtlsFingerprint && (obj.xtlsFingerprint != 0) && (obj.xtlsCertificate.fingerprint.split(':').join('').toLowerCase() != obj.xtlsFingerprint)) { obj.Stop(); return; }
}
}
@@ -545,3 +553,4 @@ module.exports.CreateAmtRedirect = function (module, domain, user, webserver, me
function ToIntStr(v) { return String.fromCharCode((v & 0xFF), ((v >> 8) & 0xFF), ((v >> 16) & 0xFF), ((v >> 24) & 0xFF)); }
function ToShortStr(v) { return String.fromCharCode((v & 0xFF), ((v >> 8) & 0xFF)); }
+
From d23cbc824d9dc96fbce597d334834cf47c126486 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:10 +0000
Subject: [PATCH 17/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
public/samples/relay.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/public/samples/relay.js b/public/samples/relay.js
index 6b1f4f65f2..c928643258 100644
--- a/public/samples/relay.js
+++ b/public/samples/relay.js
@@ -21,7 +21,7 @@ var createMeshConnection = function (connectionId) {
console.log('WebSocket Message', e);
if ((obj.state = 1) && (e.data == 'c')) {
obj.state = 2;
- if (obj.onStateChanged) { onStateChanged(obj, 2); }
+ if (obj.onStateChanged) { obj.onStateChanged(obj, 2); }
console.log('WebSocket Peer Connection', e);
obj.send('bob');
} else {
@@ -31,11 +31,11 @@ var createMeshConnection = function (connectionId) {
obj.websocket.onclose = function (e) {
console.log('WebSocket Closed', e);
obj.state = 0;
- if (obj.onStateChanged) { onStateChanged(obj, 0); }
+ if (obj.onStateChanged) { obj.onStateChanged(obj, 0); }
};
obj.websocket.onerror = function (e) { console.log('WebSocket Error', e); };
obj.state = 1;
- if (obj.onStateChanged) { onStateChanged(obj, 1); }
+ if (obj.onStateChanged) { obj.onStateChanged(obj, 1); }
}
return obj;
};
@@ -45,4 +45,4 @@ var createMeshConnection = function (connectionId) {
};
return obj;
-}
\ No newline at end of file
+}
From 4997516bb90316f5fa3d232600517c03722c1280 Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:10 +0000
Subject: [PATCH 18/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
rdp/protocol/nla.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rdp/protocol/nla.js b/rdp/protocol/nla.js
index acc814d390..c2aa01e7b5 100644
--- a/rdp/protocol/nla.js
+++ b/rdp/protocol/nla.js
@@ -129,7 +129,7 @@ NLA.prototype.recvData = function (s) {
const publicKeyDer = self.security_interface.gss_unwrapex(derBuffer);
// Check that the public key is identical except the first byte which is the DER encoding type.
- if (!this.ntlm.publicKeyDer.slice(1).equals(publicKeyDer.slice(1))) { console.log('RDP man-in-the-middle detected.'); close(); return; }
+ if (!this.ntlm.publicKeyDer.slice(1).equals(publicKeyDer.slice(1))) { console.log('RDP man-in-the-middle detected.'); this.close(); return; }
delete this.ntlm.publicKeyDer; // Clean this up, we don't need it anymore.
var xdomain, xuser, xpassword;
@@ -716,4 +716,4 @@ function unitTest() {
console.log(compareArray(bufToArr(r), [48, 12, 160, 3, 2, 1, 2, 162, 5, 4, 3, 102, 111, 111]) ? "create_ts_authinfo passed." : "create_ts_authinfo failed.");
console.log('--- RDP NLA Unit Tests Completed');
-}
\ No newline at end of file
+}
From 1b4ab9cb7055d0b9bb99bd78592c21520e58c01e Mon Sep 17 00:00:00 2001
From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com>
Date: Mon, 7 Sep 2026 05:14:11 +0000
Subject: [PATCH 19/19] fix(adhoc-sweep-fixes): 36 review findings across 19
files
---
public/scripts/agent-redir-rtc-0.1.0.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/public/scripts/agent-redir-rtc-0.1.0.js b/public/scripts/agent-redir-rtc-0.1.0.js
index 3092bb4105..b0bc28b1bd 100644
--- a/public/scripts/agent-redir-rtc-0.1.0.js
+++ b/public/scripts/agent-redir-rtc-0.1.0.js
@@ -49,7 +49,7 @@ var CreateKvmDataChannel = function (webchannel, module, keepalive) {
// Chrome & Firefox (Draft)
fileReaderInuse = true;
fileReader.readAsBinaryString(new Blob([e.data]));
- } else if (f.readAsArrayBuffer) {
+ } else if (fileReader.readAsArrayBuffer) {
// Chrome & Firefox (Spec)
fileReaderInuse = true;
fileReader.readAsArrayBuffer(e.data);
@@ -144,3 +144,4 @@ var CreateKvmDataChannel = function (webchannel, module, keepalive) {
return obj;
}
+