Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review: reject non-http(s) protocols, empty hosts, custom ports in parsePullRequestUrl
Adam Eivy4dd036f5226d
diff --git a/server/services/git.js b/server/services/git.jsindex fecedd7404..bb60bf79d0 100644--- a/server/services/git.js+++ b/server/services/git.js@@ -496,9 +496,21 @@ export function parsePullRequestUrl(url) {// request handlers, not URL validation helpers).try { parsed = new URL(url); } catch { return null; }- // Use hostname (no port) — `gh api --hostname` expects a bare hostname and- // chokes on host:port. We don't currently support custom-port forges, but if- // we ever do, the port should be plumbed through a separate field.+ // Only forge web URLs are valid input — reject file://, ftp://, javascript:,+ // etc., which can otherwise sneak through to downstream `gh api --hostname`+ // or `glab` calls with a misleading or empty host.+ if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;++ // `new URL` accepts `https:///path` and `http://:8080/...` — both yield an+ // empty hostname. Reject those: a host-less PR URL is meaningless.+ if (!parsed.hostname) return null;++ // Reject explicit ports (`https://github.com:8443/...`). We use+ // `parsed.hostname` below (not `host`), so a custom port would be silently+ // dropped and route the request to the wrong server. Custom-port forges+ // aren't supported until the port is plumbed through a separate field.+ if (parsed.port) return null;+const host = parsed.hostname;const segments = parsed.pathname.split('/').filter(Boolean);diff --git a/server/services/git.test.js b/server/services/git.test.jsindex 0b7c2b12e4..29a6c82f26 100644--- a/server/services/git.test.js+++ b/server/services/git.test.js@@ -172,6 +172,18 @@ describe('parsePullRequestUrl', () => {expect(parsePullRequestUrl('https://github.com/owner/repo/extra/pull/1')).toBeNull();expect(parsePullRequestUrl('https://github.com/owner/repo/extra/more/pull/1')).toBeNull();});++ it('rejects non-http(s) protocols, empty hosts, and explicit ports', () => {+ // file:// has an empty host — would yield host="" and route gh to nowhere.+ expect(parsePullRequestUrl('file:///atomantic/PortOS/pull/1')).toBeNull();+ // Other non-web schemes are never valid PR URLs.+ expect(parsePullRequestUrl('ftp://github.com/atomantic/PortOS/pull/1')).toBeNull();+ expect(parsePullRequestUrl('javascript:alert(1)')).toBeNull();+ // Custom ports get silently dropped by `parsed.hostname`; reject so we+ // don't target the wrong server.+ expect(parsePullRequestUrl('https://github.com:8443/atomantic/PortOS/pull/1')).toBeNull();+ expect(parsePullRequestUrl('http://gitlab.example.com:9000/group/proj/-/merge_requests/1')).toBeNull();+ });});describe('requestCopilotReview', () => {