Repository navigation
fix(test): skip real DNS writes in MITM dynamic-import test #7398
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
Merged
diegosouzapw
merged 11 commits into
cheaper-inference:release/v3.8.49
from
HouMinXi:fix/test-skip-dns-write
Jul 19, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
01ab5d1
chore(ci): add .mergify.yml to main — Mergify only reads config from …
diegosouzapw fb24740
fix(ci): add the auto-enqueue pull_request_rule to the Mergify config…
diegosouzapw fb25ebd
fix(ci): migrate Mergify auto-enqueue to merge_protections_settings.a…
diegosouzapw a795694
fix(ci): drop Mergify batch settings (batching is a paid-tier feature…
diegosouzapw 9875ccf
fix(ci): merge queue tolerates the advisory dast-smoke failure (its G…
diegosouzapw 0065f1b
test(ci): make the #6634 selfref guard hermetic — main's copy hard-fa…
diegosouzapw ddd6d09
chore(quality): tighten main's coverage baseline to the CI's real num…
diegosouzapw 66c56ec
Add cliproxy provider exposure controls and manifest injection (#7329)
KooshaPari 8e383f5
test(ci): static body in codex e2e mock route bridge (CodeQL #737) (#…
diegosouzapw 2fb34a0
fix(test): skip DNS writes in MITM dynamic-import test
HouMinXi 0414145
merge release/v3.8.49 into fix/test-skip-dns-write (resolve mitm/dns …
HouMinXi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/app/(dashboard)/dashboard/providers/services/components/CliproxyProviderExposureCard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /** | ||
| * Provider Exposure toggle for CLIProxyAPI. | ||
| * Persists the `providerExpose` field via POST /api/services/cliproxy/provider-expose. | ||
| * When enabled, CLIProxyAPI models appear as `cliproxyapi/...` in OmniRoute's model selection. | ||
| */ | ||
| "use client"; | ||
|
|
||
| import { useState } from "react"; | ||
| import { Card, Toggle } from "@/shared/components"; | ||
| import { useServiceStatus } from "../hooks/useServiceStatus"; | ||
|
|
||
| const NAME = "cliproxy"; | ||
|
|
||
| export function CliproxyProviderExposureCard() { | ||
| const { data, mutate } = useServiceStatus(NAME); | ||
| const [pending, setPending] = useState(false); | ||
| const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null); | ||
|
|
||
| async function handleToggle(enabled: boolean) { | ||
| setPending(true); | ||
| setMsg(null); | ||
| try { | ||
| const res = await fetch(`/api/services/${NAME}/provider-expose`, { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ enabled }), | ||
| }); | ||
| if (!res.ok) { | ||
| const body = await res.json().catch(() => ({})); | ||
| const errorMsg = | ||
| body?.error?.message ?? body?.message ?? `Failed to update (HTTP ${res.status})`; | ||
| setMsg({ ok: false, text: errorMsg }); | ||
| return; | ||
| } | ||
| setMsg(null); | ||
| mutate(); | ||
| } catch { | ||
| setMsg({ ok: false, text: "Network error — could not update provider exposure setting" }); | ||
| } finally { | ||
| setPending(false); | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Card padding="md"> | ||
| <div className="flex items-center gap-3 mb-3"> | ||
| <div className="size-8 rounded-lg flex items-center justify-center bg-sky-500/10"> | ||
| <span className="material-symbols-outlined text-sky-500 text-xl">hub</span> | ||
| </div> | ||
| <div> | ||
| <h3 className="font-medium text-sm">Provider Exposure</h3> | ||
| <p className="text-xs text-text-muted"> | ||
| Expose CLIProxyAPI models as a routing target under the{" "} | ||
| <code className="font-mono bg-bg-subtle px-1 rounded">cliproxyapi/</code> prefix. | ||
| </p> | ||
| </div> | ||
| </div> | ||
|
|
||
| {msg && ( | ||
| <div | ||
| className={`flex items-center gap-1.5 mb-3 px-2 py-1.5 rounded text-xs ${ | ||
| msg.ok | ||
| ? "bg-green-500/10 text-green-600 dark:text-green-400" | ||
| : "bg-red-500/10 text-red-600 dark:text-red-400" | ||
| }`} | ||
| > | ||
| <span className="material-symbols-outlined text-[12px]"> | ||
| {msg.ok ? "check_circle" : "error"} | ||
| </span> | ||
| {msg.text} | ||
| </div> | ||
| )} | ||
|
|
||
| <div className="flex items-center justify-between"> | ||
| <div> | ||
| <p className="text-sm"> | ||
| Expose as{" "} | ||
| <code className="font-mono bg-bg-subtle px-1 rounded text-xs">cliproxyapi/...</code> | ||
| </p> | ||
| <p className="text-xs text-text-muted mt-0.5"> | ||
| When enabled, discovered models appear in provider selects across OmniRoute. | ||
| </p> | ||
| </div> | ||
| <Toggle checked={data?.providerExpose ?? false} onChange={handleToggle} disabled={pending || !data} /> | ||
| </div> | ||
| </Card> | ||
| ); | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * POST /api/services/cliproxy/provider-expose | ||
| * | ||
| * Toggle provider exposure for the CLIProxy embedded service. | ||
| * When enabled, cliproxyapi models are discoverable as `cliproxyapi/...` in | ||
| * OmniRoute routing. | ||
| * | ||
| * Body: { enabled: boolean } | ||
| * Response: 204 No Content on success. | ||
| * | ||
| * Route is under /api/services/ — already classified LOCAL_ONLY in routeGuard.ts. | ||
| */ | ||
|
|
||
| import { z } from "zod"; | ||
| import { updateServiceField } from "@/lib/db/versionManager"; | ||
| import { createErrorResponse } from "@/lib/api/errorResponse"; | ||
| import { sanitizeErrorMessage } from "@omniroute/open-sse/utils/error"; | ||
|
|
||
| const BodySchema = z.object({ enabled: z.boolean() }); | ||
|
|
||
| export async function POST(request: Request): Promise<Response> { | ||
| let body: unknown; | ||
| try { | ||
| body = await request.json(); | ||
| } catch { | ||
| return createErrorResponse({ status: 400, message: "Invalid JSON body" }); | ||
| } | ||
|
|
||
| const parsed = BodySchema.safeParse(body); | ||
| if (!parsed.success) { | ||
| return createErrorResponse({ status: 400, message: parsed.error.message }); | ||
| } | ||
|
|
||
| try { | ||
| await updateServiceField("cliproxy", "providerExpose", parsed.data.enabled); | ||
| return new Response(null, { status: 204 }); | ||
| } catch (err) { | ||
| const msg = sanitizeErrorMessage(err instanceof Error ? err.message : String(err)); | ||
| return createErrorResponse({ status: 500, message: msg }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import type { ProviderPluginManifestEntry } from "@omniroute/open-sse/config/providerPluginManifest.ts"; | ||
|
|
||
| export const SERVICE_BACKEND_PLUGIN_IDS = ["9router", "cliproxyapi"] as const; | ||
|
|
||
| export type ServiceBackendPluginId = (typeof SERVICE_BACKEND_PLUGIN_IDS)[number]; | ||
|
|
||
| export const SERVICE_BACKEND_EXPOSURE_TOOL_BY_PLUGIN_ID: Record< | ||
| ServiceBackendPluginId, | ||
| "9router" | "cliproxy" | ||
| > = { | ||
| "9router": "9router", | ||
| cliproxyapi: "cliproxy", | ||
| }; | ||
|
|
||
| export const SERVICE_BACKEND_MANIFEST_TEMPLATE: Record< | ||
| ServiceBackendPluginId, | ||
| Pick< | ||
| ProviderPluginManifestEntry, | ||
| "format" | "executor" | "auth" | "endpoints" | "capabilities" | "passthroughModels" | "sidecar" | ||
| > | ||
| > = { | ||
| "9router": { | ||
| format: "openai", | ||
| executor: "default", | ||
| auth: { type: "none", header: "authorization" }, | ||
| endpoints: { modelsUrl: "/v1/models" }, | ||
| capabilities: [], | ||
| passthroughModels: true, | ||
| sidecar: { eligible: false, reasons: ["runtime provider"] }, | ||
| }, | ||
| cliproxyapi: { | ||
| format: "openai", | ||
| executor: "default", | ||
| auth: { type: "none", header: "authorization" }, | ||
| endpoints: { modelsUrl: "/v1/models" }, | ||
| capabilities: ["passthrough-models"], | ||
| passthroughModels: true, | ||
| sidecar: { eligible: false, reasons: ["runtime provider"] }, | ||
| }, | ||
| }; | ||
|
|
||
| export function getServiceToolFromPluginId( | ||
| pluginId: string | ||
| ): "9router" | "cliproxy" | undefined { | ||
| return SERVICE_BACKEND_EXPOSURE_TOOL_BY_PLUGIN_ID[ | ||
| pluginId as keyof typeof SERVICE_BACKEND_EXPOSURE_TOOL_BY_PLUGIN_ID | ||
| ]; | ||
| } | ||
|
|
||
| const SERVICE_BACKEND_PLUGIN_ID_SET = new Set<string>(SERVICE_BACKEND_PLUGIN_IDS); | ||
|
|
||
| export function isServiceBackendPluginId(pluginId: string): pluginId is ServiceBackendPluginId { | ||
| return SERVICE_BACKEND_PLUGIN_ID_SET.has(pluginId); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Loader hook: replaces child_process.spawn with a safe mock. | ||
| // Other exports (execFile, execFileSync, etc.) are the real implementations. | ||
| // Registered by mitm-dnsConfig.test.ts before any dnsConfig import. | ||
| export async function resolve(specifier: string, context: any, nextResolve: Function) { | ||
| const bare = specifier.split("?")[0]; | ||
| if (bare === "child_process") { | ||
| return { | ||
| shortCircuit: true, | ||
| url: new URL("./_cp_mock_module.mts", import.meta.url).href, | ||
| }; | ||
| } | ||
| return nextResolve(specifier, context); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Mock child_process module — replaces spawn, keeps everything else real. | ||
| // Imported by mitm-dnsConfig.test.ts via the loader hook in _cp_mock_hook.mts. | ||
| const realCp = await import("node:child_process"); | ||
|
|
||
| export const execFile = realCp.execFile; | ||
| export const execFileSync = realCp.execFileSync; | ||
| export const fork = realCp.fork; | ||
| export const execSync = realCp.execSync; | ||
| export const spawnSync = realCp.spawnSync; | ||
|
|
||
| /** All spawn calls recorded as [command, args, options]. */ | ||
| export const spawnCalls: Array<{ command: string; args: string[] }> = []; | ||
|
|
||
| export function spawn(command: string, args?: string[], options?: any) { | ||
| spawnCalls.push({ command, args: args ?? [], options }); | ||
| return { | ||
| stdin: { write: () => true, end: () => {} }, | ||
| stdout: { on: () => {} }, | ||
| stderr: { on: () => {} }, | ||
| on: function (ev: string, cb: (code: number) => void) { | ||
| if (ev === "close") cb(0); | ||
| return this; | ||
| }, | ||
| kill: () => {}, | ||
| }; | ||
| } | ||
|
|
||
| export function resetSpawnCalls() { | ||
| spawnCalls.length = 0; | ||
| } | ||
|
|
||
| export default { execFile, execFileSync, fork, spawn, execSync, spawnSync }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/usr/bin/env bash | ||
| # Wrapper: temporarily inject a test entry into /etc/hosts, run the | ||
| # mitm-dnsConfig test, then clean up. The entry lets removeDNSEntries | ||
| # exercise the full exec path (host present → spawn sudo → mock intercepts). | ||
| set -euo pipefail | ||
|
|
||
| TEST_HOST="__dns_guard_test__" | ||
| HOSTS_FILE="/etc/hosts" | ||
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
| REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" | ||
|
|
||
| cleanup() { | ||
| sudo sed -i "/$TEST_HOST/d" "$HOSTS_FILE" 2>/dev/null || true | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| # Inject test entries (idempotent — duplicates are harmless). | ||
| if ! grep -q "$TEST_HOST" "$HOSTS_FILE" 2>/dev/null; then | ||
| echo "127.0.0.1 $TEST_HOST" | sudo tee -a "$HOSTS_FILE" > /dev/null | ||
| echo "::1 $TEST_HOST" | sudo tee -a "$HOSTS_FILE" > /dev/null | ||
| fi | ||
|
|
||
| cd "$REPO_ROOT" | ||
| node --import tsx/esm --import ./tests/_setup/isolateDataDir.ts \ | ||
| --test tests/unit/mitm-dnsConfig.test.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.