-
Notifications
You must be signed in to change notification settings - Fork 1
fix(adhoc-sweep-fixes): CU-86akdypw4 16 review findings across 16 files #166
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
2935d79
0e6b0a3
cf0b72b
0ec77e0
ca53f81
18494df
f7fa3d4
0d04c7e
6790b4a
639d788
0f45895
58fc1a2
7379487
edfaad0
952fe07
4b3e602
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 |
|---|---|---|
|
|
@@ -126,6 +126,29 @@ function ConfigureAgent(agent) | |
| } | ||
| } | ||
|
|
||
| function validateDownloadedBinary(path) | ||
| { | ||
| try | ||
| { | ||
| var stat = require('fs').statSync(path); | ||
| if (stat == null || stat.size <= 0) | ||
| { | ||
| return (false); | ||
| } | ||
| // Verify the downloaded file is a valid, signed executable before it is | ||
| // registered as a privileged system service. | ||
| if (require('MeshAgent').isSignatureValid != null) | ||
| { | ||
| return (require('MeshAgent').isSignatureValid(path) ? true : false); | ||
| } | ||
| return (true); | ||
| } | ||
| catch (e) | ||
| { | ||
| return (false); | ||
| } | ||
| } | ||
|
|
||
| function start() | ||
| { | ||
| sendServerLog('Diagnostic: Start'); | ||
|
Comment on lines
126
to
154
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. 🦩 🟠 meshcore_diagnostic.js downloads and installs an agent binary without validating it before granting it a service, and cleans up asynchronously without confirming service creation succeeded In 🤖 Prompt for AI agentsfix confidence: 🔴 35 low — review closely — react 👍/👎 to teach the reviewer |
||
|
|
@@ -139,6 +162,13 @@ function start() | |
| // SUCCESS | ||
| try | ||
| { | ||
| if (!validateDownloadedBinary('agent_temporary.bin')) | ||
| { | ||
| sendServerLog('Diagnostic: Downloaded agent binary failed validation'); | ||
| try { require('fs').unlinkSync('agent_temporary.bin'); } catch (e2) { } | ||
| giveup(); | ||
| return; | ||
| } | ||
| var agent = require('service-manager').manager.installService( | ||
| { | ||
| name: process.platform == 'win32' ? 'Mesh Agent' : 'meshagent', | ||
|
|
@@ -148,8 +178,14 @@ function start() | |
| servicePath: 'agent_temporary.bin', | ||
| startType: 'DEMAND_START' | ||
| }); | ||
| require('fs').unlinkSync('agent_temporary.bin'); | ||
| if (agent == null) | ||
| { | ||
| try { require('fs').unlinkSync('agent_temporary.bin'); } catch (e3) { } | ||
| giveup(); | ||
| return; | ||
| } | ||
| ConfigureAgent(agent); | ||
| require('fs').unlinkSync('agent_temporary.bin'); | ||
| } | ||
| catch(e) | ||
| { | ||
|
|
@@ -185,6 +221,12 @@ function start() | |
| DownloadAgentBinary(s.appLocation()).then( | ||
| function () { | ||
| sendServerLog('Diagnostic: Downloaded Successfully'); | ||
| if (!validateDownloadedBinary(s.appLocation())) | ||
| { | ||
| sendServerLog('Diagnostic: Downloaded agent binary failed validation'); | ||
| giveup(); | ||
| return; | ||
| } | ||
| sendServerLog('Diagnostic: Attempting to start Mesh Agent'); | ||
| s.start(); | ||
| sendServerLog('Diagnostic: ' + (s.isRunning() ? '(SUCCESS)' : '(FAILED)')); | ||
|
|
@@ -204,3 +246,4 @@ function start() | |
| } | ||
| } | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,7 +144,7 @@ function CreateAPFClient(parent, args) { | |
| obj.onSecureConnect = function onSecureConnect(resp, ws, head) { | ||
| Debug("APF Secure WebSocket connected."); | ||
| //console.log(JSON.stringify(resp)); | ||
| obj.forwardClient.tag = { accumulator: [] }; | ||
|
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-apfclient.js accumulator uses += on array/string mismatch (tag.accumulator initialized as array, appended as string) In 🤖 Prompt for AI agentsfix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer |
||
| obj.forwardClient.tag = { accumulator: '' }; | ||
| obj.forwardClient.ws = ws; | ||
| obj.forwardClient.ws.on('end', function () { | ||
| Debug("APF: Connection is closing."); | ||
|
|
@@ -456,4 +456,4 @@ function CreateAPFClient(parent, args) { | |
| return obj; | ||
| } | ||
|
|
||
| module.exports = CreateAPFClient; | ||
| module.exports = CreateAPFClient; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,7 +161,7 @@ function amt_heci() | |
|
|
||
| // Fill the left with zeros until the string is of a given length | ||
| function zeroLeftPad(str, len) { | ||
|
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-mei.js zeroLeftPad has broken guard logic due to operator precedence, allowing null length to bypass early return In 🤖 Prompt for AI agentsfix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer |
||
| if ((len == null) && (typeof (len) != 'number')) { return null; } | ||
| if ((len == null) || (typeof (len) != 'number')) { return null; } | ||
| if (str == null) str = ''; // If null, this is to generate zero leftpad string | ||
| var zlp = ''; | ||
| for (var i = 0; i < len - str.length; i++) { zlp += '0'; } | ||
|
|
@@ -496,4 +496,4 @@ AMT_STATUS_RNG_NOT_READY = 48, | |
| AMT_STATUS_CERTIFICATE_NOT_READY = 49, | ||
| AMT_STATUS_INVALID_HANDLE = 2053 | ||
| AMT_STATUS_NOT_FOUND = 2068, | ||
| */ | ||
| */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,10 +89,10 @@ function linux_identifiers() | |
| } | ||
| } catch (xx) { } | ||
| } else { | ||
| throw('Unknown board'); | ||
|
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. 🦩 🟠 linux_identifiers() throws bare strings instead of Error objects In 🤖 Prompt for AI agentsfix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer |
||
| throw (new Error('Unknown board')); | ||
| } | ||
| } else { | ||
| throw ('this platform does not have DMI statistics'); | ||
| throw (new Error('this platform does not have DMI statistics')); | ||
| } | ||
| } else { | ||
| var entries = require('fs').readdirSync('/sys/class/dmi/id'); | ||
|
|
@@ -900,3 +900,4 @@ module.exports.isVM = function isVM() | |
| // board_serial = BASEBOARD->SerialNumber = ioreg/serial-number | ioreg/IOPlatformSerialNumber | ||
| // board_vendor = BASEBOARD->Manufacturer = ioreg/manufacturer | ||
| // board_version = BASEBOARD->Version | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,13 +110,6 @@ function parseUrl(url) { | |
| sha256.write('bob'); | ||
| sha256.end(); | ||
| } | ||
| { | ||
|
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. 🦩 🔵 agents/testsuite.js contains a duplicate/dead SHA256Stream test block explicitly marked FAIL Removed the duplicate, known-broken SHA256Stream test block (the 🤖 Prompt for AI agentsfix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer |
||
| // FAIL!!!!!!!!! | ||
| var sha256x = require('SHA256Stream'); | ||
| sha256x.hashString = function (x) { if (x == '81B637D8FCD2C6DA6359E6963113A1170DE795E4B725B84D1E0B4CFD9EC58CE9') { console.log('Test 1 - OK: ' + x); } else { console.log('Test 1 - FAIL: ' + x); } }; | ||
| sha256x.write('bob'); | ||
| sha256x.end(); | ||
| } | ||
|
|
||
| /* | ||
| { | ||
|
|
@@ -154,4 +147,4 @@ function parseUrl(url) { | |
| } | ||
|
|
||
| console.log('--- Tests Completed ---'); | ||
| process.exit(2); | ||
| process.exit(2); | ||
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.
🦩 🟠 sync-upstream.yml grants contents:write and pulls arbitrary upstream commits into an auto-created PR without integrity verification
In the
Syncstep of thesyncjob, appended an explicit warning to the auto-generated PR body (gh pr create ... --body) stating the PR contains unreviewed third-party upstream history and requires maintainer review/approval before merging, and instructing not to enable auto-merge. This is a lightweight mitigation that increases reviewer awareness but does NOT technically enforce a review gate (e.g., branch protection requiring approvals, CODEOWNERS, or blocking auto-merge) and does NOT pin/verify upstream provenance (no commit signature check, no allow-listed tag/commit range — the workflow still doesgit fetch upstream masterand merges the movingmasterbranch directly). A complete fix would additionally require: (a) branch protection rules on the target branch requiring human approval before merge (configured outside this file, in repo settings), (b) switching from trackingupstream/masterto a pinned, manually-reviewed tag/commit SHA that's bumped deliberately, and/or (c) verifying upstream commit signatures (e.g.,git verify-commit) before merging. These are out of scope for a single-file workflow YAML change without redesigning the sync strategy, so this fix only reduces — not eliminates — the risk described in the finding.🤖 Prompt for AI agents
fix confidence: 🔴 45 low — review closely — react 👍/👎 to teach the reviewer