Skip to content

fix(adhoc-sweep-fixes): 4 review findings across 4 files - #150

Draft
flamingo[bot] wants to merge 4 commits into
masterfrom
ai-fix/adhoc-sweep-fixes-2cfbf682-6542cba8
Draft

fix(adhoc-sweep-fixes): 4 review findings across 4 files#150
flamingo[bot] wants to merge 4 commits into
masterfrom
ai-fix/adhoc-sweep-fixes-2cfbf682-6542cba8

Conversation

@flamingo

@flamingo flamingo Bot commented Aug 24, 2026

Copy link
Copy Markdown

Closes 4 review findings across 4 files.

Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.

# Fix confidence Finding Location
1 🟢 98 high SerialTunnel _write handler references undefined console.err instead of console.error amt/amt-redir-mesh.js:78
2 🟡 65 medium amt-xml.js _PutObjToBodyXml references undefined global 'obj' amt/amt-xml.js:82
3 🔴 55 low — review closely meshscanner.js obj.start() references undefined variables domain and req when building title2 placeholder replacements meshscanner.js:176
4 🟢 90 high Clipboard variable name mismatch: prevClipboardText vs prevClipboard causes stale comparisons public/mstsc/client.js:181

What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.


Run: https://product-hub.flamingo.so/admin/code-review
Run id: 6542cba8-5031-4f6a-9825-da6bc2c6e58e

Merging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.

@flamingo flamingo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 What this fix changed, finding by finding

4 finding(s) fixed in this draft — 4 explained inline on the diff; 1 low-confidence hunk(s) need close review before merging.

Comment thread amt/amt-redir-mesh.js
Comment on lines 81 to 87
var obj = new require('stream').Duplex(options);
obj.forwardwrite = null;
obj.updateBuffer = function (chunk) { this.push(chunk); };
obj._write = function (chunk, encoding, callback) { if (obj.forwardwrite != null) { obj.forwardwrite(chunk); } else { console.err('Failed to fwd _write.'); } if (callback) callback(); }; // Pass data written to forward
obj._write = function (chunk, encoding, callback) { if (obj.forwardwrite != null) { obj.forwardwrite(chunk); } else { console.error('Failed to fwd _write.'); } if (callback) callback(); }; // Pass data written to forward
obj._read = function (size) { }; // Push nothing, anything to read should be pushed from updateBuffer()
return obj;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 SerialTunnel _write handler references undefined console.err instead of console.error

In the SerialTunnel function's obj._write implementation, replaced the invalid console.err('Failed to fwd _write.') call with console.error('Failed to fwd _write.'), fixing the undefined-method TypeError that would occur when obj.forwardwrite is null during a stream write.

🤖 Prompt for AI agents
In amt/amt-redir-mesh.js around line 78, review and complete this code-review fix: SerialTunnel _write handler references undefined console.err instead of console.error.
What the draft fix changed: In the `SerialTunnel` function's `obj._write` implementation, replaced the invalid `console.err('Failed to fwd _write.')` call with `console.error('Failed to fwd _write.')`, fixing the undefined-method TypeError that would occur when `obj.forwardwrite` is null during a stream write.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 98 high — react 👍/👎 to teach the reviewer

Comment thread amt/amt-xml.js
}

