Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): validate remote base URL shape before detect (R1-L6)
Diego Zacariaseab92cd6b393
diff --git a/control-ui/components/AddRemoteServerWizard/index.tsx b/control-ui/components/AddRemoteServerWizard/index.tsxindex b52e67880..8d6ead4ec 100644--- a/control-ui/components/AddRemoteServerWizard/index.tsx+++ b/control-ui/components/AddRemoteServerWizard/index.tsx@@ -13,6 +13,7 @@ import {describeTransportProbe,discoverRemoteServer,displayClientMode,+ getRemoteBaseUrlError,getRemoteServerNameError,installModeForRegistration,installRemoteServer,@@ -89,8 +90,11 @@ export function AddRemoteServerWizard({const serverNameError = serverName.length > 0 ? getRemoteServerNameError(serverName) : ''const trimmedBaseUrl = baseUrl.trim()+ const baseUrlError = baseUrl.length > 0 ? getRemoteBaseUrlError(trimmedBaseUrl) : ''const identifiersValid =- trimmedBaseUrl.length > 0 && getRemoteServerNameError(serverName) === '' && contextRef !== ''+ getRemoteBaseUrlError(trimmedBaseUrl) === '' &&+ getRemoteServerNameError(serverName) === '' &&+ contextRef !== ''const installMode = detected ? installModeForRegistration(detected.registrationMode) : nullconst needsCredentials = installMode ? requiresPreRegisteredCredentials(installMode) : false@@ -204,12 +208,14 @@ export function AddRemoteServerWizard({<div className="cu-form-stack cu-agent-form-stack"><Fielddescription="The base URL of the remote MCP server (its OAuth metadata is discovered from here)."+ error={baseUrlError || undefined}label="Remote server URL"htmlFor="remote-base-url"required><TextInputid="remote-base-url"+ invalid={Boolean(baseUrlError)}monospaceonChange={event => {setBaseUrl(event.target.value)diff --git a/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx b/control-ui/components/__tests__/AddRemoteServerWizard.test.tsxindex 23f2639ec..57d1132dd 100644--- a/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx+++ b/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx@@ -126,6 +126,24 @@ describe('AddRemoteServerWizard', () => {expect(screen.getByRole('button', { name: /Configure/ })).toBeDisabled()})+ it('keeps Detect disabled and shows an error for a malformed base URL (no detect round-trip)', async () => {+ renderWizard()+ // Valid name + context, but a non-https URL — the base URL gate must block detect.+ await fillIdentity('http://mcp.notion.com/mcp')++ const detect = screen.getByRole('button', { name: 'Detect' })+ expect(detect).toBeDisabled()+ expect(screen.getByText(/must use https/i)).toBeInTheDocument()++ // Correcting it to https clears the gate.+ fireEvent.change(screen.getByPlaceholderText('https://mcp.example.com/mcp'), {+ target: { value: 'https://mcp.notion.com/mcp' },+ })+ expect(screen.getByRole('button', { name: 'Detect' })).toBeEnabled()+ // The malformed URL never reached control-api.+ expect(discoverMock).not.toHaveBeenCalled()+ })+it('shows client credential fields only for the manual (pre-registered) mode', async () => {// manual has no real probed pilot; this is UI state, not a producer fixture.const manualDetected: RemoteDetected = { ...NOTION_DETECTED, registrationMode: 'manual' }diff --git a/control-ui/lib/__tests__/remoteMcp.test.ts b/control-ui/lib/__tests__/remoteMcp.test.tsindex 49e4ebd76..2d6ebe38f 100644--- a/control-ui/lib/__tests__/remoteMcp.test.ts+++ b/control-ui/lib/__tests__/remoteMcp.test.ts@@ -12,6 +12,7 @@ import {describeDiscoveryError,describeTransportProbe,displayClientMode,+ getRemoteBaseUrlError,getRemoteServerNameError,installModeForRegistration,mapRemoteDiscoverError,@@ -91,6 +92,36 @@ describe('getRemoteServerNameError', () => {})})+describe('getRemoteBaseUrlError', () => {+ it('requires a URL', () => {+ expect(getRemoteBaseUrlError('')).toMatch(/required/i)+ expect(getRemoteBaseUrlError(' ')).toMatch(/required/i)+ })++ it('accepts an absolute https URL with a fully-qualified host', () => {+ expect(getRemoteBaseUrlError('https://mcp.notion.com/mcp')).toBe('')+ expect(getRemoteBaseUrlError(' https://mcp.example.com ')).toBe('')+ })++ it('rejects a non-https scheme', () => {+ expect(getRemoteBaseUrlError('http://mcp.notion.com/mcp')).toMatch(/https/i)+ expect(getRemoteBaseUrlError('ftp://mcp.notion.com')).not.toBe('')+ })++ it('rejects a non-absolute or malformed URL', () => {+ expect(getRemoteBaseUrlError('mcp.notion.com/mcp')).not.toBe('')+ expect(getRemoteBaseUrlError('not a url')).not.toBe('')+ })++ it('rejects a URL with spaces', () => {+ expect(getRemoteBaseUrlError('https://mcp.notion.com/ mcp')).toMatch(/space/i)+ })++ it('rejects a non-fully-qualified hostname', () => {+ expect(getRemoteBaseUrlError('https://localhost/mcp')).toMatch(/fully-qualified/i)+ })+})+describe('buildRemoteInstallRequest', () => {it('omits credentials for non-pre-registered modes and trims fields', () => {const body = buildRemoteInstallRequest({diff --git a/control-ui/lib/remoteMcp.ts b/control-ui/lib/remoteMcp.tsindex a024294bb..3b35c9c6a 100644--- a/control-ui/lib/remoteMcp.ts+++ b/control-ui/lib/remoteMcp.ts@@ -146,6 +146,31 @@ export function getRemoteServerNameError(name: string): string {return ''}+/**+ * Client-side FORM validation for the remote wizard's base URL (UX only — control-api+ * returns the authoritative 422 and its SSRF guard is what blocks a hostile target).+ * Returns '' when acceptable, else a message. Mirrors the generic lane's endpoint+ * check (absolute https, fully-qualified host, no spaces) so an obviously malformed+ * URL is caught before the detect round-trip rather than after it. Remote requires+ * https to match the CRD's `remote.baseUrl` constraint.+ */+export function getRemoteBaseUrlError(raw: string): string {+ const value = raw.trim()+ if (!value) return 'Remote server URL is required.'+ if (/\s/.test(value)) return 'Remote server URL must not contain spaces.'+ let parsed: URL+ try {+ parsed = new URL(value)+ } catch {+ return 'Remote server URL must be an absolute https URL.'+ }+ if (parsed.protocol !== 'https:') return 'Remote server URL must use https.'+ if (!parsed.hostname.includes('.')) {+ return 'Remote server URL must have a fully-qualified hostname.'+ }+ return ''+}+// ── Error mapping to human-readable UI text ──────────────────────────────────type CodedError = {diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex a7466dcb2..6865a96cc 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.655",+ "version": "0.1.656","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.655",+ "version": "0.1.656","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 349558be4..7b96cf2d8 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.655",+ "version": "0.1.656","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",