Skip to content

fixes for external use#40

Merged
jomosh merged 4 commits into
mainfrom
UI-readiness
May 26, 2026
Merged

fixes for external use#40
jomosh merged 4 commits into
mainfrom
UI-readiness

Conversation

@jomosh
Copy link
Copy Markdown
Owner

@jomosh jomosh commented May 26, 2026

Fixes to Blah2 UI so it can be exposed externally

Copilot AI review requested due to automatic review settings May 26, 2026 20:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to make the Blah2 UI safer/more usable when accessed externally by preserving API-targeting query parameters across UI navigation and adding a network-based restriction to the capture toggle endpoint in the Node API bridge.

Changes:

  • Add api_base / api_port query forwarding to non-API UI links so navigation preserves the selected API target.
  • Restrict /capture/toggle to localhost/RFC1918 source IPs via a new is_local_ip() helper.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
html/js/common.js Forwards api_base/api_port query params to internal UI navigation links.
api/server.js Adds local-network gating for /capture/toggle using an IP allowlist check.

Comment thread html/js/common.js Outdated
Comment on lines +119 to +123
const params = new URLSearchParams();
if (apiBase) {
params.set('api_base', apiBase);
} else if (apiPort) {
params.set('api_port', apiPort);
Comment thread api/server.js
Comment on lines +124 to +132
function is_local_ip(ip) {
const addr = ip.startsWith('::ffff:') ? ip.slice(7) : ip;
if (addr === '127.0.0.1' || addr === '::1') return true;
const parts = addr.split('.').map(Number);
if (parts.length !== 4 || parts.some(p => isNaN(p))) return false;
if (parts[0] === 10) return true;
if (parts[0] === 172 && parts[1] >= 16 && parts[1] <= 31) return true;
if (parts[0] === 192 && parts[1] === 168) return true;
return false;
Comment thread api/server.js
Comment on lines 140 to +143
app.get('/capture/toggle', (req, res) => {
if (!is_local_ip(req.socket.remoteAddress)) {
res.status(403).end();
return;
Comment thread api/server.js
Comment on lines +139 to 147
// toggle state of capture — localhost and RFC1918 only
app.get('/capture/toggle', (req, res) => {
if (!is_local_ip(req.socket.remoteAddress)) {
res.status(403).end();
return;
}
capture = !capture;
res.send('{}');
});
@jomosh
Copy link
Copy Markdown
Owner Author

jomosh commented May 26, 2026

@copilot fixes have been made after your latest review. asses and re-run your review. don't fix anything, just let me know

Copy link
Copy Markdown

Copilot AI commented May 26, 2026

@copilot fixes have been made after your latest review. asses and re-run your review. don't fix anything, just let me know

I re-reviewed the current branch. The loopback-range handling and the api_port forwarding fix look good, but I still see one code issue in html/js/common.js: get_api_forward_params() validates with sanitize_api_base(apiBase) and then forwards the original apiBase instead of sanitizedApiBase, so unsanitized input can still be propagated. I didn’t make any changes.

Copilot finished work on behalf of jomosh May 26, 2026 21:17
@jomosh
Copy link
Copy Markdown
Owner Author

jomosh commented May 26, 2026

@copilot fixes have been made after your latest review. asses and re-run your review. don't fix anything, just let me know

Copy link
Copy Markdown

Copilot AI commented May 26, 2026

@copilot fixes have been made after your latest review. asses and re-run your review. don't fix anything, just let me know

I re-ran the review on the current branch and I’m not seeing any remaining blocking issues in the changes I previously flagged. The latest completed workflow runs on UI-readiness are green; the newest runs are still in progress.

Copilot finished work on behalf of jomosh May 26, 2026 21:23
@jomosh
Copy link
Copy Markdown
Owner Author

jomosh commented May 26, 2026

@copilot fixes have been made after a code review. asses and re-run your review. don't fix anything, just let me know

Copy link
Copy Markdown

Copilot AI commented May 26, 2026

@copilot fixes have been made after a code review. asses and re-run your review. don't fix anything, just let me know

I re-ran the review on the latest branch state and I’m not seeing any remaining blocking issues in the changes I previously flagged. The latest follow-up fixes look correct.

Copilot finished work on behalf of jomosh May 26, 2026 21:31
@jomosh jomosh merged commit 3b1e299 into main May 26, 2026
2 checks passed
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.

3 participants