function _PutObjToBodyXml(resuri, putObj) {
if (!resuri || putObj == null) return '';

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 amt-xml.js _PutObjToBodyXml references undefined global 'obj'

In _PutObjToBodyXml (amt/amt-xml.js), replaced the undefined-global reference obj.GetNameFromUrl(resuri) with a call to a new local helper function _GetNameFromUrl(url) defined just above it, which extracts the substring after the last / in the URL (mirroring the typical behavior implied by the original call name). This removes the ReferenceError since obj no longer needs to exist in module scope. Risk: the exact semantics of the original intended obj.GetNameFromUrl (e.g., handling of trailing slashes, namespace prefixes, or special URI formats) are not verifiable from this file alone; if callers depended on more elaborate parsing logic (such as one matching a WSMAN resource URI schema used elsewhere in the codebase), this simple implementation may not be fully equivalent and should be cross-checked against any existing "GetNameFromUrl" utility elsewhere in the project.

🤖 Prompt for AI agents
In amt/amt-xml.js around line 82, review and complete this code-review fix: amt-xml.js _PutObjToBodyXml references undefined global 'obj'.
What the draft fix changed: In `_PutObjToBodyXml` (amt/amt-xml.js), replaced the undefined-global reference `obj.GetNameFromUrl(resuri)` with a call to a new local helper function `_GetNameFromUrl(url)` defined just above it, which extracts the substring after the last `/` in the URL (mirroring the typical behavior implied by the original call name). This removes the ReferenceError since `obj` no longer needs to exist in module scope. Risk: the exact semantics of the original intended `obj.GetNameFromUrl` (e.g., handling of trailing slashes, namespace prefixes, or special URI formats) are not verifiable from this file alone; if callers depended on more elaborate parsing logic (such as one matching a WSMAN resource URI schema used elsewhere in the codebase), this simple implementation may not be fully equivalent and should be cross-checked against any existing "GetNameFromUrl" utility elsewhere in the project.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 65 medium — react 👍/👎 to teach the reviewer

Comment thread meshscanner.js
Comment on lines 166 to 172
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': obj.getWebServerName(obj.parent.config.domains[''], null),
'agentsessions': Object.keys(parent.webserver.wsagents).length,
'connectedusers': Object.keys(parent.webserver.wssessions).length,
'userssessions': Object.keys(parent.webserver.wssessions2).length,

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 meshscanner.js obj.start() references undefined variables domain and req when building title2 placeholder replacements

In obj.start(), replaced the undefined domain and req references passed to obj.getWebServerName(domain, req) with obj.getWebServerName(obj.parent.config.domains[''], null). This uses the domain object already being read in this scope (obj.parent.config.domains['']) in place of the undefined domain variable, and passes null for req since no HTTP request object exists in this context. This eliminates the ReferenceError so title2 placeholder replacement no longer silently fails. Risk: obj.getWebServerName's actual signature and behavior when req is null are not visible in this file, so it's unverified whether null is handled gracefully inside that function (e.g., if it accesses req.headers unconditionally) — a complete fix would require inspecting getWebServerName's implementation elsewhere to confirm it tolerates a null request.

🤖 Prompt for AI agents
In meshscanner.js around line 176, review and complete this code-review fix: meshscanner.js obj.start() references undefined variables domain and req when building title2 placeholder replacements.
What the draft fix changed: In `obj.start()`, replaced the undefined `domain` and `req` references passed to `obj.getWebServerName(domain, req)` with `obj.getWebServerName(obj.parent.config.domains[''], null)`. This uses the domain object already being read in this scope (`obj.parent.config.domains['']`) in place of the undefined `domain` variable, and passes `null` for `req` since no HTTP request object exists in this context. This eliminates the ReferenceError so `title2` placeholder replacement no longer silently fails. Risk: `obj.getWebServerName`'s actual signature and behavior when `req` is `null` are not visible in this file, so it's unverified whether `null` is handled gracefully inside that function (e.g., if it accesses `req.headers` unconditionally) — a complete fix would require inspecting `getWebServerName`'s implementation elsewhere to confirm it tolerates a null request.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer

Comment thread public/mstsc/client.js
Comment on lines 183 to 190
if (Mstsc.browser() == 'firefox') return; // this is needed because firefox pops up a PASTE option every second which is annoying
navigator.clipboard.readText()
.then(function(data){
if(data != self.prevClipboard){
self.prevClipboard = data;
if(data != self.prevClipboardText){
self.prevClipboardText = data;
if (self.socket) { self.socket.send(JSON.stringify(['clipboard', data])); }
}
})

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 Clipboard variable name mismatch: prevClipboardText vs prevClipboard causes stale comparisons

In Client.prototype.connect, within the onopen handler's clipboardReadTimer interval callback, renamed the two self.prevClipboard references (the comparison if(data != self.prevClipboard) and assignment self.prevClipboard = data;) to self.prevClipboardText, matching the initialization in onopen and the reset in onclose. This unifies the property name so the clipboard-change comparison correctly persists across polling intervals.

🤖 Prompt for AI agents
In public/mstsc/client.js around line 181, review and complete this code-review fix: Clipboard variable name mismatch: prevClipboardText vs prevClipboard causes stale comparisons.
What the draft fix changed: In `Client.prototype.connect`, within the `onopen` handler's `clipboardReadTimer` interval callback, renamed the two `self.prevClipboard` references (the comparison `if(data != self.prevClipboard)` and assignment `self.prevClipboard = data;`) to `self.prevClipboardText`, matching the initialization in `onopen` and the reset in `onclose`. This unifies the property name so the clipboard-change comparison correctly persists across polling intervals.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants