Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(providers): 正确校验 Guardian 审核模型授权
DavidShenf5855ba68133
diff --git a/apps/desktop/src/main/maker-host/__tests__/codexProxyGuestRoute.test.ts b/apps/desktop/src/main/maker-host/__tests__/codexProxyGuestRoute.test.tsindex b48a0ee7bb..3c48fdead9 100644--- a/apps/desktop/src/main/maker-host/__tests__/codexProxyGuestRoute.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/codexProxyGuestRoute.test.ts@@ -30,7 +30,7 @@ import { buildUserProvider } from '@cindy/model-providers';import type { RoutingDecision } from '@cindy/anthropic-compat-proxy';import { setCustomProviders } from '../active-catalog';-import { createCodexGuestRoutingGuard, registerComposed, unregister } from '../codex-proxy-host';+import { createCodexGuestRoutingGuard, registerComposed, registerReviewerRouteContext, unregister } from '../codex-proxy-host';import { CODEX_CUSTOM_PROVIDER_ROUTE_ROOT } from '../codex-custom-provider-route';import { registerGuestProviderRoute, resetGuestProviderRoutesForTest } from '../guest-provider-route-store';import { clearAllSessionProviders, setSessionProvider } from '../session-provider-store';@@ -92,6 +92,31 @@ describe('Codex proxy guard for shared-provider guests', () => {expect(await statusOf(guard({ model: 'other-model' }, ctx(path, { 'thread-id': 'guest-thread' })))).toBe(403);});+ // Unit regression for review 4326610462: the public guard must authorize Guardian's+ // actual reviewer model, including live revocation. Existing tests only sent catalog ids;+ // the minimal failure is an allowlisted parent with the internal codex-auto-review marker.+ it.each([+ ['shared-a', '/responses'],+ ['shared-a', `${CODEX_CUSTOM_PROVIDER_ROUTE_ROOT}/0123456789abcdef0123/responses`],+ ['openai', '/responses'],+ ])('authorizes Guardian by its parent model on %s %s', async (providerId, path) => {+ const model = providerId === 'openai' ? 'gpt-5.5' : 'shared-model';+ let allowed = true;+ registerGuestProviderRoute('guest-session', providerId, candidate => allowed && candidate === model, () => true);+ registerReviewerRouteContext('guest-session', 'guest-thread', model);+ const guard = createCodexGuestRoutingGuard(providerId, providerId === 'openai' ? 'oauth-bearer' : 'env-key');+ const body = { model: 'codex-auto-review' };+ const request = () => guard(body, ctx(path, {+ 'thread-id': 'guardian-child',+ 'x-openai-subagent': 'guardian',+ 'x-codex-parent-thread-id': 'guest-thread',+ }));+ expect(request()).toBeUndefined();+ expect(await statusOf(guard(body, ctx(path, { 'thread-id': 'guest-thread' })))).toBe(403);+ allowed = false;+ expect(await statusOf(request())).toBe(403);+ });+it('refuses requests that do not belong to the registered guest session', async () => {const guard = createCodexGuestRoutingGuard('shared-a', 'env-key');// 认不出会话:分享的是自定义供应商,没有可直达的默认路由。diff --git a/apps/desktop/src/main/maker-host/codex-proxy-host.ts b/apps/desktop/src/main/maker-host/codex-proxy-host.tsindex 8666157ae0..1d729f4948 100644--- a/apps/desktop/src/main/maker-host/codex-proxy-host.ts+++ b/apps/desktop/src/main/maker-host/codex-proxy-host.ts@@ -2540,7 +2540,12 @@ export function createCodexGuestRoutingGuard(const requestModel = isPlainObject(body) && typeof body.model === 'string' ? body.model : '';if (!requestModel) return undefined;const sessionId = sessionIdFromHeaders(ctx.headers);- if (!guestProviderModelAllowed(providerId, requestModel, sessionId)) return codexGuestRouteRefusal();+ // Guardian's internal marker is not a catalog model. Authorize its registered+ // parent model, including when native OpenAI keeps the marker on the wire.+ const reviewerModel = requestModel === CODEX_AUTO_REVIEW_MODEL && guardianParentThreadIdFromHeaders(ctx.headers) && sessionId+ ? reviewerModelBySession.get(sessionId)+ : undefined;+ if (!guestProviderModelAllowed(providerId, reviewerModel ?? requestModel, sessionId)) return codexGuestRouteRefusal();if (parseCodexCustomProviderPath(ctx.url).kind !== 'not-custom-provider-route') return undefined;const authInjection = frozenAuthInjection ?? getCodexProxyAuthInjection();if (ctx.url.split('?', 1)[0]?.endsWith('/responses')) {