-
Notifications
You must be signed in to change notification settings - Fork 1
fix(adhoc-sweep-fixes): CU-86akdypw4 36 review findings across 19 files #165
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
d53ba18
1d4ec6d
feba40d
e5b0138
4e8d02e
7d6eb54
2cbc35e
2d3da8e
29e7329
1c9868d
2bd9f00
c4273c6
295f8e7
d68ff99
6e5667c
4cc5a00
d23cbc8
4997516
1b4ab9c
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 |
|---|---|---|
|
|
@@ -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': { | ||
|
Comment on lines
255
to
266
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. 𦩠π AddCommandHandler switch on data.action in agentrecoverycore.js lacks a default case logging unknown actions In π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
|
|
@@ -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); | ||
| } | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,7 +155,7 @@ function lme_heci(options) { | |
| break; | ||
| case APF_SERVICE_REQUEST: | ||
|
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. 𦩠π amt-lme.js compares Buffer to string with == instead of comparing strings, name check will always be false In the APF_SERVICE_REQUEST case handler, changed π€ Prompt for AI agentsfix confidence: π‘ 65 medium β react π/π to teach the reviewer |
||
| 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) | ||
|
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.info1 is not a standard console method β likely a typo causing a runtime TypeError In the APF_GLOBAL_REQUEST 'tcpip-forward' catch block (inside π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| { | ||
| console.info1(ex, 'Port ' + port); | ||
| console.info(ex, 'Port ' + port); | ||
| if(!this._emitConnected) | ||
| { | ||
| this._emitConnected = true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,9 @@ function AMTScanner() { | |
| if (masknum <= 16 || masknum > 32) return null; | ||
|
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. 𦩠π amt-scanner.js: incorrect min bound off-by-one and dead variable in parseIPv4Range CIDR branch Fixed the off-by-one/dead-min-max-bound bug in π€ Prompt for AI agentsfix confidence: π‘ 70 medium β react π/π to teach the reviewer |
||
| 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); }); | ||
|
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. 𦩠π΅ amt-scanner.js: server.on('error') handler only logs, never invokes callback β scan hangs on socket error Updated the π€ Prompt for AI agentsfix confidence: π΄ 40 low β review closely β react π/π to teach the reviewer |
||
| 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)); } }); | ||
|
Comment on lines
91
to
105
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. 𦩠π amt-scanner.js scan() uses Removed the no-op π€ Prompt for AI agentsfix confidence: π‘ 60 medium β react π/π to teach the reviewer |
||
|
|
@@ -101,7 +111,7 @@ function AMTScanner() { | |
| callback(server.scanResults); | ||
| } | ||
| server.parent.emit('found', server.scanResults); | ||
| delete server; | ||
| server = null; | ||
| }, timeout); | ||
| }; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { } | ||
|
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. 𦩠π smbios.js lacks jshint directives and 'use strict' header Added jshint/jslint directive comments ( π€ Prompt for AI agentsfix confidence: π‘ 60 medium β react π/π to teach the reviewer |
||
| 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) | ||
|
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. 𦩠π amtInfo() dereferences data[131] without checking it exists, causing a possible crash In amtInfo() (agents/modules_meshcmd/smbios.js), changed π€ Prompt for AI agentsfix confidence: π’ 92 high β react π/π to teach the reviewer |
||
| { | ||
| 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(); | ||
| module.exports = new SMBiosTables(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(); | ||
|
|
||
|
Comment on lines
201
to
208
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. 𦩠π macos_memUtilization returns undefined instead of the expected promise on the happy path In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer
Comment on lines
201
to
208
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. 𦩠π child_process stdout accumulation missing for macos_memUtilization stderr stream In π€ Prompt for AI agentsfix confidence: π‘ 80 medium β react π/π to teach the reviewer |
||
|
|
@@ -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]; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
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. 𦩠π΅ SerialTunnel helper duplicated verbatim between amt-redir-mesh.js and apprelays.js Added a one-line TODO comment above the π€ Prompt for AI agentsfix confidence: π΄ 40 low β review closely β react π/π to teach the reviewer |
||
| 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(); | ||
|
Comment on lines
227
to
236
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. 𦩠π AMT device blocklist check missing before establishing direct TLS connection with rejectUnauthorized: false In π€ Prompt for AI agentsfix confidence: π΄ 30 low β review closely β react π/π to teach the reviewer |
||
|
|
@@ -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)); } | ||
|
|
||
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.
𦩠π fs.mkdirSync / fs.closeSync(fs.openSync) calls in recovery-console file-command handler are unguarded and will throw on failure
In the tunnel data handler's inner
switch (cmd.action)(insideAddCommandHandler's upgrade/data callback), themkdircase now wrapsfs.mkdirSync(cmd.path)in try/catch reporting{action:'mkdirerror'}, and themkfilecase wrapsfs.closeSync(fs.openSync(cmd.path,'w'))in try/catch reporting{action:'mkfileerror'}, matching the pattern used by the siblinguploadcase'suploaderrorhandling.π€ Prompt for AI agents
fix confidence: π’ 90 high β react π/π to teach the reviewer