Skip to content

fix(providers): allow canonical Antigravity through fake-IP save validation - #4723

Merged
lidge-jun merged 4 commits into
lidge-jun:devfrom
juzijia:fix/antigravity-management-fakeip
Sep 17, 2026
Merged

lidge-jun merged 4 commits into
lidge-jun:devfrom
juzijia:fix/antigravity-management-fakeip

Conversation

@juzijia

@juzijia juzijia commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Allow config-write DNS validation to treat 198.18.0.0/15 as transparent Fake-IP only for the exact canonical Google Antigravity transport (google-antigravity + google adapter + OAuth + the registry daily-cloudcode-pa.googleapis.com base URL).
  • Keep overridden Antigravity base URLs, wrong adapter/auth shapes, literal benchmark IPs, RFC1918/loopback/metadata answers, and mixed benchmark + private/metadata answer sets fail-closed.
  • Centralize the exception in providerDestinationResolvedError, so the existing management write/reload callers get the same bounded behavior without enabling allowPrivateNetwork or weakening runtime URL fetch policy.

Verification

  • Audited the branch diff against upstream dev (45cfb04e9757a5a257ab6290d9f24d2ea0bc7573): only src/lib/destination-policy.ts and tests/routing/destination-policy-resolved.test.ts change.
  • Added focused regression coverage for the reported daily-cloudcode-pa.googleapis.com -> 198.18.1.68 case plus negative coverage for custom base URL, adapter/auth mismatch, literal benchmark destination, RFC1918 companion, and metadata companion.
  • Performed a static TypeScript audit of the new test literals and corrected tuple inference before opening this PR.
  • Repository Bun tests and full typecheck were not run in this connector-only environment; this PR is opened as draft so CI/maintainer verification can remain authoritative before review-ready status.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. No new setting or public contract is introduced; this restores the existing bounded Fake-IP behavior for the canonical Antigravity save path.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. The patch is intentionally fail-closed outside the exact registry transport; maintainer security review is requested before marking ready.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Updated destination validation for the canonical Google Antigravity OAuth configuration.
    • Valid benchmark DNS responses are now accepted automatically for the exact supported Antigravity endpoint, without requiring an additional opt-in.
    • Other endpoints and configurations remain subject to existing restrictions, including protections against private-network and metadata addresses.
    • Added coverage to verify the exception applies only to resolved destinations and the matching provider configuration.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7c9a812f-e4c9-4f7f-b83e-8030865e5ef2

📥 Commits

Reviewing files that changed from the base of the PR and between 43cd1ad and ab849de.

📒 Files selected for processing (2)
  • src/lib/destination-policy.ts
  • tests/routing/destination-policy-resolved.test.ts

📝 Walkthrough

Walkthrough

Changes

Antigravity benchmark DNS exception

Layer / File(s) Summary
Canonical write-time exception
src/lib/destination-policy.ts
The policy normalizes the configured endpoint and enables the benchmark DNS exception only for the canonical google-antigravity OAuth configuration. The existing caller opt-in remains supported.
Exception behavior validation
tests/routing/destination-policy-resolved.test.ts
Tests cover the canonical configuration, mismatched base URL, adapter, or auth mode, unsafe companion addresses, and literal benchmark destinations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ All CI tests are green on my local testing.
  • ⬜ I pushed my PR to the latest dev commit.
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 74 / 80

이 PR은 지금 dev 끝(45cfb04e9, 패키지 2.57.0)에서 설정 저장·리로드 때 쓰는 DNS SSRF 검사 providerDestinationResolvedError에, 레지스트리 시드와 완전히 같은 Google Antigravity 전송만 Clash/Mihomo Fake-IP(198.18.0.0/15) DNS 답을 허용하는 예외를 넣습니다. 지금 dev에는 ChatGPT Codex(openai 정본 시드)만 관리 API 쪽에서 allowBenchmarkAddresses: true를 넘기도록 되어 있고(src/server/management/provider-routes.ts의 isCanonicalOpenAiForwardProvider), Antigravity는 같은 Fake-IP DNS를 받아도 저장이 막힙니다. 현장에서는 daily-cloudcode-pa.googleapis.com -> 198.18.x처럼 투명 DNS가 흔해서, 프록시는 실제로 쓸 수 있는데 관리 UI/설정 쓰기만 거절되는 불일치가 납니다.

