Skip to content

feat(migration): confine source requests to a destinations policy - #14508

Merged
abnegate merged 1 commit into
mainfrom
feat/migration-source-destinations
Oct 15, 2026
Merged

abnegate merged 1 commit into
mainfrom
feat/migration-source-destinations

Conversation

@abnegate

Copy link
Copy Markdown
Member

What

This ports utopia-php/migration#240 now that migration lives in packages/migration (#14503).

Target::setDestinations(Destinations) confines a target's requests to a Utopia\Client\Destinations policy. The Appwrite source applies the same policy to its SDK client, Sources\Appwrite\Client.

If no policy is set, nothing changes: requests can connect anywhere, as before.

Why

#14034 checks a migration source's endpoint before it connects. utopia-php/client goes further: it checks every connection, and every redirect hop, against the address curl actually connected to, and refuses proxies when the policy restricts addresses. So the library only needs to pass the caller's policy through.

Differences from #240

Tests

tests/General/TargetDestinationsTest.php covers seven cases:

  • a target with no policy reaching the server;
  • PublicInternet refusing it, without the server seeing a request;
  • PublicInternet with a 127.0.0.0/8 range admitting it;
  • a policy set after a request applying to the next one;
  • the SDK client refusing the server;
  • the SDK client admitting it under the 127.0.0.0/8 range;
  • the Appwrite source passing its policy to the SDK client.

Six of the seven fail without the change. The no-policy case passes either way.

Locally:

  • bin/monorepo check migration passes (Rector, Pint, PHPStan level max).
  • The unit tier passes: 186 tests.

Not verified

  • A redirect hop being refused. The fixture server listens only on 127.0.0.1, and curl connects before the policy check runs, so a second address can't be reached in order to be refused. utopia-php/client's own suite covers per-hop checks.

🤖 Generated with Claude Code

Ports utopia-php/migration#240. Target::setDestinations() hands a
Utopia\Client\Destinations to the client Target::call() builds, and the
Appwrite source applies it to its SDK client as well. utopia-php/client
checks every connection and redirect hop against the address curl
actually reached, and refuses proxies under a restricting policy, so a
host that rebinds or redirects cannot reach an address the caller did
not admit. Unset, requests connect anywhere, as before.

The resolver controls from #229 stay: #14034 uses
setResolver() today, and the two compose. The changelog gains a 4.0.0
section for this and for what landed since 3.1.2 without an entry,
including the redirect default that makes it a major.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The change introduces destination-based network confinement for data migrations, ensuring outbound HTTP connections (including redirect hops) are validated against configured destinations.

Files Change
packages/migration/src/Sources/Appwrite/Client.php Rebuilds the HTTP client with destination enforcement and refuses disallowed redirects.
packages/migration/src/Sources/Appwrite.php Exposes setDestinations() on the source adapter, delegating to the client with cache invalidation.
packages/migration/src/Target.php Adds lazy client rebuild with configured destinations on the target side.
packages/migration/tests/General/DestinationsSource.php, TargetDestinationsTest.php Adds tests covering pre-request and post-request destination setter ordering.
packages/migration/CHANGELOG.md Documents the new destinations feature.

Reviewed commit: b1de3c2

@ghost

ghost commented Oct 15, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The policy is applied to both target and Appwrite SDK requests, and the changed behavior is covered by tests.

Adds a destinations policy to migration targets and forwards the same policy from Appwrite sources to their SDK client. Adds coverage for policy refusal, allowed loopback access, and applying the policy after a request; updates the migration changelog.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 6
File Change
packages/migration/CHANGELOG.md Documents the upcoming 4.0.0 changes, including destinations policies.
packages/migration/src/Sources/Appwrite.php Forwards destinations policies to the Appwrite SDK client and parent target.
packages/migration/src/Sources/Appwrite/Client.php Applies configured destinations to the SDK HTTP client.
packages/migration/src/Target.php Adds a target destinations setter and applies the policy when constructing its HTTP client.
packages/migration/tests/General/DestinationsSource.php Exposes the SDK client for destination-policy tests.
packages/migration/tests/General/TargetDestinationsTest.php Covers target and SDK policy enforcement, including setting the source policy after an initial request.

Reviewed b1de3c2 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat/migration-source-destinations (after).

Metric Before After Change
🚀 Requests/sec 205.62 210.29 ⚪ +2.3%
⏱️ Latency P50 84.05 ms 81.42 ms ⚪ -3.1%
⏱️ Latency P95 194.71 ms 193.12 ms ⚪ -0.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 81.42 193.12 13,395 210.29 -1.6
Account 159.51 287.58 705 11.66 +22.24
TablesDB 77.51 144.08 7,285 117.41 -5.03
Storage 78.19 173.63 3,525 58.04 -35.49
Functions 118.03 222.7 1,880 31.67 -11.04

Top API waits (after)

API request Max wait (ms)
functions.create 439.85
tablesdb.rows.create 426.6
account.prefs.update 411.75
account.name.update 410.71
functions.variables.update 394.9

@abnegate
abnegate merged commit 79cf7a0 into main Oct 15, 2026
435 of 437 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant