-
Notifications
You must be signed in to change notification settings - Fork 1
fix(MESHCENT-002): CU-86akhf8u4 12 review findings across 6 files #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
48158c4
45c8909
b809334
45ba842
a11a39c
a0d6861
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,11 +37,13 @@ module.exports.CreateHttpInterceptor = function (args) { | |
|
|
||
| // Process data coming from Intel AMT | ||
| obj.processAmtData = function (data) { | ||
| obj.amt.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processAmtDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| try { | ||
| obj.amt.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processAmtDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| } catch (ex) { obj.Debug('processAmtData exception: ' + ex); return Buffer.from('', 'binary'); } | ||
| }; | ||
|
|
||
| // Process data coming from AMT in the accumulator | ||
|
|
@@ -86,7 +88,7 @@ module.exports.CreateHttpInterceptor = function (args) { | |
| } else if (obj.amt.mode == 1) { // Length Body Mode | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Same inverted length-clamp bug duplicated in AMT-side body handler Fixed the inverted clamp in π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| // Send the body of content-length size | ||
| var rl = obj.amt.count; | ||
| if (rl < obj.amt.acc.length) rl = obj.amt.acc.length; | ||
| if (rl > obj.amt.acc.length) rl = obj.amt.acc.length; | ||
| r = obj.amt.acc.substring(0, rl); | ||
| obj.amt.acc = obj.amt.acc.substring(rl); | ||
| obj.amt.count -= rl; | ||
|
Comment on lines
88
to
94
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ ws.send-equivalent socket writes in interceptor.js are not wrapped in try/catch Wrapped the top-level entry points that process incoming socket data ( π€ Prompt for AI agentsfix confidence: π΄ 45 low β review closely β react π/π to teach the reviewer |
||
|
|
@@ -119,11 +121,13 @@ module.exports.CreateHttpInterceptor = function (args) { | |
|
|
||
| // Process data coming from the Browser | ||
| obj.processBrowserData = function (data) { | ||
| obj.ws.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processBrowserDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| try { | ||
| obj.ws.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processBrowserDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| } catch (ex) { obj.Debug('processBrowserData exception: ' + ex); return Buffer.from('', 'binary'); } | ||
| }; | ||
|
|
||
| // Process data coming from the Browser in the accumulator | ||
|
|
@@ -197,7 +201,7 @@ module.exports.CreateHttpInterceptor = function (args) { | |
| } else if (obj.ws.mode == 1) { // Length Body Mode | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Off-by-one buffer truncation bug in amt-wsman-duk.js PerformAjaxEx length-body branch Fixed the identical inverted clamp in π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| // 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; | ||
|
|
@@ -286,12 +290,14 @@ module.exports.CreateRedirInterceptor = function (args) { | |
|
|
||
| // Process data coming from Intel AMT | ||
| obj.processAmtData = function (data) { | ||
| if ((obj.amt.direct == true) && (obj.amt.acc == '')) { return data; } // Interceptor fast path | ||
| obj.amt.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processAmtDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| try { | ||
| if ((obj.amt.direct == true) && (obj.amt.acc == '')) { return data; } // Interceptor fast path | ||
| obj.amt.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processAmtDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| } catch (ex) { obj.Debug('processAmtData exception: ' + ex); return Buffer.from('', 'binary'); } | ||
| }; | ||
|
|
||
| // Process data coming from AMT in the accumulator | ||
|
|
@@ -354,12 +360,14 @@ module.exports.CreateRedirInterceptor = function (args) { | |
|
|
||
| // Process data coming from the Browser | ||
| obj.processBrowserData = function (data) { | ||
| if ((obj.ws.direct == true) && (obj.ws.acc == '')) { return data; } // Interceptor fast path | ||
| obj.ws.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processBrowserDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| try { | ||
| if ((obj.ws.direct == true) && (obj.ws.acc == '')) { return data; } // Interceptor fast path | ||
| obj.ws.acc += data.toString('binary'); // Add data to accumulator | ||
| data = ''; | ||
| var datalen = 0; | ||
| do { datalen = data.length; data += obj.processBrowserDataEx(); } while (datalen != data.length); // Process as much data as possible | ||
| return Buffer.from(data, 'binary'); | ||
| } catch (ex) { obj.Debug('processBrowserData exception: ' + ex); return Buffer.from('', 'binary'); } | ||
| }; | ||
|
|
||
| // Process data coming from the Browser in the accumulator | ||
|
|
@@ -457,4 +465,4 @@ module.exports.CreateRedirInterceptor = function (args) { | |
| }; | ||
|
|
||
| return obj; | ||
| }; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,18 +108,19 @@ function serverConnect() { | |
| console.log('Connected at user: ' + data.userinfo.name); | ||
| if ((args.targetuser != null) || (args.targetsession != null)) { | ||
| console.log('Sending interuser message...'); | ||
| ws.send(JSON.stringify({ action: 'interuser', userid: args.targetuser, sessionid: args.targetsession, data: 'Hello!!!' })); // Send a hello message | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ ws.send() calls in meshbot.js not wrapped in try/catch In the 'userinfo' case handler of the ws.on('message', ...) callback in serverConnect(), wrapped the ws.send() call (interuser hello message) in a try/catch block with an empty catch, matching the suggested fix exactly. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| try { ws.send(JSON.stringify({ action: 'interuser', userid: args.targetuser, sessionid: args.targetsession, data: 'Hello!!!' })); } catch (ex) { } // Send a hello message | ||
| } | ||
| break; | ||
| } | ||
| case 'interuser': { | ||
| console.log('Got InterUser Message', data); | ||
| if ((args.targetuser == null) && (args.targetsession == null) && (typeof data.data == 'string')) { // For testing, echo back the original message. | ||
| console.log('Sending interuser echo...'); | ||
| ws.send(JSON.stringify({ action: 'interuser', sessionid: data.sessionid, data: 'ECHO: ' + data.data })); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ ws.send() call in meshbot.js interuser echo path not wrapped in try/catch In the 'interuser' case handler of the ws.on('message', ...) callback in serverConnect(), wrapped the ws.send() echo call in a try/catch block with an empty catch, matching the suggested fix exactly. π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| try { ws.send(JSON.stringify({ action: 'interuser', sessionid: data.sessionid, data: 'ECHO: ' + data.data })); } catch (ex) { } | ||
| } | ||
| break; | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us | |
| obj.req = req; // Used in multi-server.js | ||
| obj.id = req.query.id; | ||
| obj.file = req.query.f; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π obj.file from req.query.f is used unchecked in file relay without a '..' guard Added a guard right after π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
| if ((obj.file != null) && (obj.file.indexOf('..') >= 0)) { obj.file = null; } | ||
|
|
||
| // Check relay authentication | ||
| if ((user == null) && (obj.req.query != null) && (obj.req.query.rauth != null)) { | ||
|
|
@@ -58,8 +59,8 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us | |
| // Disconnect | ||
| obj.close = function (arg) { | ||
| if (obj.ws != null) { | ||
| if ((arg == 1) || (arg == null)) { try { obj.ws.close(); parent.parent.debug('relay', 'FileRelay: Soft disconnect (' + obj.req.clientIp + ')'); } catch (ex) { console.log(e); } } // Soft close, close the websocket | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ ws.send() call to agent bypasses try/catch in performRelay In obj.close() (top of file), the two catch blocks π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ console.log(e) references undefined variable in multiple catch(ex) blocks in closeBothSides In closeBothSides(), the peer disconnect block π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| if (arg == 2) { try { obj.ws._socket._parent.end(); parent.parent.debug('relay', 'FileRelay: Hard disconnect (' + obj.req.clientIp + ')'); } catch (ex) { console.log(e); } } // Hard close, close the TCP socket | ||
| if ((arg == 1) || (arg == null)) { try { obj.ws.close(); parent.parent.debug('relay', 'FileRelay: Soft disconnect (' + obj.req.clientIp + ')'); } catch (ex) { console.log(ex); } } // Soft close, close the websocket | ||
| if (arg == 2) { try { obj.ws._socket._parent.end(); parent.parent.debug('relay', 'FileRelay: Hard disconnect (' + obj.req.clientIp + ')'); } catch (ex) { console.log(ex); } } // Hard close, close the TCP socket | ||
| } else if (obj.res != null) { | ||
| try { res.sendStatus(404); } catch (ex) { } | ||
| } | ||
|
|
@@ -132,7 +133,7 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us | |
|
|
||
| // Check that at least one connection is authenticated | ||
| if ((obj.authenticated != true) && (relayinfo.peer1.authenticated != true)) { | ||
| if (ws) { ws.close(); } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π Undefined 'ws' identifier referenced instead of 'obj.ws' in performRelay In performRelay(), the auth-failure branch π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| if (obj.ws) { obj.ws.close(); } | ||
| parent.parent.debug('relay', 'FileRelay without-auth: ' + obj.id + ' (' + obj.req.clientIp + ')'); | ||
| delete obj.id; | ||
| delete obj.ws; | ||
|
|
@@ -256,7 +257,7 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us | |
| // Disconnect the peer | ||
| try { if (peer.relaySessionCounted) { parent.relaySessionCount--; delete peer.relaySessionCounted; } } catch (ex) { console.log(ex); } | ||
| parent.parent.debug('relay', 'FileRelay disconnect: ' + obj.id + ' (' + obj.req.clientIp + ' --> ' + peer.req.clientIp + ')'); | ||
| if (peer.ws) { try { peer.ws.close(); } catch (e) { } try { peer.ws._socket._parent.end(); } catch (e) { } } | ||
| if (peer.ws) { try { peer.ws.close(); } catch (ex) { console.log(ex); } try { peer.ws._socket._parent.end(); } catch (ex) { console.log(ex); } } | ||
| if (peer.res) { try { peer.res.end(); } catch (ex) { } } | ||
|
|
||
| // Aggressive peer cleanup | ||
|
|
@@ -310,3 +311,4 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us | |
| performRelay(); | ||
| return obj; | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ | |
| self.mouseNagleData = ['mouse', e.clientX - rect.left, e.clientY - rect.top, 0, false]; | ||
| if (self.mouseNagleTimer == null) { | ||
| //console.log('sending', self.mouseNagleData); | ||
| self.mouseNagleTimer = setTimeout(function () { self.socket.send(JSON.stringify(self.mouseNagleData)); self.mouseNagleTimer = null; }, 50); | ||
| self.mouseNagleTimer = setTimeout(function () { try { self.socket.send(JSON.stringify(self.mouseNagleData)); } catch (ex) { } self.mouseNagleTimer = null; }, 50); | ||
| } | ||
| //self.socket.send(JSON.stringify(this.mouseNagleData)); | ||
| e.preventDefault(); | ||
|
|
@@ -79,23 +79,23 @@ | |
| if (!self.socket || !self.activeSession) return; | ||
| if (self.mouseNagleTimer != null) { clearTimeout(self.mouseNagleTimer); self.mouseNagleTimer = null; } | ||
| var rect = e.target.getBoundingClientRect(); | ||
| self.socket.send(JSON.stringify(['mouse', e.clientX - rect.left, e.clientY - rect.top, mouseButtonMap(e.button), true])); | ||
| try { self.socket.send(JSON.stringify(['mouse', e.clientX - rect.left, e.clientY - rect.top, mouseButtonMap(e.button), true])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
| this.canvas.addEventListener('mouseup', function (e) { | ||
| if (!self.socket || !self.activeSession) return; | ||
| if (self.mouseNagleTimer != null) { clearTimeout(self.mouseNagleTimer); self.mouseNagleTimer = null; } | ||
| var rect = e.target.getBoundingClientRect(); | ||
| self.socket.send(JSON.stringify(['mouse', e.clientX - rect.left, e.clientY - rect.top, mouseButtonMap(e.button), false])); | ||
| try { self.socket.send(JSON.stringify(['mouse', e.clientX - rect.left, e.clientY - rect.top, mouseButtonMap(e.button), false])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
| this.canvas.addEventListener('contextmenu', function (e) { | ||
| if (!self.socket || !self.activeSession) return; | ||
| if (self.mouseNagleTimer != null) { clearTimeout(self.mouseNagleTimer); self.mouseNagleTimer = null; } | ||
| var rect = e.target.getBoundingClientRect(); | ||
| self.socket.send(JSON.stringify(['mouse', e.clientX - rect.left, e.clientY - rect.top, mouseButtonMap(e.button), false])); | ||
| try { self.socket.send(JSON.stringify(['mouse', e.clientX - rect.left, e.clientY - rect.top, mouseButtonMap(e.button), false])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
|
|
@@ -109,7 +109,7 @@ | |
| var step = 128; | ||
| //console.log('DOMMouseScroll', delta, step, e.detail); | ||
| var rect = e.target.getBoundingClientRect(); | ||
| self.socket.send(JSON.stringify(['wheel', e.clientX - rect.left, e.clientY - rect.top, step, delta > 0, isHorizontal])); | ||
| try { self.socket.send(JSON.stringify(['wheel', e.clientX - rect.left, e.clientY - rect.top, step, delta > 0, isHorizontal])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
|
|
@@ -122,21 +122,21 @@ | |
| var step = 128; | ||
| //console.log('mousewheel', delta, step, e); | ||
| var rect = e.target.getBoundingClientRect(); | ||
| self.socket.send(JSON.stringify(['wheel', e.clientX - rect.left, e.clientY - rect.top, step, delta > 0, isHorizontal])); | ||
| try { self.socket.send(JSON.stringify(['wheel', e.clientX - rect.left, e.clientY - rect.top, step, delta > 0, isHorizontal])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
|
|
||
| // Bind keyboard event | ||
| window.addEventListener('keydown', function (e) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ ws.send() calls in mstsc client unwrapped in try/catch Wrapped every π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| if (!self.socket || !self.activeSession) return; | ||
| self.socket.send(JSON.stringify(['scancode', Mstsc.scancode(e), true])); | ||
| try { self.socket.send(JSON.stringify(['scancode', Mstsc.scancode(e), true])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
| window.addEventListener('keyup', function (e) { | ||
| if (!self.socket || !self.activeSession) return; | ||
| self.socket.send(JSON.stringify(['scancode', Mstsc.scancode(e), false])); | ||
| try { self.socket.send(JSON.stringify(['scancode', Mstsc.scancode(e), false])); } catch (ex) { } | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
|
|
@@ -164,19 +164,21 @@ | |
| this.socket.binaryType = 'arraybuffer'; | ||
| this.socket.onopen = function () { | ||
| //console.log("WS-OPEN"); | ||
| self.socket.send(JSON.stringify(['infos', { | ||
| ip: ip, | ||
| port: 3389, | ||
| screen: { | ||
| width: self.canvas.width, | ||
| height: self.canvas.height | ||
| }, | ||
| domain: domain, | ||
| username: username, | ||
| password: password, | ||
| options: options, | ||
| locale: Mstsc.locale() | ||
| }])); | ||
| try { | ||
| self.socket.send(JSON.stringify(['infos', { | ||
| ip: ip, | ||
| port: 3389, | ||
| screen: { | ||
| width: self.canvas.width, | ||
| height: self.canvas.height | ||
| }, | ||
| domain: domain, | ||
| username: username, | ||
| password: password, | ||
| options: options, | ||
| locale: Mstsc.locale() | ||
| }])); | ||
| } catch (ex) { } | ||
| self.prevClipboardText = null; | ||
| self.clipboardReadTimer = setInterval(function(){ | ||
| if(navigator.clipboard.readText != null){ | ||
|
|
@@ -185,7 +187,7 @@ | |
| .then(function(data){ | ||
| if(data != self.prevClipboard){ | ||
| self.prevClipboard = data; | ||
| if (self.socket) { self.socket.send(JSON.stringify(['clipboard', data])); } | ||
| if (self.socket) { try { self.socket.send(JSON.stringify(['clipboard', data])); } catch (ex) { } } | ||
| } | ||
| }) | ||
| .catch(function(){ }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π IDER module's obj.SendCommand calls parent.xxSend without try/catch guard around transport write
In
obj.SendCommand(amt/amt-ider-module.js), wrapped the transport writeobj.parent.xxSend(x);in atry { ... } catch (ex) { }block, matching the codebase-wide convention (MESHCENT-002/002-2) of guarding ws.send-equivalent transport writes so that an exception from a closed/proxied socket does not propagate uncaught through the IDER command pipeline.obj.bytesToAmt += x.length;remains outside the try block so byte accounting is unaffected by the change, consistent with existing behavior.π€ Prompt for AI agents
fix confidence: π’ 92 high β react π/π to teach the reviewer