고치는 방식은 openai처럼 라우트마다 플래그를 더 넣는 대신, src/lib/destination-policy.ts 안에 registryAllowsBenchmarkDnsAtWriteTime을 두고 providerDestinationResolvedError가 호출자 옵션과 OR로 예외를 켭니다. 조건은 좁습니다. 이름 google-antigravity, 레지스트리 authKind === oauth + allowBaseUrlOverride, 호출 쪽 adapter/authMode이 시드와 같고, baseUrl이 정규화 후 시드 URL(https://daily-cloudcode-pa.googleapis.com)과 같을 때만입니다. 커스텀 릴레이 URL, 어댑터/인증 불일치, 리터럴 198.18 URL, 벤치마크+사설/메타데이터 혼합 답은 계속 막습니다. allowPrivateNetwork를 키우거나 런타임 resolvePublicAddresses 기본값을 느슨하게 만들지 않습니다. 테스트도 같은 파일에 긍정 1개·부정(커스텀/어댑터/키/혼합/리터럴)을 같이 넣었습니다. 범위는 destination-policy.ts + 해당 테스트뿐이라 types/config 분할 캠페인과도 안 겹칩니다.

왜 점수 74인가. 현장 Fake-IP 저장 거절을 정본 전송에만 풀어 주는 방향이 맞고, 실패 닫힘(fail-closed) 부정 테스트가 분명합니다. 다만 openai는 아직도 관리 라우트가 명시적으로 플래그를 넘기고 Antigravity만 정책 함수 안으로 예외가 들어가서 패턴이 갈라집니다. 또 예외는 adapter/authMode가 호출 객체에 실려 와야 켜지므로, baseUrl만 넘기는 호출 경로는 의도적으로 예외 밖입니다(안전에는 이득). draft + 로컬 스위트 미실행이라 CI가 권위입니다. Mihomo IPv6 Fake-IP(fdfe:dcba:9876::/48)는 이 PR 범위 밖입니다.

src/lib/destination-policy.ts registryAllowsBenchmarkDnsAtWriteTime - 예외가 켜지려면 호출자가 adapter/authMode를 같이 넘겨야 한다. 관리 저장·리로드가 디스크/에디터 전체 row를 넘기면 동작하고, baseUrl만 넘기는 경로에서는 예외가 안 켜진다(문서/호출 계약 확인 필요).
src/lib/destination-policy.ts providerDestinationResolvedError - openai는 provider-routes.ts에서 allowBenchmarkAddresses를 넘기고, Antigravity는 정책 함수 내부 OR로 켠다. 같은 Fake-IP 예외인데 진입점이 두 갈래라 이후 제공자 추가 때 어디에 넣을지 헷갈릴 수 있다.
src/lib/destination-policy.ts EOF - 파일 끝 개행이 빠졌다(diff No newline at end of file). 작은 스타일/도구 소음.
tests/routing/destination-policy-resolved.test.ts Antigravity describe - 정규화(끝 슬래시·대소문자 호스트) 긍정 케이스는 없고, IPv6 Mihomo Fake-IP는 다루지 않는다. 이번 현장 리포트가 IPv4 198.18.1.68이면 충분하지만 범위 한계는 적어 두는 편이 좋다.
src/server/management/provider-routes.ts (이 PR 밖) - openai용 name === "openai" && isCanonicalOpenAiForwardProvider 자리는 그대로다. Antigravity를 같은 자리에 대칭으로 넣을지, 이번처럼 정책 쪽으로 모을지 한쪽으로 정리하는 편이 유지보수에 낫다.

메인테이너의 판단이 필요한 지점

  • Fake-IP 예외를 openai처럼 관리 라우트 호출부에 둘지, 이번 PR처럼 destination-policy 레지스트리 검사로 모을지.
  • draft 체크리스트·보안 리뷰를 통과시키기 전에 ready로 올릴지(작성자도 보안 리뷰를 요청함).
  • IPv6 Mihomo Fake-IP까지 같은 정본 Antigravity에 허용할지, 이번엔 IPv4만으로 닫을지.

너의 추천
draft 유지. 호스트 CI에서 destination-policy-resolved 관련 테스트가 초록이면, 정책 쪽 중앙화 방향을 메인테이너가 OK한 뒤 merge. squash보다 커밋 그대로(또는 작은 EOF 개행만 정리) 권장. types/config 분할과 무관하니 close-don't-rebase 대상 아님. 관련 이슈 번호가 본문에 없으면 현장 재현 이슈를 Fixes #로 묶으면 추적에 좋다.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun
lidge-jun force-pushed the fix/antigravity-management-fakeip branch from aca715a to ac4ccc1 Compare September 16, 2026 08:56
@lidge-jun
lidge-jun force-pushed the fix/antigravity-management-fakeip branch from ac4ccc1 to 01dadfd Compare September 16, 2026 11:16

@lidge-jun lidge-jun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed against current head ab849de4fe8db63e15ef22b04e3ce6ec31395859 (the earlier review anchor 01dadfddca is now followed by a merge from dev). I accept the approach.

The exception is derived inside config-time resolved-destination validation from the exact canonical registry transport. At src/lib/destination-policy.ts:262-277, all six conditions are present: provider name is exactly google-antigravity; the registry entry has OAuth auth kind; the registry explicitly allows base-URL override; the configured adapter equals the registry adapter; runtime auth mode is OAuth; and the normalized configured base URL equals the normalized registry base URL. The registry row confirms the canonical values (src/providers/registry/entries-core.ts:987-994): Google adapter, OAuth, override enabled, and https://daily-cloudcode-pa.googleapis.com.

The original boundary is preserved. Custom Antigravity relays fail the canonical comparison; literal 198.18.x.x URLs are still rejected synchronously before DNS (src/lib/destination-policy.ts:343-356,380-390); every DNS answer is still classified, so a benchmark answer mixed with private or metadata space is rejected (src/lib/destination-policy.ts:400-409); other providers cannot enter the named exception; and neither allowPrivateNetwork nor the runtime URL-fetch policy is changed. The focused negative cases in tests/routing/destination-policy-resolved.test.ts:179-215 exercise those distinctions.

The remaining delivery gap is issue linkage. closingIssuesReferences is empty and the PR body contains no closing reference. Please name the issue this resolves and add the appropriate closing reference; without that, there is no basis to record a closure for this fix.

IPv6 Mihomo Fake-IP handling is outside this change's scope; this patch is specifically the IPv4 198.18.0.0/15 benchmark-DNS exception. Nit: src/lib/destination-policy.ts still lacks a final newline at the current head.

@lidge-jun lidge-jun mentioned this pull request Sep 17, 2026
2 tasks done
@lidge-jun
lidge-jun marked this pull request as ready for review September 17, 2026 19:41
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 17, 2026 19:41
@lidge-jun
lidge-jun merged commit 7e86436 into lidge-jun:dev Sep 17, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants