AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(platform): credential swap proxy that every E2B box egresses through (#14645)
Krzysztof Czerwinski167505067d95
diff --git a/.github/workflows/platform-swap-proxy-ci.yml b/.github/workflows/platform-swap-proxy-ci.ymlnew file mode 100644index 0000000000..700b49b856--- /dev/null+++ b/.github/workflows/platform-swap-proxy-ci.yml@@ -0,0 +1,97 @@+name: AutoGPT Platform - Swap Proxy CI++on:+ push:+ branches: [master, dev, ci-test*]+ paths:+ - ".github/workflows/platform-swap-proxy-ci.yml"+ - ".github/scripts/validate_junit.py"+ - "autogpt_platform/swap_proxy/**"+ pull_request:+ branches: [master, dev, release-*]+ paths:+ - ".github/workflows/platform-swap-proxy-ci.yml"+ - ".github/scripts/validate_junit.py"+ - "autogpt_platform/swap_proxy/**"+ merge_group:+ # On-demand run for a branch whose base is not master/dev (a stacked PR), where the+ # pull_request trigger above never fires:+ # gh workflow run platform-swap-proxy-ci.yml --ref <branch>+ workflow_dispatch:++concurrency:+ group: ${{ format('swap-proxy-ci-{0}', github.head_ref && format('{0}-{1}', github.event_name, github.event.pull_request.number) || github.sha) }}+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }}++jobs:+ # The proxy is its own package with its own lockfile: mitmproxy pins its+ # dependencies exactly and cannot share an environment with the backend.+ # Pure unit and loopback tests: no database or external services needed.+ test:+ permissions:+ contents: read+ timeout-minutes: 10+ runs-on: ubuntu-latest+ defaults:+ run:+ shell: bash+ working-directory: autogpt_platform/swap_proxy++ steps:+ - name: Checkout repository+ uses: actions/checkout@v6++ - name: Set up Python 3.13+ uses: actions/setup-python@v5+ with:+ python-version: "3.13"++ - name: Set up Python dependency cache+ uses: actions/cache@v5+ with:+ path: ~/.cache/pypoetry+ key: poetry-${{ runner.os }}-py3.13-swap-proxy-${{ hashFiles('autogpt_platform/swap_proxy/poetry.lock') }}++ - name: Install Poetry+ run: |+ # The version this package's own lockfile was written with (also the+ # one the Dockerfile pins), not the backend's: a Poetry bump there+ # must not start rewriting a lock nobody here touched.+ HEAD_POETRY_VERSION=$(sed -n 's/^# This file is automatically @generated by Poetry \([0-9][0-9.]*\) .*/\1/p' poetry.lock)+ if [ -z "$HEAD_POETRY_VERSION" ]; then+ echo "Error: no Poetry version in the poetry.lock header."+ exit 1+ fi+ echo "Using Poetry version ${HEAD_POETRY_VERSION}"+ curl -sSL https://install.python-poetry.org | POETRY_VERSION=$HEAD_POETRY_VERSION python3 -++ - name: Check poetry.lock+ run: |+ poetry lock++ if ! git diff --quiet --ignore-matching-lines="^# " poetry.lock; then+ echo "Error: poetry.lock not up to date."+ echo+ git diff poetry.lock+ exit 1+ fi++ - name: Install Python dependencies+ run: poetry install++ - name: Run linters+ run: |+ poetry run isort --check swap_proxy+ poetry run black --check swap_proxy+ poetry run ruff check swap_proxy+ poetry run pyright swap_proxy++ - name: Run pytest+ run: poetry run pytest -q --junitxml=junit-swap-proxy.xml++ - name: Validate test report+ if: ${{ always() }}+ run: >-+ python ../../.github/scripts/validate_junit.py --synthesize-invalid+ --require-no-skips+ junit-swap-proxy.xmldiff --git a/autogpt_platform/backend/backend/copilot/integration_creds.py b/autogpt_platform/backend/backend/copilot/integration_creds.pyindex fcd7637aa9..56284b43f3 100644--- a/autogpt_platform/backend/backend/copilot/integration_creds.py+++ b/autogpt_platform/backend/backend/copilot/integration_creds.py@@ -182,11 +182,17 @@ def _cache_key(return (user_id, provider)+class ProviderTokenUnavailable(Exception):+ """The token could not be looked up or refreshed: unknown, not absent."""++async def get_provider_token(user_id: str,provider: str,required_scopes: frozenset[str] = frozenset(),credential_id: str | None = None,+ *,+ strict: bool = False,) -> str | None:"""Return the user's access token for *provider*, or ``None`` if not connected.@@ -199,6 +205,10 @@ async def get_provider_token(chat; when it is still stored, it is the only candidate.Both found tokens and "not connected" results are cached for 60 s, and acredential write in any process evicts the entry before that lapses.+ With *strict*, a failed credential read or a failed refresh with no other+ token to fall back to raises ``ProviderTokenUnavailable`` instead of+ returning ``None``: for a caller to whom "not connected" means something+ (the swap proxy scrubs against it), a failure must not look like one."""_ensure_cache_invalidation_listener()cache_key = _cache_key(user_id, provider, required_scopes, credential_id)@@ -211,13 +221,15 @@ async def get_provider_token(manager = _managertry:creds_list = await manager.store.get_creds_by_provider(user_id, provider)- except Exception:+ except Exception as e:logger.warning("Failed to fetch %s credentials for user %s",provider,user_id,exc_info=True,)+ if strict:+ raise ProviderTokenUnavailable(provider) from ereturn Noneif credential_id is not None:@@ -278,6 +290,8 @@ async def get_provider_token(# the next call should retry the refresh instead of being blocked for 60 s.if not refresh_failed:_null_cache[cache_key] = True+ elif strict:+ raise ProviderTokenUnavailable(provider)return Nonediff --git a/autogpt_platform/backend/backend/copilot/integration_creds_test.py b/autogpt_platform/backend/backend/copilot/integration_creds_test.pyindex 0284207a3c..b001b83fee 100644--- a/autogpt_platform/backend/backend/copilot/integration_creds_test.py+++ b/autogpt_platform/backend/backend/copilot/integration_creds_test.py@@ -11,6 +11,7 @@ from backend.copilot.integration_creds import (_NULL_CACHE_TTL,_TOKEN_CACHE_TTL,PROVIDER_ENV_VARS,+ ProviderTokenUnavailable,_consume_creds_changed_events,_gh_identity_cache,_gh_identity_null_cache,@@ -261,6 +262,48 @@ class TestGetProviderToken:assert (_USER, _PROVIDER) not in _token_cacheassert (_USER, _PROVIDER) not in _null_cache+ @pytest.mark.asyncio(loop_scope="session")+ async def test_strict_raises_on_a_db_failure_instead_of_not_connected(self):+ """The swap proxy scrubs against this answer: a failure must not read+ as "not connected", which would mean nothing to scrub."""+ mock_manager = MagicMock()+ mock_manager.store.get_creds_by_provider = AsyncMock(+ side_effect=RuntimeError("db down")+ )+ with patch("backend.copilot.integration_creds._manager", mock_manager):+ with pytest.raises(ProviderTokenUnavailable):+ await get_provider_token(_USER, _PROVIDER, strict=True)+ assert (_USER, _PROVIDER) not in _null_cache++ @pytest.mark.asyncio(loop_scope="session")+ async def test_strict_raises_when_the_only_refresh_fails(self):+ mock_manager = MagicMock()+ mock_manager.store.get_creds_by_provider = AsyncMock(+ return_value=[_make_oauth2_creds("stale-oauth-tok")]+ )+ mock_manager.refresh_if_needed = AsyncMock(side_effect=RuntimeError("network"))+ with patch("backend.copilot.integration_creds._manager", mock_manager):+ with pytest.raises(ProviderTokenUnavailable):+ await get_provider_token(_USER, _PROVIDER, strict=True)++ @pytest.mark.asyncio(loop_scope="session")+ async def test_strict_still_falls_back_when_a_refresh_fails(self):+ """A failed refresh with an API key to fall back to is an answer."""+ mock_manager = MagicMock()+ mock_manager.store.get_creds_by_provider = AsyncMock(+ return_value=[_make_oauth2_creds("stale"), _make_api_key_creds("api-tok")]+ )+ mock_manager.refresh_if_needed = AsyncMock(side_effect=RuntimeError("network"))+ with patch("backend.copilot.integration_creds._manager", mock_manager):+ assert await get_provider_token(_USER, _PROVIDER, strict=True) == "api-tok"++ @pytest.mark.asyncio(loop_scope="session")+ async def test_strict_not_connected_is_still_none(self):+ mock_manager = MagicMock()+ mock_manager.store.get_creds_by_provider = AsyncMock(return_value=[])+ with patch("backend.copilot.integration_creds._manager", mock_manager):+ assert await get_provider_token(_USER, _PROVIDER, strict=True) is None+@pytest.mark.asyncio(loop_scope="session")async def test_token_cache_ttl_is_the_stale_token_ceiling(self):"""The TTL is the fallback when a pub/sub invalidation is lost."""diff --git a/autogpt_platform/backend/backend/copilot/providers.py b/autogpt_platform/backend/backend/copilot/providers.pyindex decd68ba9e..8f08fd341d 100644--- a/autogpt_platform/backend/backend/copilot/providers.py+++ b/autogpt_platform/backend/backend/copilot/providers.py@@ -17,11 +17,17 @@ class ProviderEntry(TypedDict):connected (e.g. ``["GH_TOKEN", "GITHUB_TOKEN"]``).default_scopes: Default OAuth scopes requested when the agent does notspecify any.+ swap_hosts: The only hosts the credential swap proxy may send this+ provider's token to (exact names, or ``.example.com`` for every+ subdomain). Empty means the token is never swapped in. List the+ hosts that *take* the token, not every host the provider serves+ from: a redirect target with a signed URL needs none."""name: strenv_vars: list[str]default_scopes: list[str]+ swap_hosts: list[str]def _is_github_oauth_configured() -> bool:@@ -45,6 +51,7 @@ SUPPORTED_PROVIDERS: dict[str, ProviderEntry] = {"name": "GitHub","env_vars": ["GH_TOKEN", "GITHUB_TOKEN"],"default_scopes": ["repo"],+ "swap_hosts": ["github.com", "api.github.com", "uploads.github.com"],},}diff --git a/autogpt_platform/backend/backend/copilot/swap_credentials.py b/autogpt_platform/backend/backend/copilot/swap_credentials.pynew file mode 100644index 0000000000..752c16a23c--- /dev/null+++ b/autogpt_platform/backend/backend/copilot/swap_credentials.py@@ -0,0 +1,82 @@+"""What the credential swap proxy asks the backend: bindings and values.++The proxy (``autogpt_platform/swap_proxy``) is a separate service with no+database access and no encryption key. Every box egresses through it; when a+request carries a placeholder (``hsurr:github``) it asks here for the value,+naming the user the connection belongs to and the host the request is going+to. The answer is the credential only if it is bound to that host, so the+binding is enforced on this side of the wire as well as on the proxy's.++Lookup, OAuth refresh and cache invalidation are ``get_provider_token``'s, the+same path that fills ``GH_TOKEN`` today: there is no second store.++A credential's name is its provider slug, and its hosts come from+``SUPPORTED_PROVIDERS``: that table is the binding registry until per-user+bindings exist (SECRT-2616, SECRT-2618).+"""++from typing import Optional++from pydantic import BaseModel++from backend.copilot.integration_creds import get_provider_token+from backend.copilot.providers import SUPPORTED_PROVIDERS+++class SwapCredential(BaseModel):+ """One credential as the proxy swaps it: entry name to value, and the+ only hosts it may be sent to."""++ name: str+ values: dict[str, str]+ allowed_hosts: list[str]+++def _host_is_bound(host: str, allowed_hosts: list[str]) -> bool:+ """The same rule as ``host_in_list`` in ``swap_proxy/swap_proxy/swap.py``.++ Written twice because the two packages cannot import each other (their+ dependencies conflict), and the two must never disagree: that is what+ "enforced on both sides" rests on. ``swap_credentials_test.py`` and the+ proxy's ``swap_test.py`` hold both to one table of hosts.+ """+ h = host.lower().split(":")[0]+ return any(+ h == entry or (entry.startswith(".") and h.endswith(entry))+ for entry in (e.lower() for e in allowed_hosts)+ )+++async def get_swap_bindings() -> dict[str, list[str]]:+ """Credential name to bound hosts, with no values: what lets the proxy+ leave every other host's traffic alone without asking."""+ return {+ slug: list(entry["swap_hosts"])+ for slug, entry in SUPPORTED_PROVIDERS.items()+ if entry["swap_hosts"]+ }+++async def resolve_swap_credential(+ user_id: str, name: str, host: str+) -> Optional[SwapCredential]:+ """*user_id*'s credential called *name*, if it may be sent to *host*.++ ``None`` for an unknown name, an unbound host, or a user who has not+ connected the provider: in each case the placeholder goes out as it is.+ A failure to look the token up or refresh it raises+ (``ProviderTokenUnavailable``) rather than answering ``None``: the proxy+ scrubs responses against this answer, so a failure has to reach it as an+ outage (it refuses what it cannot scrub), not as "nothing to scrub".+ """+ entry = SUPPORTED_PROVIDERS.get(name)+ if entry is None or not _host_is_bound(host, entry["swap_hosts"]):+ return None+ token = await get_provider_token(user_id, name, strict=True)+ if not token:+ return None+ return SwapCredential(+ name=name,+ values={"access_token": token},+ allowed_hosts=list(entry["swap_hosts"]),+ )diff --git a/autogpt_platform/backend/backend/copilot/swap_credentials_test.py b/autogpt_platform/backend/backend/copilot/swap_credentials_test.pynew file mode 100644index 0000000000..705af4c528--- /dev/null+++ b/autogpt_platform/backend/backend/copilot/swap_credentials_test.py@@ -0,0 +1,142 @@+"""What the swap proxy is told: a value only for a host it is bound to."""++import importlib.util+import re+from pathlib import Path+from unittest.mock import AsyncMock, patch++import pytest++from backend.copilot.integration_creds import ProviderTokenUnavailable+from backend.copilot.providers import SUPPORTED_PROVIDERS+from backend.copilot.swap_credentials import (+ SwapCredential,+ _host_is_bound,+ get_swap_bindings,+ resolve_swap_credential,+)+from backend.util import e2b_network++_M = "backend.copilot.swap_credentials"+_GITHUB_HOSTS = ["github.com", "api.github.com", "uploads.github.com"]+++def _token(value):+ return patch(f"{_M}.get_provider_token", AsyncMock(return_value=value))+++async def test_bindings_carry_hosts_and_no_values():+ assert await get_swap_bindings() == {"github": _GITHUB_HOSTS}++[email protected]("host", ["api.github.com", "GitHub.com", "github.com:443"])+async def test_a_bound_host_gets_the_users_token(host):+ with _token("ghp_real") as lookup:+ credential = await resolve_swap_credential("user-1", "github", host)+ assert credential == SwapCredential(+ name="github",+ values={"access_token": "ghp_real"},+ allowed_hosts=_GITHUB_HOSTS,+ )+ lookup.assert_awaited_once_with("user-1", "github", strict=True)+++ "host",+ [+ "evil.test",+ "api.github.com.evil.test",+ "notgithub.com",+ "raw.githubusercontent.com", # serves GitHub content, takes no token+ "",+ ],+)+async def test_an_unbound_host_gets_nothing_and_the_token_is_never_fetched(host):+ with _token("ghp_real") as lookup:+ assert await resolve_swap_credential("user-1", "github", host) is None+ lookup.assert_not_awaited()+++async def test_an_unknown_name_gets_nothing():+ with _token("ghp_real") as lookup:+ assert await resolve_swap_credential("user-1", "gitlab", "gitlab.com") is None+ lookup.assert_not_awaited()+++async def test_a_user_who_has_not_connected_the_provider_gets_nothing():+ with _token(None):+ assert await resolve_swap_credential("user-1", "github", "github.com") is None+++async def test_a_lookup_that_fails_is_an_error_not_a_user_without_a_token():+ """The proxy scrubs responses against this answer, and refuses what it+ cannot scrub only when the backend says it cannot answer."""+ failing = AsyncMock(side_effect=ProviderTokenUnavailable("github"))+ with patch(f"{_M}.get_provider_token", failing):+ with pytest.raises(ProviderTokenUnavailable):+ await resolve_swap_credential("user-1", "github", "github.com")+++def test_every_provider_says_where_its_token_may_go():+ """A new provider must decide this; an empty list means never swapped."""+ for slug, entry in SUPPORTED_PROVIDERS.items():+ assert isinstance(entry["swap_hosts"], list), slug+ for host in entry["swap_hosts"]:+ assert host == host.lower() and "/" not in host and "*" not in host, host+++def test_minted_usernames_are_what_the_proxy_accepts():+ """The proxy (swap_proxy/owners.py) looks up nothing that does not match+ this shape; the two packages cannot import each other, so it is pinned here."""+ assert re.fullmatch(r"box-[0-9a-f]{16}", e2b_network._mint().username)+++# Mirrored in swap_proxy/swap_proxy/swap_test.py; keep the two identical. The+# binding is checked on both sides of the wire, by two functions that cannot+# import each other and must not disagree.+HOST_BINDING_TABLE = [+ # (host, bound entries, may the credential go there?)+ ("api.github.com", ["api.github.com"], True),+ ("API.GitHub.com", ["api.github.com"], True),+ ("api.github.com", ["API.GITHUB.COM"], True),+ ("api.github.com:443", ["api.github.com"], True),+ ("github.com", ["api.github.com"], False),+ ("api.github.com.evil.test", ["api.github.com"], False),+ ("evilapi.github.com", ["api.github.com"], False),+ ("notgithub.com", ["github.com"], False),+ ("sub.github.com", ["github.com"], False), # exact names do not cover subdomains+ ("raw.githubusercontent.com", [".githubusercontent.com"], True),+ ("a.b.githubusercontent.com", [".githubusercontent.com"], True),+ ("githubusercontent.com", [".githubusercontent.com"], False),+ ("evilgithubusercontent.com", [".githubusercontent.com"], False),+ ("githubusercontent.com.evil.test", [".githubusercontent.com"], False),+ ("api.github.com", [], False),+ ("", ["api.github.com"], False),+ ("api.github.com", ["github.com", "api.github.com"], True),+]++[email protected]("host, entries, bound", HOST_BINDING_TABLE)+def test_host_binding_is_the_table_the_proxy_is_held_to(host, entries, bound):+ assert _host_is_bound(host, entries) is bound+++def test_the_proxys_own_copy_agrees_on_every_host():+ """``swap.py`` imports only the standard library, so it loads by path even+ though its package does not install here. Outside a full checkout there+ is nothing to load, and the mirrored table in its own suite stands alone."""+ path = Path(__file__).parents[3] / "swap_proxy" / "swap_proxy" / "swap.py"+ if not path.exists():+ return+ spec = importlib.util.spec_from_file_location("swap_proxy_swap", path)+ assert spec is not None and spec.loader is not None+ swap = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(swap)+ for host, entries, _ in HOST_BINDING_TABLE:+ assert swap.host_in_list(host, entries) is _host_is_bound(host, entries), hostdiff --git a/autogpt_platform/backend/backend/data/db_manager.py b/autogpt_platform/backend/backend/data/db_manager.pyindex 3765606811..10a550e575 100644--- a/autogpt_platform/backend/backend/data/db_manager.py+++ b/autogpt_platform/backend/backend/data/db_manager.py@@ -55,6 +55,7 @@ from backend.api.features.store.db import (from backend.api.features.store.embeddings import backfill_missing_embeddingsfrom backend.copilot import db as chat_dbfrom backend.copilot.sharing.db import link_new_execution_to_chat_share+from backend.copilot.swap_credentials import get_swap_bindings, resolve_swap_credentialfrom backend.data import bot_analytics as bot_analytics_dbfrom backend.data import bot_installs as bot_installs_dbfrom backend.data import db@@ -362,6 +363,12 @@ class DatabaseManager(AppService):get_user_credentials = _(get_user_credentials)set_user_credentials = _(set_user_credentials)+ # ============ Credential Swap Proxy ============ #+ # Called by the swap proxy (autogpt_platform/swap_proxy), which has no+ # database access of its own; see backend/copilot/swap_credentials.py.+ get_swap_bindings = _(get_swap_bindings)+ resolve_swap_credential = _(resolve_swap_credential)+# ============ User Comms ============ #get_active_user_ids_in_timerange = _(get_active_user_ids_in_timerange)get_user_email_by_id = _(get_user_email_by_id)diff --git a/autogpt_platform/backend/backend/util/e2b_network.py b/autogpt_platform/backend/backend/util/e2b_network.pyindex ead69fd9c5..61b3c4dd72 100644--- a/autogpt_platform/backend/backend/util/e2b_network.py+++ b/autogpt_platform/backend/backend/util/e2b_network.py@@ -72,9 +72,11 @@ class EgressOwner(BaseModel):"""Whose box a connection comes from: what the proxy audits and swaps for.``session`` and ``expert`` are CoPilot boxes (``SandboxOwner``); ``block``- is a graph execution's, keyed by the user. *user_id* is whose stored- credentials the proxy may swap into this box's requests; ``None`` means- none at all.+ is a graph execution's, keyed by the user. *user_id* is who the box runs+ for. Only a CoPilot box gets that user's credentials swapped in+ (``swaps``): a block runs a graph someone else may have written, and a+ marketplace agent must not get to act with the GitHub account of whoever+ runs it."""model_config = ConfigDict(frozen=True)@@ -87,6 +89,10 @@ class EgressOwner(BaseModel):def label(self) -> str:return f"{self.kind}:{self.id}"+ @property+ def swaps(self) -> bool:+ return self.kind != "block" and self.user_id is not None+class ProxyCredential(BaseModel):"""What E2B's host presents to the proxy for one running stretch of a box.@@ -279,6 +285,8 @@ async def _remember(record = {"owner": owner.label,"user_id": owner.user_id,+ # Absent or false means the proxy swaps nothing for this box.+ "swaps": owner.swaps,"sandbox_id": sandbox_id,"secret_sha256": secret_digest(credential.secret),}diff --git a/autogpt_platform/backend/backend/util/e2b_network_test.py b/autogpt_platform/backend/backend/util/e2b_network_test.pyindex d617a7a868..a071be901a 100644--- a/autogpt_platform/backend/backend/util/e2b_network_test.py+++ b/autogpt_platform/backend/backend/util/e2b_network_test.py@@ -142,12 +142,38 @@ class TestPinned:assert record == {"owner": "expert:exp-1","user_id": "user-1",+ "swaps": True,"sandbox_id": "sb-1","secret_sha256": secret_digest("s3cr3t-256-bits"),}assert "s3cr3t-256-bits" not in json.dumps(redis.store)assert redis.store["e2b:egress:box:sb-1"] == "box-a1"+ @pytest.mark.asyncio+ @pytest.mark.parametrize(+ "owner, swaps",+ [+ (EgressOwner(kind="session", id="s-1", user_id="user-1"), True),+ (EgressOwner(kind="expert", id="e-1", user_id="user-1"), True),+ (EgressOwner(kind="session", id="s-1"), False),+ # A graph someone else wrote must not act as whoever runs it.+ (EgressOwner(kind="block", id="user-1", user_id="user-1"), False),+ ],+ )+ async def test_only_a_copilot_box_with_a_user_gets_credentials_swapped_in(+ self, owner, swaps+ ):+ redis = _redis()+ minted = ProxyCredential(username="box-a1", secret="s")+ with (+ _configured(_PROXY),+ patch(f"{_M}.get_redis_async", AsyncMock(return_value=redis)),+ patch(f"{_M}._mint", return_value=minted),+ ):+ await create_sandbox(_sdk(_box()), owner, template="t")+ record = await credential_record("box-a1")+ assert record and record["swaps"] is swaps+@pytest.mark.asyncioasync def test_the_record_exists_before_the_box_does(self):"""The box's first connection must already resolve at the proxy."""diff --git a/autogpt_platform/swap_proxy/.dockerignore b/autogpt_platform/swap_proxy/.dockerignorenew file mode 100644index 0000000000..73ef916c18--- /dev/null+++ b/autogpt_platform/swap_proxy/.dockerignore@@ -0,0 +1,4 @@+**/*_test.py+**/__pycache__+.venv+.pytest_cachediff --git a/autogpt_platform/swap_proxy/Dockerfile b/autogpt_platform/swap_proxy/Dockerfilenew file mode 100644index 0000000000..1ea62d6a2d--- /dev/null+++ b/autogpt_platform/swap_proxy/Dockerfile@@ -0,0 +1,32 @@+# Build context: autogpt_platform/swap_proxy+FROM python:3.13-slim AS builder++ENV POETRY_VIRTUALENVS_IN_PROJECT=true \+ POETRY_NO_INTERACTION=1 \+ PIP_NO_CACHE_DIR=1++# Same Poetry version as the lockfile was written with.+RUN pip install "poetry==2.2.1"++WORKDIR /app+COPY pyproject.toml poetry.lock README.md ./+RUN poetry install --only main --no-root+COPY swap_proxy ./swap_proxy+RUN poetry install --only main+++FROM python:3.13-slim++RUN useradd --system --create-home --home-dir /var/lib/swap-proxy swap-proxy+COPY --from=builder /app /app++# The signing CA is not in the image and is not generated: mount the provisioned+# one (mitmproxy-ca.pem, plus mitmproxy-dhparam.pem if the mount is read-only)+# at SWAP_PROXY_CONFDIR. Without it the service refuses to start. See README.+USER swap-proxy+ENV PATH="/app/.venv/bin:$PATH" \+ PYTHONUNBUFFERED=1 \+ SWAP_PROXY_CONFDIR=/var/lib/swap-proxy/ca++EXPOSE 1080+CMD ["swap-proxy"]diff --git a/autogpt_platform/swap_proxy/README.md b/autogpt_platform/swap_proxy/README.mdnew file mode 100644index 0000000000..ef16b9a460--- /dev/null+++ b/autogpt_platform/swap_proxy/README.md@@ -0,0 +1,279 @@+# Swap proxy++The proxy every AutoPilot sandbox egresses through. Code the model writes never+holds a real credential: it holds a placeholder such as `hsurr:github`, and this+proxy replaces the placeholder with the user's real token on the way out, in+the `Authorization` header only, and only for requests going to a host that+credential is bound to.++Ported from the credential-swapping proxy in spark-vm, adapted to serve many+users at once.++## How a connection goes++1. **Who is this?** The backend pins each E2B box's egress to this proxy with a+ per-box SOCKS5 username and secret (`backend/util/e2b_network.py`) and+ records the pair's owner in Redis. The proxy looks the username up and checks+ the secret against the stored digest. No match, no connection. The record+ also says whether this owner gets credentials swapped in at all: CoPilot+ boxes do; a block's box, which may run a graph someone else wrote, does not.+ (`swap_proxy/owners.py`)+2. **Where to?** The destination is resolved and refused if it lands in private+ address space; an allowed address is pinned so the check and the connect+ agree. (`swap_proxy/egress.py`)+3. **Open it or not?** Only hosts some credential is bound to are intercepted.+ Everything else is passed through as opaque bytes, never decrypted.+4. **Swap.** A placeholder in the `Authorization` header becomes the owner's+ value: `Bearer` and `token` (curl, `gh`) and HTTP Basic, which is what git+ sends, also for a token in the remote URL (git and curl turn URL userinfo+ into this header; it never goes out as part of the URL). A placeholder+ anywhere else (another header, the path, the query, a body, a websocket+ message) goes out literally and is audited as `refused` /+ `outside-authorization`. A body is where a provider stores things: a value+ swapped into one could be written to a gist, an issue or a blob and read+ back later in whatever encoding the provider offers (base64, hex, a git+ packfile), which no scrub can match. A value in `Authorization` is used,+ not stored. The swap everywhere else is kept (`swap_anywhere` on a+ credential) for providers that need it, and arrives with the binding+ table (SECRT-2616); nothing sets it yet. The backend is asked for values+ per user and per host, and refuses hosts a credential is not bound to.+ (`swap_proxy/swap.py`, `swap_proxy/source.py`)+5. **Scrub.** A value echoed back in a text response, or in a websocket message+ from the server, is turned back into its placeholder before the box sees it,+ and so is the exact base64 of an HTTP Basic pair the proxy built, which a+ server echoing the header would send back. The values scrubbed are the+ user's current ones for that host plus any swapped into that very request. The host is the one the request and the+ connection name, proven or not: over plain http too, since removing a value+ never sends one. If the backend cannot say what the user's+ values are, a text response with a body is refused (`refused-response` /+ `resolver-unavailable`) and a server websocket message dropped+ (`refused-message`), rather than passed on unscrubbed: a value can come back+ in a response that did not ask for it, from wherever it is stored at the+ provider.+ The scrub also runs over the body's bytes, with each value as UTF-8 and as+ UTF-16, whatever charset the body declares: a body that does not decode as+ declared is scrubbed that way instead of being let through, and one the box+ reads in another charset than the proxy did is covered too.+6. **Only what can be scrubbed.** For a box that gets swaps: no swap for+ `TRACE` / `TRACK`, whose response is the request itself (`message/http`,+ not a type the scrub reads); a `101` that is not a websocket is refused+ (`unscrubbable-upgrade`); and anything but HTTP inside a connection the+ proxy opened is closed (`refused-connection` / `not-http`) rather than+ relayed as raw bytes, which nothing scrubs. A swap also needs an HTTP/1+ absolute-form target, when one is sent, to name the verified host. Plain+ protocols the proxy never opens (ssh in the clear, say) still pass.++Every swap, scrub and refusal is one JSON line on the `swap_proxy.audit` logger,+with names and reasons, never values. A swap is recorded only for bytes that had+not left yet.++### Large bodies++The proxy holds at most 5 MiB of one body in memory (`MAX_BODY_BYTES` in+`addon.py`, the only size in the service); mitmproxy streams anything larger.+A box chooses how much it sends and, by what it asks for, how much comes back,+so the size must never decide whether a credential is protected:++| | up to 5 MiB | over 5 MiB, or growing past it |+| --- | --- | --- |+| request head (the `Authorization` header) | swapped | swapped, before anything is sent |+| text request body | not swapped (audited); with `swap_anywhere`, swapped | streamed, not swapped; with `swap_anywhere`, sent as it is and audited `body-not-swapped` |+| text response body | scrubbed | **refused**: the flow is killed; audited `refused-response` |+| binary body, either way | streamed, untouched | streamed, untouched |++The 5 MiB counts bytes on the wire, and a compressed body stands for more, so a+held body with a `Content-Encoding` has a second limit on what it may decode to:+20 MiB (`MAX_DECODED_BYTES`, four times the wire limit). The limit is enforced+while decoding (`decode.py` asks each decoder for at most that much), never by+decoding the whole body and measuring it, so a few kilobytes of gzip standing+for gigabytes cost the proxy no more than 20 MiB and are then turned away:++| a held text body that… | request (with `swap_anywhere` only) | response |+| --- | --- | --- |+| decodes to more than 20 MiB | sent as it is; audited `body-not-swapped` / `decoded-too-large` | **refused**; audited `refused-response` / `decoded-too-large` |+| is in an encoding that cannot be decoded within a bound (anything but `gzip`, `deflate`, `br`, `zstd`, or more than one), or is corrupt | sent as it is; audited `body-not-swapped` / `undecodable-encoding` | **refused**; audited `refused-response` / `undecodable-encoding` |++A request body the proxy will not decode may or may not name a credential;+nobody can say without decoding it. It goes out untouched, which is the safe+direction, and the head of the request is still swapped. A response the proxy+cannot read is one the box could still decode, so it is not passed on. Both+only apply to a box that gets swaps and a user with a credential for the host:+for anyone else there is nothing to swap or scrub and the body is not read.++So a `git push` with a large pack authenticates (its body is binary and+streams), and a text response too large to scrub never reaches the box. A+request body is held back only for a credential with `swap_anywhere`; by+default nothing can be swapped into it, and it streams. A body with no declared+length (chunked, HTTP/2) that is held is held until it ends or passes the+limit, so a value split across chunks is still caught.++A value is only ever swapped into an https request whose upstream certificate+mitmproxy verified for the very host the request names. If the backend cannot+be asked, nothing is swapped: the placeholder goes out literally and the request+fails at the provider, loudly and with nothing leaked.++## Why a separate package++mitmproxy pins its dependencies exactly and needs Python 3.12+, and the E2B SDK+the backend depends on needs a newer `h2` than mitmproxy allows, so the two+cannot share an environment. The split is also the safer one: this is the+service that faces the internet and terminates TLS, and it has no database+access and no encryption key. It gets values from the backend one user and one+host at a time.++## Running it++```bash+poetry install+poetry run swap-proxy+```++| Variable | Default | |+| --- | --- | --- |+| `SWAP_PROXY_LISTEN_HOST` / `SWAP_PROXY_LISTEN_PORT` | `0.0.0.0` / `1080` | SOCKS5 listener |+| `SWAP_PROXY_BACKEND_URL` | `http://localhost:8005` | the backend's internal `DatabaseManager` service |+| `SWAP_PROXY_CONFDIR` | `~/.mitmproxy` | directory the signing CA is mounted into; see below |+| `SWAP_PROXY_GENERATE_CA` | `false` | local runs only: generate a CA if the directory has none |+| `SWAP_PROXY_EGRESS_ALLOW` | empty | comma-separated private hosts or CIDRs boxes may reach anyway |+| `REDIS_HOST`, `REDIS_PORT`, `REDIS_PASSWORD`, `REDIS_CLUSTER_HOST`, `REDIS_CLUSTER_PORT`, `REDIS_USE_ANNOUNCED_ADDRESS` | | same meaning as in the backend |++### The signing CA++The boxes' image trusts one CA certificate, and the proxy signs the certificate+of every bound host with that CA's key. So:++- **One CA for every replica and every restart.** A replica that signed with a+ CA of its own would break TLS to every bound host inside every box, and it+ would read there as a certificate bug, not as missing provisioning.+- **Provisioned, never generated.** Create the key pair once, keep it in your+ secret store, and mount it into `SWAP_PROXY_CONFDIR` as `mitmproxy-ca.pem`+ (private key and certificate in one PEM file). If the mount is read-only, put+ `mitmproxy-dhparam.pem` beside it: it is not a secret (fixed public+ parameters mitmproxy writes out with every CA), but mitmproxy tries to create+ it when it is missing. The service **refuses to start** without the CA rather+ than let mitmproxy make one up. `SWAP_PROXY_GENERATE_CA=true` lifts that for+ a local run; `mitmproxy-ca-cert.pem` in the directory is then the certificate+ to trust.+- **The key lives in the secret store and in the running proxy, nowhere else.**+ Whoever holds it can read the traffic of every bound host. It is not in the+ image, the repository or a box.+- **Rotation is a coordinated change**: boxes must trust the new certificate+ before the proxy starts signing with the new key.++### Turning it on++The backend only sends boxes here once `E2B_EGRESS_PROXY_ADDRESS` is set, and+E2B fails closed. Setting that address and provisioning the CA are **one release+step**: the proxy reachable at that address, the CA mounted into every replica,+and its certificate in the image the boxes run. Any one of them missing shows up+as every box losing either its egress or its TLS to bound hosts.++The same step sets the network policy around the proxy, and that policy is a+security boundary, not housekeeping. The proxy calls one backend service+(`SWAP_PROXY_BACKEND_URL`, the internal `DatabaseManager`) and must be able to+reach that and nothing else in the backend: the policy is what keeps a+compromised proxy away from every other backend service.++It cannot do more than that. `DatabaseManager` serves every method it exposes+on the same port, with no caller authentication or per-caller allowlist, and+the proxy uses only two of them (`get_swap_bindings`,+`resolve_swap_credential`). A proxy that can reach it can call all of them,+reading any user's credentials among them. Restricting it to the two swap+methods needs a dedicated service or a per-caller allowlist (SECRT-2742);+until then that is an accepted gap, and one more reason the proxy's own host+is to be treated as holding every user's credentials.++### What one message costs the event loop++The swap and the scrub run synchronously on mitmproxy's event loop, which every+connection of a replica shares. Measured on a developer laptop (Apple silicon,+Python 3.13), one body at the 5 MiB limit, median of several runs:++| work | time |+| --- | --- |+| swap a JSON request body | 23 ms |+| scrub a JSON or plain-text response | 2-3 ms |+| scan a gzip response with nothing to scrub (decode included) | 8 ms |+| scrub a gzip response that did echo a value (decode, scrub, re-encode) | 53 ms |++That is how long every other connection on the replica waits while one such+message is handled; a box can cause it at will, one message at a time. These+are single-machine numbers, not a capacity figure: how many boxes a replica+carries has not been measured, and server CPUs will differ. The table is for+5 MiB of decoded text. A compressed body may decode to up to 20 MiB, so the+worst single message costs about four times the gzip rows.++## Tests++```bash+poetry run pytest+```++`e2e_test.py` and `e2e_tls_test.py` run the real proxy on loopback with a+hand-written SOCKS5 client in front and a local server behind; they are where+the tenant boundary is tested (wrong, stale and borrowed credentials). The+rest are unit tests, `swap_test.py` being the port of spark-vm's conformance+suite. `addon_test.py` drives the hooks with mitmproxy's own test flows for what+a hand-written HTTP/1 client cannot reach (websockets, HTTP/2 framing).++CI is `.github/workflows/platform-swap-proxy-ci.yml`. Its `pull_request`+trigger only fires for a base of `master`/`dev`/`release-*`; for a stacked PR+run it by hand: `gh workflow run platform-swap-proxy-ci.yml --ref <branch>`.++## Not here yet++- Per-user bindings and more providers: the binding table is+ `SUPPORTED_PROVIDERS[...]["swap_hosts"]` in the backend, GitHub only.+- Time-limited grants and the approval step that spark-vm has.+- E2B tunnels TCP only: DNS and QUIC leave a box without passing through here.++## Known limits++- Images and binary bodies are neither swapped (above 5 MiB) nor scrubbed (at+ any size). What counts as text is the content type the sender declares.+- A value goes into the `Authorization` header and nowhere else. A provider+ that takes its key in another header, the query or a body cannot be used+ until the binding table opts that credential in (`swap_anywhere`,+ SECRT-2616).+- Only literal values are scrubbed, and the exact Basic pairs the proxy built.+ The same value in another encoding (base64, hex, inside an archive) is not+ recognised. With the swap confined to `Authorization`, no value is written+ into a request body through the proxy, which is how one would come to be+ stored at a provider and served back so encoded; one stored there by other+ means (by the user, say) is not caught.+- A text response over 5 MiB from a bound host is refused, not delivered, for a+ box that gets swaps.+- A compressed text response from a bound host that decodes to more than+ 20 MiB, or uses an encoding other than `gzip`, `deflate`, `br` or `zstd` (or+ several at once), is refused for a box that gets swaps; a request body like+ that is not swapped (with `swap_anywhere`; otherwise it is never swapped).+- The decoded-size limit covers HTTP bodies. Websocket messages are+ decompressed by mitmproxy before the addon sees them, with no limit of ours.+- A text response with no declared length is held until it is complete, so an+ event stream from a bound host does not arrive incrementally.+- Websocket messages are swapped and scrubbed one message at a time; a value+ split across two messages is not recognised.+- While the backend cannot be asked, a box that gets swaps receives no text+ response with a body and no server websocket message from a bound host+ (each refused and audited), and nothing is swapped into its requests beyond+ the 15 s a fetched value stays cached. Binary responses still pass, as they+ are never scrubbed. Boxes that do not get swaps are unaffected. If the+ proxy has never had an answer from the backend since it started, it cannot+ tell bound hosts from others: a swapping box's TLS connections are then+ opened whatever their host, and the same refusals apply to all of them until+ the backend first answers.+- Only bound hosts are scrubbed. A value stored at a provider and served back+ from a host that is not bound (a raw-content domain, say) passes through+ unread. The name is the box's to+ choose: TLS to a provider's address under an SNI that is not bound, or plain+ http with such a `Host`, is the same case. For a box that gets swaps, TLS+ with no SNI at all and plain http to a bare address are refused+ (`refused-connection` / `refused-request`, reason `no-sni`); that narrows+ the case, it does not close it.+- A body in gzip or zstd may hold at most 64 members or frames; more is+ treated as undecodable.+- A connection stays authenticated while it stays open, also after its box's+ credential is rotated.+- NAT64 (`64:ff9b::/96`, and its local-use prefix) and 6to4 addresses are judged+ by the IPv4 address they carry. Teredo and operator-chosen NAT64 prefixes are+ not recognised.diff --git a/autogpt_platform/swap_proxy/poetry.lock b/autogpt_platform/swap_proxy/poetry.locknew file mode 100644index 0000000000..27869848e2--- /dev/null+++ b/autogpt_platform/swap_proxy/poetry.lock@@ -0,0 +1,1711 @@+# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand.++[[package]]+name = "aioquic"+version = "1.2.0"+description = "An implementation of QUIC and HTTP/3"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "aioquic-1.2.0-cp38-abi3-macosx_10_9_x86_64.whl", hash = "sha256:3e23964dfb04526ade6e66f5b7cd0c830421b8138303ab60ba6e204015e7cb0b"},+ {file = "aioquic-1.2.0-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:84d733332927b76218a3b246216104116f766f5a9b2308ec306cd017b3049660"},+ {file = "aioquic-1.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2466499759b31ea4f1d17f4aeb1f8d4297169e05e3c1216d618c9757f4dd740d"},+ {file = "aioquic-1.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cd75015462ca5070a888110dc201f35a9f4c7459f9201b77adc3c06013611bb8"},+ {file = "aioquic-1.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43ae3b11d43400a620ca0b4b4885d12b76a599c2cbddba755f74bebfa65fe587"},+ {file = "aioquic-1.2.0-cp38-abi3-win32.whl", hash = "sha256:910d8c91da86bba003d491d15deaeac3087d1b9d690b9edc1375905d8867b742"},+ {file = "aioquic-1.2.0-cp38-abi3-win_amd64.whl", hash = "sha256:e3dcfb941004333d477225a6689b55fc7f905af5ee6a556eb5083be0354e653a"},+ {file = "aioquic-1.2.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:8e600da7aa7e4a7bc53ee8f45fd66808032127ae00938c119ac77d66633b8961"},+ {file = "aioquic-1.2.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:358e2b9c1e0c24b9933094c3c2cf990faf44d03b64d6f8ff79b4b3f510c6c268"},+ {file = "aioquic-1.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fe683943ea3439dd0aca05ff80e85a552d4b39f9f34858c76ac54c205990e88"},+ {file = "aioquic-1.2.0-pp310-pypy310_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c22689c33fe4799624aed6faaba0af9e6ea7d31ac45047745828ee68d67fe1d9"},+ {file = "aioquic-1.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3976b75e82d83742c8b811e38d273eda2ca7f81394b6a85da33a02849c5f1d9d"},+ {file = "aioquic-1.2.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:cbe7167b2faee887e115d83d25332c4b8fa4604d5175807d978cb4fe39b4e36e"},+ {file = "aioquic-1.2.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:f81e7946f09501a7c27e3f71b84a455e6bf92346fb5a28ef2d73c9d564463c63"},+ {file = "aioquic-1.2.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:e2c3c127cc3d9eac7a6d05142036bf4b2c593d750a115a2fa42c1f86cbe8c0a0"},+ {file = "aioquic-1.2.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb917143e7a4de5beba1e695fa89f2b05ef080b450dea07338cc67a9c75e0a4d"},+ {file = "aioquic-1.2.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1de513772fd04ff38028fdf748a9e2dec33d7aa2fbf67fda3011d9a85b620c54"},+ {file = "aioquic-1.2.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7dcc212bb529900757d8e99a76198b42c2a978ce735a1bfca394033c16cfc33c"},+ {file = "aioquic-1.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e7ce10198f8efa91986ad8ac83fa08e50972e0aacde45bdaf7b9365094e72c0c"},+ {file = "aioquic-1.2.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:6e418c92898a0af306e6f1b6a55a0d3d2597001c57a7b1ba36cf5b47bf41233b"},+ {file = "aioquic-1.2.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:81650d59bef05c514af2cfdcb2946e9d13367b745e68b36881d43630ef563d38"},+ {file = "aioquic-1.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6371c3afa1036294e1505fdbda8c147bc41c5b6709a47459e8c1b4eec41a86ef"},+ {file = "aioquic-1.2.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c332cffa3c2124e5db82b2b9eb2662bd7c39ee2247606b74de689f6d3091b61a"},+ {file = "aioquic-1.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fcc1eb083ed9f8d903482e375281c8c26a5ed2b6bee5ee2be3f13275d8fdb146"},+ {file = "aioquic-1.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:f209ad5edbff8239e994c189dc74428420957448a190f4343faee4caedef4eee"},+ {file = "aioquic-1.2.0.tar.gz", hash = "sha256:f91263bb3f71948c5c8915b4d50ee370004f20a416f67fab3dcc90556c7e7199"},+]++[package.dependencies]+certifi = "*"+cryptography = ">=42.0.0"+pylsqpack = ">=0.3.3,<0.4.0"+pyopenssl = ">=24"+service-identity = ">=24.1.0"++[package.extras]+dev = ["coverage[toml] (>=7.2.2)"]++[[package]]+name = "anyio"+version = "4.14.2"+description = "High-level concurrency and networking framework on top of asyncio or Trio"+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "anyio-4.14.2-py3-none-any.whl", hash = "sha256:9f505dda5ac9f0c8309b5e8bd445a8c2bf7246f3ce950121e45ea15bc41d1494"},+ {file = "anyio-4.14.2.tar.gz", hash = "sha256:cfa139f3ed1a23ee8f88a145ddb5ac7605b8bbfd8592baacd7ce3d8bb4313c7f"},+]++[package.dependencies]+idna = ">=2.8"+typing_extensions = {version = ">=4.5", markers = "python_version < \"3.13\""}++[package.extras]+trio = ["trio (>=0.32.0)"]++[[package]]+name = "argon2-cffi"+version = "25.1.0"+description = "Argon2 for Python"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "argon2_cffi-25.1.0-py3-none-any.whl", hash = "sha256:fdc8b074db390fccb6eb4a3604ae7231f219aa669a2652e0f20e16ba513d5741"},+ {file = "argon2_cffi-25.1.0.tar.gz", hash = "sha256:694ae5cc8a42f4c4e2bf2ca0e64e51e23a040c6a517a85074683d3959e1346c1"},+]++[package.dependencies]+argon2-cffi-bindings = "*"++[[package]]+name = "argon2-cffi-bindings"+version = "26.1.0"+description = "Low-level CFFI bindings for Argon2"+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:21ca0396fe5ec995dd54431c32698189666f9224810acfa752e50d2bd94d9df2"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:78de2d65e0b9ea7ce9d1b1c3e87297b2d7305a02c266ee2a2d6910daddd7ee69"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:27f1821903e2ceadcb88ec2b45ef190897b7682449c772f4d9b53e42c520cf29"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:d88e5f7e60f28ae0b0cc6b2f16c43e87cd642a196a86f85e0d8bb6fe016fc16d"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:34b7d9c24a4165a2c61cc8ae11d44d48c9ce2830fb536cb7914e11fdd9962728"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:224865cbbcb7a2bd1356741dff12b0134df726b6d44bb7b500df8e303cbd9e81"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ffff613aaa9ce6236766e2fc6dc560bb5abde7a2e2416e3db1f9ae395a2b4dd4"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-win32.whl", hash = "sha256:a86c069c91a747a2c4e5c51473590aeb48172fff9b2130d23729a42d98665ecb"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-win_amd64.whl", hash = "sha256:2c36ff87b5dfaa477d0bd51e9d7f6abdae7c8955d2983c97419085d842154b3e"},+ {file = "argon2_cffi_bindings-26.1.0-cp310-abi3-win_arm64.whl", hash = "sha256:f9c4420a7a864fe1b86ce35befc95b8e39fb852493b81cf798671ddc265de638"},+ {file = "argon2_cffi_bindings-26.1.0-cp313-cp313-pyemscripten_2025_0_wasm32.whl", hash = "sha256:af11ac37a7c53dc16cb7950a6190851b0870fe218b6c60c0bb7ac355234e3083"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:db0fcd827ca61622a01b220aadfbece01939acf53888f2cb98cd93e9b1e2c97e"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:28524438cd3e723f25412f63d4fd516ff5bae9ae5aa56acbe2a1404398a0cf31"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ac82fc756a446b6ccd7139ce70efa9d8bbe541e7ad579a12dcb52764b7175c5f"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6a4e68eed961a8de6928d1c17ff3dc2a547e0e923c17f8f1cd79fb7bc9502f98"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:151dfaad9de753f4af2a7854e707e4784f2acc434340ade64239c5b104b2d605"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:061a6919145bbf282ebf1f9c59d3135d4833c25313c8595c0d68cf7712ddfce2"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:62ff20cd130c956c7c9144d5fe35228f98b51c579b2439e988b27ef93e16c02a"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:19423e5d7ac1cc354baab59eaabf18db2ec04ef6593b5abe5a34f323c4a8f87a"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-win32.whl", hash = "sha256:4f84cdd868978d7b7350a566c254042d44216d9e37f241f3a6d3b1dfebeede35"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-win_amd64.whl", hash = "sha256:2b741888c93147444fdfc851abd81cc207f37f7f7da42062a00deb3888e57da8"},+ {file = "argon2_cffi_bindings-26.1.0-cp314-cp314t-win_arm64.whl", hash = "sha256:6ab674f668d5962a3a4136ae0812519b0f1586874263723a32181d60d64137e1"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:1d98e33bd8bd67d7206c124e200bf2229c4cfa8c9c19f7b44a897f0fc71837eb"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ccaf0a46cbb380f1fd102a874e32aa629fd3cb0c0e94f4943fa1f6d5edc5dac6"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f0c3103fcff20183e593459cfea6e012281c0e76ae3ed8b5565ad1b92eac3990"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c49e853a3bef9dd10329f31f702e7fa9b5c58229ff9c2ff6d069efaf09177c08"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:6376d4b3aca039375ca8bf92f770da0ec424a1ce3a37077a8d3c557411aa56ca"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:9bacedc04b0402837586a17f0919e3dfdd95291f441f1f56bd80ec274c2840a1"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:76ae29acace5d33355344612844d588e19deaaba4639d8bb01601e4b1418ef36"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-win32.whl", hash = "sha256:df612391feca41c44d20118f3b88d1b86419465cd1f5496859f715ca60ec2210"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-win_amd64.whl", hash = "sha256:1a0a29ed86960e44eaace7e081bdfab4f08b012fd96ec8edba71e2ad020939e4"},+ {file = "argon2_cffi_bindings-26.1.0-cp315-cp315t-win_arm64.whl", hash = "sha256:d157ddfab1e8b21f2f1dedda9c09645d98b5ed0b667b0626be600a345d426440"},+ {file = "argon2_cffi_bindings-26.1.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:7014ab7e6f5d8511af92544667a0346ea6dfc314ea9a7cad1dba9fdb5c9a6e33"},+ {file = "argon2_cffi_bindings-26.1.0-pp310-pypy310_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:242bb0cda2ae3650764fc194593d9ea45fc9e72729acd89778c7cfe184cec2a5"},+ {file = "argon2_cffi_bindings-26.1.0-pp310-pypy310_pp73-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b70225b5fd1e0d2ef4f7fd30d24658454535f0924dff0caca5dc08efbbbadfbb"},+ {file = "argon2_cffi_bindings-26.1.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:1af817e84578ef8b7295ad17de0f9896e4c8520dbf2233c7aa5aa3d487256fc4"},+ {file = "argon2_cffi_bindings-26.1.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:19b562b1de4b9052ef1214a2821c44b6e6f22945daa102c32ae4eff929d8b6d8"},+ {file = "argon2_cffi_bindings-26.1.0-pp311-pypy311_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:49d525938467d52c923a890153c99087c9d5a937d1f6b585dbdba34ec82e397a"},+ {file = "argon2_cffi_bindings-26.1.0-pp311-pypy311_pp73-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1b0bcac4d490a237e18cf91f57352920c29f77f2fa39efd0813fb81298bf17ba"},+ {file = "argon2_cffi_bindings-26.1.0-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:0cc40f7b4050bb93eb67de95d2d759322fc7ce4930b9d645581ecf4913ec651e"},+ {file = "argon2_cffi_bindings-26.1.0.tar.gz", hash = "sha256:63505c71542a44b68b1e38060450fb006404170da375feb31af153e7f9c6205d"},+]++[package.dependencies]+cffi = {version = ">=1.0.1", markers = "python_version < \"3.14\""}++[[package]]+name = "asgiref"+version = "3.11.1"+description = "ASGI specs, helper code, and adapters"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "asgiref-3.11.1-py3-none-any.whl", hash = "sha256:e8667a091e69529631969fd45dc268fa79b99c92c5fcdda727757e52146ec133"},+ {file = "asgiref-3.11.1.tar.gz", hash = "sha256:5f184dc43b7e763efe848065441eac62229c9f7b0475f41f80e207a114eda4ce"},+]++[package.extras]+tests = ["mypy (>=1.14.0)", "pytest", "pytest-asyncio"]++[[package]]+name = "attrs"+version = "26.1.0"+description = "Classes Without Boilerplate"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309"},+ {file = "attrs-26.1.0.tar.gz", hash = "sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32"},+]++[[package]]+name = "bcrypt"+version = "5.0.0"+description = "Modern password hashing for your software and your servers"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "bcrypt-5.0.0-cp313-cp313t-macosx_10_12_universal2.whl", hash = "sha256:f3c08197f3039bec79cee59a606d62b96b16669cff3949f21e74796b6e3cd2be"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:200af71bc25f22006f4069060c88ed36f8aa4ff7f53e67ff04d2ab3f1e79a5b2"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:baade0a5657654c2984468efb7d6c110db87ea63ef5a4b54732e7e337253e44f"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:c58b56cdfb03202b3bcc9fd8daee8e8e9b6d7e3163aa97c631dfcfcc24d36c86"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:4bfd2a34de661f34d0bda43c3e4e79df586e4716ef401fe31ea39d69d581ef23"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:ed2e1365e31fc73f1825fa830f1c8f8917ca1b3ca6185773b349c20fd606cec2"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux_2_34_aarch64.whl", hash = "sha256:83e787d7a84dbbfba6f250dd7a5efd689e935f03dd83b0f919d39349e1f23f83"},+ {file = "bcrypt-5.0.0-cp313-cp313t-manylinux_2_34_x86_64.whl", hash = "sha256:137c5156524328a24b9fac1cb5db0ba618bc97d11970b39184c1d87dc4bf1746"},+ {file = "bcrypt-5.0.0-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:38cac74101777a6a7d3b3e3cfefa57089b5ada650dce2baf0cbdd9d65db22a9e"},+ {file = "bcrypt-5.0.0-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:d8d65b564ec849643d9f7ea05c6d9f0cd7ca23bdd4ac0c2dbef1104ab504543d"},+ {file = "bcrypt-5.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:741449132f64b3524e95cd30e5cd3343006ce146088f074f31ab26b94e6c75ba"},+ {file = "bcrypt-5.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:212139484ab3207b1f0c00633d3be92fef3c5f0af17cad155679d03ff2ee1e41"},+ {file = "bcrypt-5.0.0-cp313-cp313t-win32.whl", hash = "sha256:9d52ed507c2488eddd6a95bccee4e808d3234fa78dd370e24bac65a21212b861"},+ {file = "bcrypt-5.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:f6984a24db30548fd39a44360532898c33528b74aedf81c26cf29c51ee47057e"},+ {file = "bcrypt-5.0.0-cp313-cp313t-win_arm64.whl", hash = "sha256:9fffdb387abe6aa775af36ef16f55e318dcda4194ddbf82007a6f21da29de8f5"},+ {file = "bcrypt-5.0.0-cp314-cp314t-macosx_10_12_universal2.whl", hash = "sha256:4870a52610537037adb382444fefd3706d96d663ac44cbb2f37e3919dca3d7ef"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:48f753100931605686f74e27a7b49238122aa761a9aefe9373265b8b7aa43ea4"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f70aadb7a809305226daedf75d90379c397b094755a710d7014b8b117df1ebbf"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:744d3c6b164caa658adcb72cb8cc9ad9b4b75c7db507ab4bc2480474a51989da"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a28bc05039bdf3289d757f49d616ab3efe8cf40d8e8001ccdd621cd4f98f4fc9"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:7f277a4b3390ab4bebe597800a90da0edae882c6196d3038a73adf446c4f969f"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:79cfa161eda8d2ddf29acad370356b47f02387153b11d46042e93a0a95127493"},+ {file = "bcrypt-5.0.0-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:a5393eae5722bcef046a990b84dff02b954904c36a194f6cfc817d7dca6c6f0b"},+ {file = "bcrypt-5.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:7f4c94dec1b5ab5d522750cb059bb9409ea8872d4494fd152b53cca99f1ddd8c"},+ {file = "bcrypt-5.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0cae4cb350934dfd74c020525eeae0a5f79257e8a201c0c176f4b84fdbf2a4b4"},+ {file = "bcrypt-5.0.0-cp314-cp314t-win32.whl", hash = "sha256:b17366316c654e1ad0306a6858e189fc835eca39f7eb2cafd6aaca8ce0c40a2e"},+ {file = "bcrypt-5.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:92864f54fb48b4c718fc92a32825d0e42265a627f956bc0361fe869f1adc3e7d"},+ {file = "bcrypt-5.0.0-cp314-cp314t-win_arm64.whl", hash = "sha256:dd19cf5184a90c873009244586396a6a884d591a5323f0e8a5922560718d4993"},+ {file = "bcrypt-5.0.0-cp38-abi3-macosx_10_12_universal2.whl", hash = "sha256:fc746432b951e92b58317af8e0ca746efe93e66555f1b40888865ef5bf56446b"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c2388ca94ffee269b6038d48747f4ce8df0ffbea43f31abfa18ac72f0218effb"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:560ddb6ec730386e7b3b26b8b4c88197aaed924430e7b74666a586ac997249ef"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:d79e5c65dcc9af213594d6f7f1fa2c98ad3fc10431e7aa53c176b441943efbdd"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2b732e7d388fa22d48920baa267ba5d97cca38070b69c0e2d37087b381c681fd"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:0c8e093ea2532601a6f686edbc2c6b2ec24131ff5c52f7610dd64fa4553b5464"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:5b1589f4839a0899c146e8892efe320c0fa096568abd9b95593efac50a87cb75"},+ {file = "bcrypt-5.0.0-cp38-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:89042e61b5e808b67daf24a434d89bab164d4de1746b37a8d173b6b14f3db9ff"},+ {file = "bcrypt-5.0.0-cp38-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:e3cf5b2560c7b5a142286f69bde914494b6d8f901aaa71e453078388a50881c4"},+ {file = "bcrypt-5.0.0-cp38-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f632fd56fc4e61564f78b46a2269153122db34988e78b6be8b32d28507b7eaeb"},+ {file = "bcrypt-5.0.0-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:801cad5ccb6b87d1b430f183269b94c24f248dddbbc5c1f78b6ed231743e001c"},+ {file = "bcrypt-5.0.0-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:3cf67a804fc66fc217e6914a5635000259fbbbb12e78a99488e4d5ba445a71eb"},+ {file = "bcrypt-5.0.0-cp38-abi3-win32.whl", hash = "sha256:3abeb543874b2c0524ff40c57a4e14e5d3a66ff33fb423529c88f180fd756538"},+ {file = "bcrypt-5.0.0-cp38-abi3-win_amd64.whl", hash = "sha256:35a77ec55b541e5e583eb3436ffbbf53b0ffa1fa16ca6782279daf95d146dcd9"},+ {file = "bcrypt-5.0.0-cp38-abi3-win_arm64.whl", hash = "sha256:cde08734f12c6a4e28dc6755cd11d3bdfea608d93d958fffbe95a7026ebe4980"},+ {file = "bcrypt-5.0.0-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:0c418ca99fd47e9c59a301744d63328f17798b5947b0f791e9af3c1c499c2d0a"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddb4e1500f6efdd402218ffe34d040a1196c072e07929b9820f363a1fd1f4191"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:7aeef54b60ceddb6f30ee3db090351ecf0d40ec6e2abf41430997407a46d2254"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f0ce778135f60799d89c9693b9b398819d15f1921ba15fe719acb3178215a7db"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a71f70ee269671460b37a449f5ff26982a6f2ba493b3eabdd687b4bf35f875ac"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f8429e1c410b4073944f03bd778a9e066e7fad723564a52ff91841d278dfc822"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:edfcdcedd0d0f05850c52ba3127b1fce70b9f89e0fe5ff16517df7e81fa3cbb8"},+ {file = "bcrypt-5.0.0-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:611f0a17aa4a25a69362dcc299fda5c8a3d4f160e2abb3831041feb77393a14a"},+ {file = "bcrypt-5.0.0-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:db99dca3b1fdc3db87d7c57eac0c82281242d1eabf19dcb8a6b10eb29a2e72d1"},+ {file = "bcrypt-5.0.0-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:5feebf85a9cefda32966d8171f5db7e3ba964b77fdfe31919622256f80f9cf42"},+ {file = "bcrypt-5.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:3ca8a166b1140436e058298a34d88032ab62f15aae1c598580333dc21d27ef10"},+ {file = "bcrypt-5.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:61afc381250c3182d9078551e3ac3a41da14154fbff647ddf52a769f588c4172"},+ {file = "bcrypt-5.0.0-cp39-abi3-win32.whl", hash = "sha256:64d7ce196203e468c457c37ec22390f1a61c85c6f0b8160fd752940ccfb3a683"},+ {file = "bcrypt-5.0.0-cp39-abi3-win_amd64.whl", hash = "sha256:64ee8434b0da054d830fa8e89e1c8bf30061d539044a39524ff7dec90481e5c2"},+ {file = "bcrypt-5.0.0-cp39-abi3-win_arm64.whl", hash = "sha256:f2347d3534e76bf50bca5500989d6c1d05ed64b440408057a37673282c654927"},+ {file = "bcrypt-5.0.0-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:7edda91d5ab52b15636d9c30da87d2cc84f426c72b9dba7a9b4fe142ba11f534"},+ {file = "bcrypt-5.0.0-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:046ad6db88edb3c5ece4369af997938fb1c19d6a699b9c1b27b0db432faae4c4"},+ {file = "bcrypt-5.0.0-pp311-pypy311_pp73-manylinux_2_34_aarch64.whl", hash = "sha256:dcd58e2b3a908b5ecc9b9df2f0085592506ac2d5110786018ee5e160f28e0911"},+ {file = "bcrypt-5.0.0-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl", hash = "sha256:6b8f520b61e8781efee73cba14e3e8c9556ccfb375623f4f97429544734545b4"},+ {file = "bcrypt-5.0.0.tar.gz", hash = "sha256:f748f7c2d6fd375cc93d3fba7ef4a9e3a092421b8dbf34d8d4dc06be9492dfdd"},+]++[package.extras]+tests = ["pytest (>=3.2.1,!=3.3.0)"]+typecheck = ["mypy"]++[[package]]+name = "black"+version = "24.10.0"+description = "The uncompromising code formatter."+optional = false+python-versions = ">=3.9"+groups = ["dev"]+files = [+ {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"},+ {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"},+ {file = "black-24.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:649fff99a20bd06c6f727d2a27f401331dc0cc861fb69cde910fe95b01b5928f"},+ {file = "black-24.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:fe4d6476887de70546212c99ac9bd803d90b42fc4767f058a0baa895013fbb3e"},+ {file = "black-24.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5a2221696a8224e335c28816a9d331a6c2ae15a2ee34ec857dcf3e45dbfa99ad"},+ {file = "black-24.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f9da3333530dbcecc1be13e69c250ed8dfa67f43c4005fb537bb426e19200d50"},+ {file = "black-24.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4007b1393d902b48b36958a216c20c4482f601569d19ed1df294a496eb366392"},+ {file = "black-24.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:394d4ddc64782e51153eadcaaca95144ac4c35e27ef9b0a42e121ae7e57a9175"},+ {file = "black-24.10.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b5e39e0fae001df40f95bd8cc36b9165c5e2ea88900167bddf258bacef9bbdc3"},+ {file = "black-24.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d37d422772111794b26757c5b55a3eade028aa3fde43121ab7b673d050949d65"},+ {file = "black-24.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14b3502784f09ce2443830e3133dacf2c0110d45191ed470ecb04d0f5f6fcb0f"},+ {file = "black-24.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:30d2c30dc5139211dda799758559d1b049f7f14c580c409d6ad925b74a4208a8"},+ {file = "black-24.10.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1cbacacb19e922a1d75ef2b6ccaefcd6e93a2c05ede32f06a21386a04cedb981"},+ {file = "black-24.10.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1f93102e0c5bb3907451063e08b9876dbeac810e7da5a8bfb7aeb5a9ef89066b"},+ {file = "black-24.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ddacb691cdcdf77b96f549cf9591701d8db36b2f19519373d60d31746068dbf2"},+ {file = "black-24.10.0-cp313-cp313-win_amd64.whl", hash = "sha256:680359d932801c76d2e9c9068d05c6b107f2584b2a5b88831c83962eb9984c1b"},+ {file = "black-24.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:17374989640fbca88b6a448129cd1745c5eb8d9547b464f281b251dd00155ccd"},+ {file = "black-24.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:63f626344343083322233f175aaf372d326de8436f5928c042639a4afbbf1d3f"},+ {file = "black-24.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccfa1d0cb6200857f1923b602f978386a3a2758a65b52e0950299ea014be6800"},+ {file = "black-24.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:2cd9c95431d94adc56600710f8813ee27eea544dd118d45896bb734e9d7a0dc7"},+ {file = "black-24.10.0-py3-none-any.whl", hash = "sha256:3bb2b7a1f7b685f85b11fed1ef10f8a9148bceb49853e47a294a3dd963c1dd7d"},+ {file = "black-24.10.0.tar.gz", hash = "sha256:846ea64c97afe3bc677b761787993be4991810ecc7a4a937816dd6bddedc4875"},+]++[package.dependencies]+click = ">=8.0.0"+mypy-extensions = ">=0.4.3"+packaging = ">=22.0"+pathspec = ">=0.9.0"+platformdirs = ">=2"++[package.extras]+colorama = ["colorama (>=0.4.3)"]+d = ["aiohttp (>=3.10)"]+jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]+uvloop = ["uvloop (>=0.15.2)"]++[[package]]+name = "blinker"+version = "1.9.0"+description = "Fast, simple object-to-object and broadcast signaling"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc"},+ {file = "blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf"},+]++[[package]]+name = "brotli"+version = "1.2.0"+description = "Python bindings for the Brotli compression library"+optional = false+python-versions = "*"+groups = ["main"]+files = [+ {file = "brotli-1.2.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:99cfa69813d79492f0e5d52a20fd18395bc82e671d5d40bd5a91d13e75e468e8"},+ {file = "brotli-1.2.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:3ebe801e0f4e56d17cd386ca6600573e3706ce1845376307f5d2cbd32149b69a"},+ {file = "brotli-1.2.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:a387225a67f619bf16bd504c37655930f910eb03675730fc2ad69d3d8b5e7e92"},+ {file = "brotli-1.2.0-cp27-cp27m-win32.whl", hash = "sha256:b908d1a7b28bc72dfb743be0d4d3f8931f8309f810af66c906ae6cd4127c93cb"},+ {file = "brotli-1.2.0-cp27-cp27m-win_amd64.whl", hash = "sha256:d206a36b4140fbb5373bf1eb73fb9de589bb06afd0d22376de23c5e91d0ab35f"},+ {file = "brotli-1.2.0-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:7e9053f5fb4e0dfab89243079b3e217f2aea4085e4d58c5c06115fc34823707f"},+ {file = "brotli-1.2.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:4735a10f738cb5516905a121f32b24ce196ab82cfc1e4ba2e3ad1b371085fd46"},+ {file = "brotli-1.2.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3b90b767916ac44e93a8e28ce6adf8d551e43affb512f2377c732d486ac6514e"},+ {file = "brotli-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6be67c19e0b0c56365c6a76e393b932fb0e78b3b56b711d180dd7013cb1fd984"},+ {file = "brotli-1.2.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0bbd5b5ccd157ae7913750476d48099aaf507a79841c0d04a9db4415b14842de"},+ {file = "brotli-1.2.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3f3c908bcc404c90c77d5a073e55271a0a498f4e0756e48127c35d91cf155947"},+ {file = "brotli-1.2.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:1b557b29782a643420e08d75aea889462a4a8796e9a6cf5621ab05a3f7da8ef2"},+ {file = "brotli-1.2.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:81da1b229b1889f25adadc929aeb9dbc4e922bd18561b65b08dd9343cfccca84"},+ {file = "brotli-1.2.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:ff09cd8c5eec3b9d02d2408db41be150d8891c5566addce57513bf546e3d6c6d"},+ {file = "brotli-1.2.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:a1778532b978d2536e79c05dac2d8cd857f6c55cd0c95ace5b03740824e0e2f1"},+ {file = "brotli-1.2.0-cp310-cp310-win32.whl", hash = "sha256:b232029d100d393ae3c603c8ffd7e3fe6f798c5e28ddca5feabb8e8fdb732997"},+ {file = "brotli-1.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:ef87b8ab2704da227e83a246356a2b179ef826f550f794b2c52cddb4efbd0196"},+ {file = "brotli-1.2.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:15b33fe93cedc4caaff8a0bd1eb7e3dab1c61bb22a0bf5bdfdfd97cd7da79744"},+ {file = "brotli-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:898be2be399c221d2671d29eed26b6b2713a02c2119168ed914e7d00ceadb56f"},+ {file = "brotli-1.2.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:350c8348f0e76fff0a0fd6c26755d2653863279d086d3aa2c290a6a7251135dd"},+ {file = "brotli-1.2.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2e1ad3fda65ae0d93fec742a128d72e145c9c7a99ee2fcd667785d99eb25a7fe"},+ {file = "brotli-1.2.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:40d918bce2b427a0c4ba189df7a006ac0c7277c180aee4617d99e9ccaaf59e6a"},+ {file = "brotli-1.2.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:2a7f1d03727130fc875448b65b127a9ec5d06d19d0148e7554384229706f9d1b"},+ {file = "brotli-1.2.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:9c79f57faa25d97900bfb119480806d783fba83cd09ee0b33c17623935b05fa3"},+ {file = "brotli-1.2.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:844a8ceb8483fefafc412f85c14f2aae2fb69567bf2a0de53cdb88b73e7c43ae"},+ {file = "brotli-1.2.0-cp311-cp311-win32.whl", hash = "sha256:aa47441fa3026543513139cb8926a92a8e305ee9c71a6209ef7a97d91640ea03"},+ {file = "brotli-1.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:022426c9e99fd65d9475dce5c195526f04bb8be8907607e27e747893f6ee3e24"},+ {file = "brotli-1.2.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:35d382625778834a7f3061b15423919aa03e4f5da34ac8e02c074e4b75ab4f84"},+ {file = "brotli-1.2.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7a61c06b334bd99bc5ae84f1eeb36bfe01400264b3c352f968c6e30a10f9d08b"},+ {file = "brotli-1.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:acec55bb7c90f1dfc476126f9711a8e81c9af7fb617409a9ee2953115343f08d"},+ {file = "brotli-1.2.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:260d3692396e1895c5034f204f0db022c056f9e2ac841593a4cf9426e2a3faca"},+ {file = "brotli-1.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:072e7624b1fc4d601036ab3f4f27942ef772887e876beff0301d261210bca97f"},+ {file = "brotli-1.2.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:adedc4a67e15327dfdd04884873c6d5a01d3e3b6f61406f99b1ed4865a2f6d28"},+ {file = "brotli-1.2.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:7a47ce5c2288702e09dc22a44d0ee6152f2c7eda97b3c8482d826a1f3cfc7da7"},+ {file = "brotli-1.2.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:af43b8711a8264bb4e7d6d9a6d004c3a2019c04c01127a868709ec29962b6036"},+ {file = "brotli-1.2.0-cp312-cp312-win32.whl", hash = "sha256:e99befa0b48f3cd293dafeacdd0d191804d105d279e0b387a32054c1180f3161"},+ {file = "brotli-1.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:b35c13ce241abdd44cb8ca70683f20c0c079728a36a996297adb5334adfc1c44"},+ {file = "brotli-1.2.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:9e5825ba2c9998375530504578fd4d5d1059d09621a02065d1b6bfc41a8e05ab"},+ {file = "brotli-1.2.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0cf8c3b8ba93d496b2fae778039e2f5ecc7cff99df84df337ca31d8f2252896c"},+ {file = "brotli-1.2.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c8565e3cdc1808b1a34714b553b262c5de5fbda202285782173ec137fd13709f"},+ {file = "brotli-1.2.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:26e8d3ecb0ee458a9804f47f21b74845cc823fd1bb19f02272be70774f56e2a6"},+ {file = "brotli-1.2.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:67a91c5187e1eec76a61625c77a6c8c785650f5b576ca732bd33ef58b0dff49c"},+ {file = "brotli-1.2.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4ecdb3b6dc36e6d6e14d3a1bdc6c1057c8cbf80db04031d566eb6080ce283a48"},+ {file = "brotli-1.2.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:3e1b35d56856f3ed326b140d3c6d9db91740f22e14b06e840fe4bb1923439a18"},+ {file = "brotli-1.2.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:54a50a9dad16b32136b2241ddea9e4df159b41247b2ce6aac0b3276a66a8f1e5"},+ {file = "brotli-1.2.0-cp313-cp313-win32.whl", hash = "sha256:1b1d6a4efedd53671c793be6dd760fcf2107da3a52331ad9ea429edf0902f27a"},+ {file = "brotli-1.2.0-cp313-cp313-win_amd64.whl", hash = "sha256:b63daa43d82f0cdabf98dee215b375b4058cce72871fd07934f179885aad16e8"},+ {file = "brotli-1.2.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:6c12dad5cd04530323e723787ff762bac749a7b256a5bece32b2243dd5c27b21"},+ {file = "brotli-1.2.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:3219bd9e69868e57183316ee19c84e03e8f8b5a1d1f2667e1aa8c2f91cb061ac"},+ {file = "brotli-1.2.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:963a08f3bebd8b75ac57661045402da15991468a621f014be54e50f53a58d19e"},+ {file = "brotli-1.2.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9322b9f8656782414b37e6af884146869d46ab85158201d82bab9abbcb971dc7"},+ {file = "brotli-1.2.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:cf9cba6f5b78a2071ec6fb1e7bd39acf35071d90a81231d67e92d637776a6a63"},+ {file = "brotli-1.2.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7547369c4392b47d30a3467fe8c3330b4f2e0f7730e45e3103d7d636678a808b"},+ {file = "brotli-1.2.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:fc1530af5c3c275b8524f2e24841cbe2599d74462455e9bae5109e9ff42e9361"},+ {file = "brotli-1.2.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:d2d085ded05278d1c7f65560aae97b3160aeb2ea2c0b3e26204856beccb60888"},+ {file = "brotli-1.2.0-cp314-cp314-win32.whl", hash = "sha256:832c115a020e463c2f67664560449a7bea26b0c1fdd690352addad6d0a08714d"},+ {file = "brotli-1.2.0-cp314-cp314-win_amd64.whl", hash = "sha256:e7c0af964e0b4e3412a0ebf341ea26ec767fa0b4cf81abb5e897c9338b5ad6a3"},+ {file = "brotli-1.2.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:82676c2781ecf0ab23833796062786db04648b7aae8be139f6b8065e5e7b1518"},+ {file = "brotli-1.2.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c16ab1ef7bb55651f5836e8e62db1f711d55b82ea08c3b8083ff037157171a69"},+ {file = "brotli-1.2.0-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e85190da223337a6b7431d92c799fca3e2982abd44e7b8dec69938dcc81c8e9e"},+ {file = "brotli-1.2.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:d8c05b1dfb61af28ef37624385b0029df902ca896a639881f594060b30ffc9a7"},+ {file = "brotli-1.2.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:465a0d012b3d3e4f1d6146ea019b5c11e3e87f03d1676da1cc3833462e672fb0"},+ {file = "brotli-1.2.0-cp36-cp36m-musllinux_1_2_aarch64.whl", hash = "sha256:96fbe82a58cdb2f872fa5d87dedc8477a12993626c446de794ea025bbda625ea"},+ {file = "brotli-1.2.0-cp36-cp36m-musllinux_1_2_i686.whl", hash = "sha256:1b71754d5b6eda54d16fbbed7fce2d8bc6c052a1b91a35c320247946ee103502"},+ {file = "brotli-1.2.0-cp36-cp36m-musllinux_1_2_ppc64le.whl", hash = "sha256:66c02c187ad250513c2f4fce973ef402d22f80e0adce734ee4e4efd657b6cb64"},+ {file = "brotli-1.2.0-cp36-cp36m-musllinux_1_2_x86_64.whl", hash = "sha256:ba76177fd318ab7b3b9bf6522be5e84c2ae798754b6cc028665490f6e66b5533"},+ {file = "brotli-1.2.0-cp36-cp36m-win32.whl", hash = "sha256:c1702888c9f3383cc2f09eb3e88b8babf5965a54afb79649458ec7c3c7a63e96"},+ {file = "brotli-1.2.0-cp36-cp36m-win_amd64.whl", hash = "sha256:f8d635cafbbb0c61327f942df2e3f474dde1cff16c3cd0580564774eaba1ee13"},+ {file = "brotli-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e80a28f2b150774844c8b454dd288be90d76ba6109670fe33d7ff54d96eb5cb8"},+ {file = "brotli-1.2.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50b1b799f45da91292ffaa21a473ab3a3054fa78560e8ff67082a185274431c8"},+ {file = "brotli-1.2.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:29b7e6716ee4ea0c59e3b241f682204105f7da084d6254ec61886508efeb43bc"},+ {file = "brotli-1.2.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_12_i686.manylinux2010_i686.whl", hash = "sha256:640fe199048f24c474ec6f3eae67c48d286de12911110437a36a87d7c89573a6"},+ {file = "brotli-1.2.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:92edab1e2fd6cd5ca605f57d4545b6599ced5dea0fd90b2bcdf8b247a12bd190"},+ {file = "brotli-1.2.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:7274942e69b17f9cef76691bcf38f2b2d4c8a5f5dba6ec10958363dcb3308a0a"},+ {file = "brotli-1.2.0-cp37-cp37m-musllinux_1_2_i686.whl", hash = "sha256:a56ef534b66a749759ebd091c19c03ef81eb8cd96f0d1d16b59127eaf1b97a12"},+ {file = "brotli-1.2.0-cp37-cp37m-musllinux_1_2_ppc64le.whl", hash = "sha256:5732eff8973dd995549a18ecbd8acd692ac611c5c0bb3f59fa3541ae27b33be3"},+ {file = "brotli-1.2.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:598e88c736f63a0efec8363f9eb34e5b5536b7b6b1821e401afcb501d881f59a"},+ {file = "brotli-1.2.0-cp37-cp37m-win32.whl", hash = "sha256:7ad8cec81f34edf44a1c6a7edf28e7b7806dfb8886e371d95dcf789ccd4e4982"},+ {file = "brotli-1.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:865cedc7c7c303df5fad14a57bc5db1d4f4f9b2b4d0a7523ddd206f00c121a16"},+ {file = "brotli-1.2.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:ac27a70bda257ae3f380ec8310b0a06680236bea547756c277b5dfe55a2452a8"},+ {file = "brotli-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e813da3d2d865e9793ef681d3a6b66fa4b7c19244a45b817d0cceda67e615990"},+ {file = "brotli-1.2.0-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9fe11467c42c133f38d42289d0861b6b4f9da31e8087ca2c0d7ebb4543625526"},+ {file = "brotli-1.2.0-cp38-cp38-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c0d6770111d1879881432f81c369de5cde6e9467be7c682a983747ec800544e2"},+ {file = "brotli-1.2.0-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:eda5a6d042c698e28bda2507a89b16555b9aa954ef1d750e1c20473481aff675"},+ {file = "brotli-1.2.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:3173e1e57cebb6d1de186e46b5680afbd82fd4301d7b2465beebe83ed317066d"},+ {file = "brotli-1.2.0-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:71a66c1c9be66595d628467401d5976158c97888c2c9379c034e1e2312c5b4f5"},+ {file = "brotli-1.2.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:1e68cdf321ad05797ee41d1d09169e09d40fdf51a725bb148bff892ce04583d7"},+ {file = "brotli-1.2.0-cp38-cp38-win32.whl", hash = "sha256:f16dace5e4d3596eaeb8af334b4d2c820d34b8278da633ce4a00020b2eac981c"},+ {file = "brotli-1.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:14ef29fc5f310d34fc7696426071067462c9292ed98b5ff5a27ac70a200e5470"},+ {file = "brotli-1.2.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8d4f47f284bdd28629481c97b5f29ad67544fa258d9091a6ed1fda47c7347cd1"},+ {file = "brotli-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2881416badd2a88a7a14d981c103a52a23a276a553a8aacc1346c2ff47c8dc17"},+ {file = "brotli-1.2.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2d39b54b968f4b49b5e845758e202b1035f948b0561ff5e6385e855c96625971"},+ {file = "brotli-1.2.0-cp39-cp39-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:95db242754c21a88a79e01504912e537808504465974ebb92931cfca2510469e"},+ {file = "brotli-1.2.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:bba6e7e6cfe1e6cb6eb0b7c2736a6059461de1fa2c0ad26cf845de6c078d16c8"},+ {file = "brotli-1.2.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:88ef7d55b7bcf3331572634c3fd0ed327d237ceb9be6066810d39020a3ebac7a"},+ {file = "brotli-1.2.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:7fa18d65a213abcfbb2f6cafbb4c58863a8bd6f2103d65203c520ac117d1944b"},+ {file = "brotli-1.2.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:09ac247501d1909e9ee47d309be760c89c990defbb2e0240845c892ea5ff0de4"},+ {file = "brotli-1.2.0-cp39-cp39-win32.whl", hash = "sha256:c25332657dee6052ca470626f18349fc1fe8855a56218e19bd7a8c6ad4952c49"},+ {file = "brotli-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:1ce223652fd4ed3eb2b7f78fbea31c52314baecfac68db44037bb4167062a937"},+ {file = "brotli-1.2.0.tar.gz", hash = "sha256:e310f77e41941c13340a95976fe66a8a95b01e783d430eeaf7a2f87e0a57dd0a"},+]++[[package]]+name = "certifi"+version = "2026.7.22"+description = "Python package for providing Mozilla's CA Bundle."+optional = false+python-versions = ">=3.7"+groups = ["main"]+files = [+ {file = "certifi-2026.7.22-py3-none-any.whl", hash = "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775"},+ {file = "certifi-2026.7.22.tar.gz", hash = "sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55"},+]++[[package]]+name = "cffi"+version = "2.1.1"+description = "Foreign Function Interface for Python calling C code."+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "cffi-2.1.1-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:baed1e86cc735622097354b9d1281406caf42ff42a886d29faa8e8d1630333be"},+ {file = "cffi-2.1.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ca82be1a1d406ecfe1d25dc16cb33488e5a16bf4438c9fb590484ea29d92478b"},+ {file = "cffi-2.1.1-cp310-cp310-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:42e2f76b9455f5a9a844f770bf3e200ed3da0e15f5df3db9c31fe80b04b3d004"},+ {file = "cffi-2.1.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:5a59cc1c4442bc3d5c703bf720b51138d0bfc173618807c9ee2490a7541dd3d9"},+ {file = "cffi-2.1.1-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:9f8d177621de5cb38ee3e731eda45d421db093ec0739f46a5594babda7987a98"},+ {file = "cffi-2.1.1-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:75f80557d1389eddbd0de2681f6a390a0c5338c31ddaa821381c203fc3fd50d9"},+ {file = "cffi-2.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:194cffa889098ced9976c3fc6340305e43f6303657d298da55366907c05c22d6"},+ {file = "cffi-2.1.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:5bb4e7ea95dcd6a014a6fef62e62467d67d8e582326443f3d68e71d6320a9fcf"},+ {file = "cffi-2.1.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:3d22a20b1fb1632cc72c22f95f7b0d2961c3e1c235f245ba4c606c4771035659"},+ {file = "cffi-2.1.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:1dea0e4d7d4f11f619fe8c1d76caf49e24405b4b5743c0e3be16a500ecd930c9"},+ {file = "cffi-2.1.1-cp310-cp310-win32.whl", hash = "sha256:7ce713ace7c0e4520535b42b77eaa742c16dab813978064913e5a3cf82973b41"},+ {file = "cffi-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:a48d62ab9d6f4f98c983223a547af44be6ca3691074c31cecced6facd3ba2dc1"},+ {file = "cffi-2.1.1-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:c8d2c9fd1f2d16f780d15127abb050d13d1a76c03a4bd87d7e4980e45e511e12"},+ {file = "cffi-2.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:398aff33cee2767e3e781d2554c54bd0dff386bb437581e0d8011fde1a942ec1"},+ {file = "cffi-2.1.1-cp311-cp311-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:154852545011f779917b11c78db2358d095da62a9a172b78ad0a583ee5adc0d0"},+ {file = "cffi-2.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:3311ed60d36f83378794e1009ac6258bafbf81f7888b4caa7b35a521e3f95813"},+ {file = "cffi-2.1.1-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:6e192623c49c94421616a5778fba35cf0d5a8d000650c1967ef4448ee5cdd990"},+ {file = "cffi-2.1.1-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a6e721d4b0e45d5b65e87534470e67b18dcd092c83f68fba09f152b9cbc061af"},+ {file = "cffi-2.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:34e261f78cb6ceaaa36f42f2613f4380d94d9c759a9c73c769ee6e0247364632"},+ {file = "cffi-2.1.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7225e4514edb64eb6740324353e0da0711954fd8d7da4576755b1c6e09b697cd"},+ {file = "cffi-2.1.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:df913725b79db7bcf03448f36b7bf8815363417d5b58deecf9305e3e30f0f21a"},+ {file = "cffi-2.1.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f5cfbc5fe74540d335175b656c725d74d90e3730c626d92575eea35029d9afaa"},+ {file = "cffi-2.1.1-cp311-cp311-win32.whl", hash = "sha256:f8ec5e643a9a937f64e1999eb9f75d072263751912dc5cd06d3c85f8f44be7c3"},+ {file = "cffi-2.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:42f6930c31dc7f50732c9ae793c2786c7b6b044195967bbdde40bb9be81c4cc0"},+ {file = "cffi-2.1.1-cp311-cp311-win_arm64.whl", hash = "sha256:c7659f22557c5a0bc4855cd635f55edec690cc008a40768527762cb9fb263455"},+ {file = "cffi-2.1.1-cp312-cp312-macosx_10_15_x86_64.whl", hash = "sha256:c8c69575568085ba0b1b10c0249d779a214aea6f6522e949a0fc9fb0fcb449d0"},+ {file = "cffi-2.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f81b3b8f3d4e343550fa4baa0e479bba9f2d29ce9c2e9b51d1ce1718d7442fcf"},+ {file = "cffi-2.1.1-cp312-cp312-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:811bd1e21d32de12efca32393a0ab3f5133b54fce9bd44b8bd77ab07da14bf6a"},+ {file = "cffi-2.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:68e62fe11f30d5ca8289242866f0a5291402d8529ca2178ab8afc5c9694ae890"},+ {file = "cffi-2.1.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:4a7c934f7360e8cd64fe9efadcbd10c7c6364f531e432b9a4bf5ccbc9e0e8b50"},+ {file = "cffi-2.1.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:3143d81e29e1e20a9ce10901ec369012947876596f75a222235965f2b7ae832e"},+ {file = "cffi-2.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf"},+ {file = "cffi-2.1.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:208f941bb9d18e768138677f0a6d2ce01f590df56043dda1df1535ac57c88517"},+ {file = "cffi-2.1.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:210019b6c7cf07f081b4c54635c8cf744377001350e29cc0f81c4377b4797735"},+ {file = "cffi-2.1.1-cp312-cp312-win32.whl", hash = "sha256:046bfc24911b37851ee1b51aab8bffe713d89c68c6a057b09484ce9fd5f69b4e"},+ {file = "cffi-2.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:f53e442b08449d42821fa4a4fba000095af9f62742a500f978a9f557ec44339a"},+ {file = "cffi-2.1.1-cp312-cp312-win_arm64.whl", hash = "sha256:7bde5e4cc5c10140859842b9d383af292b22639a4dffb725314baf45968cef80"},+ {file = "cffi-2.1.1-cp313-cp313-ios_13_0_arm64_iphoneos.whl", hash = "sha256:b5bdfd1c873d4e093aabc0ca84c4ca6dbc4f752afb5c86f146d9742580c9da2e"},+ {file = "cffi-2.1.1-cp313-cp313-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:31348097ff5bbe827ccc41795d4dd099d9f0625e7def00ee653c137a490c2a6c"},+ {file = "cffi-2.1.1-cp313-cp313-macosx_10_15_x86_64.whl", hash = "sha256:9d2055050ea716bd38b7f7f1579c275386646b4894c155a3e2f3cd62ed41b7c6"},+ {file = "cffi-2.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19ee6127ee34de7d83ce3d371ebc5ed91addbdcc39f9ab15ce4eb35a4e534971"},+ {file = "cffi-2.1.1-cp313-cp313-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:6a8dddef476fab96d066d578fc88526767b836ab5ab21754e1d5bf3879c31c7c"},+ {file = "cffi-2.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:f16c709686a78c727bbbf059f92b0bf41c6fc60deec706d2dc19f529175a6125"},+ {file = "cffi-2.1.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:fcd22650c908d7b7da162bbfaab594a1227a15d1643a98c68b122ac642fa2264"},+ {file = "cffi-2.1.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:aa9511c62d14da7aacc9b4bf51f3f697a621e83b2d6919008243c3aad168eea3"},+ {file = "cffi-2.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:a931079504ecc49efed7744c476a5c343a92fabf66dec2db95edb1b2fdc770e2"},+ {file = "cffi-2.1.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a2d7755bef5a12ed488f4ef1f1b69ee9191d7396083b755a5d2295f6edb4768b"},+ {file = "cffi-2.1.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e0bcb7e0f677f543555d2adff3bf19c05f66cdb4796e5ff602442ab2fe3c4ef7"},+ {file = "cffi-2.1.1-cp313-cp313-win32.whl", hash = "sha256:334644fbac4eff73d985a17a91226df55d0f394160c4cfb880e084c8f7161cac"},+ {file = "cffi-2.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:1aa5645c30469b09530c4ebca77ebf8f17618293c58f8549cb1a543a50236e7d"},+ {file = "cffi-2.1.1-cp313-cp313-win_arm64.whl", hash = "sha256:63bbfd5ded17c4840ac07cd8f1c21ba9d9708141f840b324f422f41b207e3973"},+ {file = "cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c"},+ {file = "cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb"},+ {file = "cffi-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d28630f5854ab07ab1fd4aba756de52326c82e6be15d414b12793f1975048b54"},+ {file = "cffi-2.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72"},+ {file = "cffi-2.1.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:58acb8ab8e295e6c5ea12f888cbb13cf21511ef2a3303a23f4325c29d17fe5c1"},+ {file = "cffi-2.1.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:456a61fa52d579ebf9df2e9552ead5129855dbaff6c1e5a9b1bc408809bdc062"},+ {file = "cffi-2.1.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a4f00aa42f75d6e4595e8866e748cc1705adc0cddfeb2ca86d0d03993d63ba03"},+ {file = "cffi-2.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96"},+ {file = "cffi-2.1.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:64faea20f4e2613363a1a9b9c7dd73058f3ecd00133a511e72ad7c511658f527"},+ {file = "cffi-2.1.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13"},+ {file = "cffi-2.1.1-cp314-cp314-win32.whl", hash = "sha256:1a18a57b58cfb21fc28d72e876acf10eaed67a1ed96226f92af4df681d571c4c"},+ {file = "cffi-2.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:3222ba5d678f80a030e6afbcc33dc1ae5cb45facabb61cee2c7016b8432fde48"},+ {file = "cffi-2.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:ab36d55f9ed2d067327667c2fea18dda018eb628dd6347aa01dda6cf1f5d3836"},+ {file = "cffi-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:7750c6449dff7864bb9bb27ddfb0267756189201a3afc911d82b3caacd70dfc3"},+ {file = "cffi-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2"},+ {file = "cffi-2.1.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49cbc70e6542d4ccccb936558d1064a8012541e78f821f955cff24e357776c94"},+ {file = "cffi-2.1.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:e2d65b31f36619cda3999b78b2aa9632e76b78448e7a56fc4240824200e7c4fc"},+ {file = "cffi-2.1.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:28907ab9bfb6aa13184cfc17c6b8e1023c5ab6fd7076d8c20a35e59fe04f8f29"},+ {file = "cffi-2.1.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676"},+ {file = "cffi-2.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5e7cecbaadb83884793e05828cee59b210b24583b9c7425d0ba6a754fe22eb4e"},+ {file = "cffi-2.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f"},+ {file = "cffi-2.1.1-cp314-cp314t-win32.whl", hash = "sha256:8ef53b2de9bcb9197d31854256575d59dbac0cba72ac627bb291ef5eceb74be4"},+ {file = "cffi-2.1.1-cp314-cp314t-win_amd64.whl", hash = "sha256:616f097f2fe415bc92a247f02e11f634e1f9e9a83d327e3c915c15089c87869e"},+ {file = "cffi-2.1.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ad2c86c495b899d862ea0f4b42891b8713a3bd45dd4105c7fd51c2a72f39f3a5"},+ {file = "cffi-2.1.1-cp315-cp315-ios_13_0_arm64_iphoneos.whl", hash = "sha256:dddad92b554513a31f272570678ba307fb9f618f05e3d4a5eacafff9eae03e1d"},+ {file = "cffi-2.1.1-cp315-cp315-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:da0e573f9f97159390c89d9f1a9e41908b66d408cc5b58d08cf3847d844c531b"},+ {file = "cffi-2.1.1-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:fb92203a88b3d3053034db775110081c49d28be6551923805e039924093761e4"},+ {file = "cffi-2.1.1-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:2ae64be792b8966f2c69538199728b290e34726562896df1e5dc8ffd8d8188e8"},+ {file = "cffi-2.1.1-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:507a24c282e0f42f8ed737cf048572cbf580468da5555764a8331735e9c736b6"},+ {file = "cffi-2.1.1-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:246fa40ce8645a614ff682e0b70f37134e460eaf93a775e0cbe3cca585a67a80"},+ {file = "cffi-2.1.1-cp315-cp315-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:471cee653ae88de62096552e6d24ccb4a5adb8c8c9f10b5054d0122c15bf2779"},+ {file = "cffi-2.1.1-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:aeae0e330c9f6acd681f647d46cefd30c29f93e3392882e792e82080c9691399"},+ {file = "cffi-2.1.1-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:42a494cee34437f05546455144f2b5d9ac09b1face62bcfce597d2e521066688"},+ {file = "cffi-2.1.1-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:cc572dace3f60ef98d7b12ff411d20f5362feb31a0439eab0085bbfd349982d7"},+ {file = "cffi-2.1.1-cp315-cp315-win32.whl", hash = "sha256:4f42141fc14250de6dde5ee7ea4432be017252d91f19c5ad043c084cea629cac"},+ {file = "cffi-2.1.1-cp315-cp315-win_amd64.whl", hash = "sha256:e6e8cff14d6fb0be70a09c0bdc58096f501952d04624ebf867e0e56da2df8960"},+ {file = "cffi-2.1.1-cp315-cp315-win_arm64.whl", hash = "sha256:27350daa11d4f10c540e6e89dada4c54feb7256ad03e9a4dc075ebad7ba360d1"},+ {file = "cffi-2.1.1-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:c26608d2222fb1e94487e4a387d85f13eb55d5ed725cb25a0c589ac4ee60e7bc"},+ {file = "cffi-2.1.1-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:4be96343e422f2dfcd12ab5c9f5aebe03f82f737c6bffeca6830b3875cb44aab"},+ {file = "cffi-2.1.1-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:937c0052c05a31ca1daf18de3158eed4dbfcb9cc107adbea227728d647be701e"},+ {file = "cffi-2.1.1-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:df423d40ee8654634421812bc3b196da3f9bd7d32929da813f8394c4348a5358"},+ {file = "cffi-2.1.1-cp315-cp315t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a730a083190634c65cca36ba5f489531576ebd79bcd5c8e172130f6453127231"},+ {file = "cffi-2.1.1-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:363e05fa78e15116c3c32c210ee36884fd6b9afa6d440e47112c3bd511d64cb6"},+ {file = "cffi-2.1.1-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:770de9db11e84213beec501cfcaa013b019820ca881e03344dea5844f7876d94"},+ {file = "cffi-2.1.1-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:7da0c5eff80f0197f3b3d1232ec5a682a9325f4ae9016a78f5f5ca35f9ced1f5"},+ {file = "cffi-2.1.1-cp315-cp315t-win32.whl", hash = "sha256:06c72bb76605a4b0cd0aad6930b69d4baf7dd5d806cfc409b824191099700e66"},+ {file = "cffi-2.1.1-cp315-cp315t-win_amd64.whl", hash = "sha256:d9c275eaacd24aa73f94ffd6de08fc3f932424d8b6c376f4bed7cde376fe7bc3"},+ {file = "cffi-2.1.1-cp315-cp315t-win_arm64.whl", hash = "sha256:d18e5ac0f2f03f4f518d3e23db0f0cad7faa1da8620e9c09461d443bbf6e6692"},+ {file = "cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be"},+]++[package.dependencies]+pycparser = {version = "*", markers = "implementation_name != \"PyPy\""}++[[package]]+name = "click"+version = "8.5.0"+description = "Composable command line interface toolkit"+optional = false+python-versions = ">=3.10"+groups = ["main", "dev"]+files = [+ {file = "click-8.5.0-py3-none-any.whl", hash = "sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360"},+ {file = "click-8.5.0.tar.gz", hash = "sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34"},+]++[[package]]+name = "colorama"+version = "0.4.6"+description = "Cross-platform colored terminal text."+optional = false+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"+groups = ["dev"]+markers = "sys_platform == \"win32\""+files = [+ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"},+ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},+]++[[package]]+name = "cryptography"+version = "48.0.1"+description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers."+optional = false+python-versions = "!=3.9.0,!=3.9.1,>=3.9"+groups = ["main"]+files = [+ {file = "cryptography-48.0.1-cp311-abi3-macosx_10_9_universal2.whl", hash = "sha256:3e4a1a3232eef2e6c732827d5722db29a0cc8b27af2a4d865b094cf954be9ca1"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:32143b24adb918f078134e1e230f1eb8cc04886b92c28b5f0041aaf3e5699225"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f0d27a5696721ef7a672b8c810f6aded391058e0b9486e63e6d93baf765da691"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:eb86ce1af36fe65041b6db9a8bb064ee621a7e5fded0f80d475ec243477cd242"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:b024e784ad6c077ee0147b35ea9cbfc1e34e1fd4c1dcca214c2794d73a12df08"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3752f2dbc8f07a30aad2932c986cea495b03bb554887828225da104f732852b6"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:bd81490cd5801d755cf97bb68ac191f14b708470b1c7cf4580f669b9c9264cd8"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:66fd0771e7b9c6dcd44cf1120690d2338d16d72795cf40cae2786a39eba65429"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:3fd2ca57062b241c856670b073487d2e86c4637937ca5601e48f97bf8e11fc8f"},+ {file = "cryptography-48.0.1-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:0ee6ea481db1ab889cba043ec1eda17bb9c1ea79db6722f779c3667f9f70322f"},+ {file = "cryptography-48.0.1-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:f2ceef93cb096aa3c4cc4b5c94ca6131f9196d28c64d6111533402a9b2054d41"},+ {file = "cryptography-48.0.1-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:9bd3f92d76217892b15df84ca256c2c113d386fdda7a7d8691aeeced976507c6"},+ {file = "cryptography-48.0.1-cp311-abi3-win32.whl", hash = "sha256:b9a32b876490d66c8bcc9963ef220199569748434ab01a9d6aaeabf88e7f5158"},+ {file = "cryptography-48.0.1-cp311-abi3-win_amd64.whl", hash = "sha256:39489bfca54c7a1f6b297efcd8bc608ab92d16c4ca631b0cad4da46724588b24"},+ {file = "cryptography-48.0.1-cp314-cp314t-macosx_10_9_universal2.whl", hash = "sha256:f817adc181390bd54f2f700107a7419040fb7c1bdf2fc26f36551a06a68c3345"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d5d30989c6917b478b5817902e85fddaea2261efa8648383d965381ccb9e1ac4"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:df637c05205ea7c1d7fbcbe54bbfea648a52951155f997af13d895d0ecc96991"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:869c3b8a53bfe27147832df48b32adadf558249d50e76cb3769d40e986b13265"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_28_ppc64le.whl", hash = "sha256:e361afba8918070d376df76f408a4f67fec0ee9cff81a99e48fe9a233ef59e17"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:d069066deead00ac7f090be101be875a06855908f7ec004c27b8fefb4acfb411"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:09f73a725d582cef64b91281a322cd798d14a33b2b6f2b7ad9531dc336d84c02"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:15254441469dd6bf027039453288e2072124f8b6603563f5d759e1c9b69273fa"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_34_ppc64le.whl", hash = "sha256:8ace4507d1e6533c125f4fac754f8bb8b6a74c08e92179dabd7e16571a3efbf3"},+ {file = "cryptography-48.0.1-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:b4e391975f038e66432328639620a4aff2d307513b004f1ca06d6225bced815c"},+ {file = "cryptography-48.0.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:42fcd8e26fe555d9b3577a135f5091fefa0aa4e99129c23fb56787a1bd4ada72"},+ {file = "cryptography-48.0.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:c1400da5e32a43253392277eac7490a60e497d810a63dd5608d71bbd7af507c9"},+ {file = "cryptography-48.0.1-cp314-cp314t-win32.whl", hash = "sha256:0df56b056bc17c1b7d6821dfa65216e62bd232d8ab05eb3db44e71d235651471"},+ {file = "cryptography-48.0.1-cp314-cp314t-win_amd64.whl", hash = "sha256:9de21387aa95e2a895823d0745b430bed4f33503ba9ab5e0b5311f33e37d66d2"},+ {file = "cryptography-48.0.1-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:4fdc69f8e4316bcf0c8c8ec1f26f285d12e8142d88d96c876a59a03be3f6ae67"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:48fe40804d4caa2288f24e70ca8c64c42dd826da0ad7e4f1b41b2128d679e6c8"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:86be3b1b0b6bf09482fb50a979c508d2950ed95f5621ec77f4e385962006b83a"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:4ab0a343c807bbcd90c971cd1ecf072937cd01847a9e002bef88fb47ac6be577"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:9621de99d2da096006b629979efd8ae7eb2d8b822488d0c89ee4000c306c59b1"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:88c852a0ae366e262e5a1744b685e6a433dc8788dd2a277e418bf4904203609d"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:43c5835e2cb98c8733d86f57d6fc879b613f5c3478607281c3e36daffc6dd8a6"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:fe0180af5bf9236518a087e35bf2d9a347d5f5f51e63c579d683ddff424e3d46"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:b7a2d1a937a738a881737cec135a38bb61470589b17515b9f73f571d0ae10401"},+ {file = "cryptography-48.0.1-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:b74ca3b8e5ecdd833bf6a002ca41b4793bb27fb8f1c06ffaf2643c9e9140e31b"},+ {file = "cryptography-48.0.1-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:2c37f2461406063b417837f5f3daab668652acd82423efcd7f0a9f04be972de1"},+ {file = "cryptography-48.0.1-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:86fe77abb1bd87afb251d4d02ada7ecf53a32cee9b67d976abb2e45a13297475"},+ {file = "cryptography-48.0.1-cp39-abi3-win32.whl", hash = "sha256:6b2c0c3e6ccf3ade7750f836ef3ee36eea250cc467d45c256895573ac08cc6f1"},+ {file = "cryptography-48.0.1-cp39-abi3-win_amd64.whl", hash = "sha256:9a49ca6c81417f6a5edb50375a60cccdd70fa0a91a5211829dbea74eba94d2ac"},+ {file = "cryptography-48.0.1-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:08a597acce1ff37f347400087776599e2348a3a8bc53b44120e463cd274efe4a"},+ {file = "cryptography-48.0.1-pp311-pypy311_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:735824ec41b7f74a7c45fb1591349333e4c696cb6c044e5f46356e560143e4cd"},+ {file = "cryptography-48.0.1-pp311-pypy311_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:92a46e1d638daa264ba2971c0b0489c9409787943efae4d60ffda3d091ef832c"},+ {file = "cryptography-48.0.1-pp311-pypy311_pp73-manylinux_2_34_aarch64.whl", hash = "sha256:7e234ac052af99f2700826a5c29ea99d9c1b1f80341cde62d11c8154dc8e0bd9"},+ {file = "cryptography-48.0.1-pp311-pypy311_pp73-manylinux_2_34_x86_64.whl", hash = "sha256:33842cf0888951cef5bc7ac724ab844a42044c1727b967b7f8997289a0464f92"},+ {file = "cryptography-48.0.1-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:6184ca7b174f28d7c703f1290d4b297217c45355f77a98f67e9b7f14549ac54a"},+ {file = "cryptography-48.0.1.tar.gz", hash = "sha256:266f4ee051abb2f725b74ef8072b521ce1feacf685a3364fa6a6b45548db791a"},+]++[package.dependencies]+cffi = {version = ">=2.0.0", markers = "platform_python_implementation != \"PyPy\""}++[package.extras]+ssh = ["bcrypt (>=3.1.5)"]++[[package]]+name = "flask"+version = "3.1.3"+description = "A simple framework for building complex web applications."+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "flask-3.1.3-py3-none-any.whl", hash = "sha256:f4bcbefc124291925f1a26446da31a5178f9483862233b23c0c96a20701f670c"},+ {file = "flask-3.1.3.tar.gz", hash = "sha256:0ef0e52b8a9cd932855379197dd8f94047b359ca0a78695144304cb45f87c9eb"},+]++[package.dependencies]+blinker = ">=1.9.0"+click = ">=8.1.3"+itsdangerous = ">=2.2.0"+jinja2 = ">=3.1.2"+markupsafe = ">=2.1.1"+werkzeug = ">=3.1.0"++[package.extras]+async = ["asgiref (>=3.2)"]+dotenv = ["python-dotenv"]++[[package]]+name = "h11"+version = "0.16.0"+description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86"},+ {file = "h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1"},+]++[[package]]+name = "h2"+version = "4.3.0"+description = "Pure-Python HTTP/2 protocol implementation"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "h2-4.3.0-py3-none-any.whl", hash = "sha256:c438f029a25f7945c69e0ccf0fb951dc3f73a5f6412981daee861431b70e2bdd"},+ {file = "h2-4.3.0.tar.gz", hash = "sha256:6c59efe4323fa18b47a632221a1888bd7fde6249819beda254aeca909f221bf1"},+]++[package.dependencies]+hpack = ">=4.1,<5"+hyperframe = ">=6.1,<7"++[[package]]+name = "hpack"+version = "4.2.0"+description = "Pure-Python HPACK header encoding"+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "hpack-4.2.0-py3-none-any.whl", hash = "sha256:858ac0b02280fa582b5080d68db0899c62a80375e0e5413a74970c5e518b6986"},+ {file = "hpack-4.2.0.tar.gz", hash = "sha256:0895cfa3b5531fc65fe439c05eb65144f123bf7a394fcaa56aa423548d8e45c0"},+]++[[package]]+name = "httpcore"+version = "1.0.9"+description = "A minimal low-level HTTP client."+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55"},+ {file = "httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8"},+]++[package.dependencies]+certifi = "*"+h11 = ">=0.16"++[package.extras]+asyncio = ["anyio (>=4.0,<5.0)"]+http2 = ["h2 (>=3,<5)"]+socks = ["socksio (==1.*)"]+trio = ["trio (>=0.22.0,<1.0)"]++[[package]]+name = "httpx"+version = "0.28.1"+description = "The next generation HTTP client."+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad"},+ {file = "httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc"},+]++[package.dependencies]+anyio = "*"+certifi = "*"+httpcore = "==1.*"+idna = "*"++[package.extras]+brotli = ["brotli ; platform_python_implementation == \"CPython\"", "brotlicffi ; platform_python_implementation != \"CPython\""]+cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]+http2 = ["h2 (>=3,<5)"]+socks = ["socksio (==1.*)"]+zstd = ["zstandard (>=0.18.0)"]++[[package]]+name = "hyperframe"+version = "6.1.0"+description = "Pure-Python HTTP/2 framing"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "hyperframe-6.1.0-py3-none-any.whl", hash = "sha256:b03380493a519fce58ea5af42e4a42317bf9bd425596f7a0835ffce80f1a42e5"},+ {file = "hyperframe-6.1.0.tar.gz", hash = "sha256:f630908a00854a7adeabd6382b43923a4c4cd4b821fcb527e6ab9e15382a3b08"},+]++[[package]]+name = "idna"+version = "3.19"+description = "Internationalized Domain Names in Applications (IDNA)"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "idna-3.19-py3-none-any.whl", hash = "sha256:815e7be7a7806d54abb586dc943addc79e8b2ee16915059658cbeff4b1b43bf4"},+ {file = "idna-3.19.tar.gz", hash = "sha256:5e0811a4383b21dc5838069f801c4fb62113b7447663d2530d2bd6e77b49bf15"},+]++[package.extras]+all = ["coverage (>=7.10.0)", "hypothesis (>=6.141.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.16.0)", "ty (>=0.0.37)"]++[[package]]+name = "iniconfig"+version = "2.3.0"+description = "brain-dead simple config-ini parsing"+optional = false+python-versions = ">=3.10"+groups = ["dev"]+files = [+ {file = "iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12"},+ {file = "iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730"},+]++[[package]]+name = "isort"+version = "5.13.2"+description = "A Python utility / library to sort Python imports."+optional = false+python-versions = ">=3.8.0"+groups = ["dev"]+files = [+ {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"},+ {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"},+]++[package.extras]+colors = ["colorama (>=0.4.6)"]++[[package]]+name = "itsdangerous"+version = "2.2.0"+description = "Safely pass data to untrusted environments and back."+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef"},+ {file = "itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173"},+]++[[package]]+name = "jinja2"+version = "3.1.6"+description = "A very fast and expressive template engine."+optional = false+python-versions = ">=3.7"+groups = ["main"]+files = [+ {file = "jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"},+ {file = "jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"},+]++[package.dependencies]+MarkupSafe = ">=2.0"++[package.extras]+i18n = ["Babel (>=2.7)"]++[[package]]+name = "kaitaistruct"+version = "0.11"+description = "Kaitai Struct declarative parser generator for binary data: runtime library for Python"+optional = false+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"+groups = ["main"]+files = [+ {file = "kaitaistruct-0.11-py2.py3-none-any.whl", hash = "sha256:5c6ce79177b4e193a577ecd359e26516d1d6d000a0bffd6e1010f2a46a62a561"},+ {file = "kaitaistruct-0.11.tar.gz", hash = "sha256:053ee764288e78b8e53acf748e9733268acbd579b8d82a427b1805453625d74b"},+]++[[package]]+name = "ldap3"+version = "2.9.1"+description = "A strictly RFC 4510 conforming LDAP V3 pure Python client library"+optional = false+python-versions = "*"+groups = ["main"]+files = [+ {file = "ldap3-2.9.1-py2.py3-none-any.whl", hash = "sha256:5869596fc4948797020d3f03b7939da938778a0f9e2009f7a072ccf92b8e8d70"},+ {file = "ldap3-2.9.1.tar.gz", hash = "sha256:f3e7fc4718e3f09dda568b57100095e0ce58633bcabbed8667ce3f8fbaa4229f"},+]++[package.dependencies]+pyasn1 = ">=0.4.6"++[[package]]+name = "markupsafe"+version = "3.0.3"+description = "Safely add untrusted strings to HTML/XML markup."+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "markupsafe-3.0.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:2f981d352f04553a7171b8e44369f2af4055f888dfb147d55e42d29e29e74559"},+ {file = "markupsafe-3.0.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e1c1493fb6e50ab01d20a22826e57520f1284df32f2d8601fdd90b6304601419"},+ {file = "markupsafe-3.0.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1ba88449deb3de88bd40044603fafffb7bc2b055d626a330323a9ed736661695"},+ {file = "markupsafe-3.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f42d0984e947b8adf7dd6dde396e720934d12c506ce84eea8476409563607591"},+ {file = "markupsafe-3.0.3-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c0c0b3ade1c0b13b936d7970b1d37a57acde9199dc2aecc4c336773e1d86049c"},+ {file = "markupsafe-3.0.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:0303439a41979d9e74d18ff5e2dd8c43ed6c6001fd40e5bf2e43f7bd9bbc523f"},+ {file = "markupsafe-3.0.3-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:d2ee202e79d8ed691ceebae8e0486bd9a2cd4794cec4824e1c99b6f5009502f6"},+ {file = "markupsafe-3.0.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:177b5253b2834fe3678cb4a5f0059808258584c559193998be2601324fdeafb1"},+ {file = "markupsafe-3.0.3-cp310-cp310-win32.whl", hash = "sha256:2a15a08b17dd94c53a1da0438822d70ebcd13f8c3a95abe3a9ef9f11a94830aa"},+ {file = "markupsafe-3.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:c4ffb7ebf07cfe8931028e3e4c85f0357459a3f9f9490886198848f4fa002ec8"},+ {file = "markupsafe-3.0.3-cp310-cp310-win_arm64.whl", hash = "sha256:e2103a929dfa2fcaf9bb4e7c091983a49c9ac3b19c9061b6d5427dd7d14d81a1"},+ {file = "markupsafe-3.0.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1cc7ea17a6824959616c525620e387f6dd30fec8cb44f649e31712db02123dad"},+ {file = "markupsafe-3.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:4bd4cd07944443f5a265608cc6aab442e4f74dff8088b0dfc8238647b8f6ae9a"},+ {file = "markupsafe-3.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b5420a1d9450023228968e7e6a9ce57f65d148ab56d2313fcd589eee96a7a50"},+ {file = "markupsafe-3.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0bf2a864d67e76e5c9a34dc26ec616a66b9888e25e7b9460e1c76d3293bd9dbf"},+ {file = "markupsafe-3.0.3-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:bc51efed119bc9cfdf792cdeaa4d67e8f6fcccab66ed4bfdd6bde3e59bfcbb2f"},+ {file = "markupsafe-3.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:068f375c472b3e7acbe2d5318dea141359e6900156b5b2ba06a30b169086b91a"},+ {file = "markupsafe-3.0.3-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:7be7b61bb172e1ed687f1754f8e7484f1c8019780f6f6b0786e76bb01c2ae115"},+ {file = "markupsafe-3.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:f9e130248f4462aaa8e2552d547f36ddadbeaa573879158d721bbd33dfe4743a"},+ {file = "markupsafe-3.0.3-cp311-cp311-win32.whl", hash = "sha256:0db14f5dafddbb6d9208827849fad01f1a2609380add406671a26386cdf15a19"},+ {file = "markupsafe-3.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:de8a88e63464af587c950061a5e6a67d3632e36df62b986892331d4620a35c01"},+ {file = "markupsafe-3.0.3-cp311-cp311-win_arm64.whl", hash = "sha256:3b562dd9e9ea93f13d53989d23a7e775fdfd1066c33494ff43f5418bc8c58a5c"},+ {file = "markupsafe-3.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:d53197da72cc091b024dd97249dfc7794d6a56530370992a5e1a08983ad9230e"},+ {file = "markupsafe-3.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1872df69a4de6aead3491198eaf13810b565bdbeec3ae2dc8780f14458ec73ce"},+ {file = "markupsafe-3.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3a7e8ae81ae39e62a41ec302f972ba6ae23a5c5396c8e60113e9066ef893da0d"},+ {file = "markupsafe-3.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d6dd0be5b5b189d31db7cda48b91d7e0a9795f31430b7f271219ab30f1d3ac9d"},+ {file = "markupsafe-3.0.3-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:94c6f0bb423f739146aec64595853541634bde58b2135f27f61c1ffd1cd4d16a"},+ {file = "markupsafe-3.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:be8813b57049a7dc738189df53d69395eba14fb99345e0a5994914a3864c8a4b"},+ {file = "markupsafe-3.0.3-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:83891d0e9fb81a825d9a6d61e3f07550ca70a076484292a70fde82c4b807286f"},+ {file = "markupsafe-3.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:77f0643abe7495da77fb436f50f8dab76dbc6e5fd25d39589a0f1fe6548bfa2b"},+ {file = "markupsafe-3.0.3-cp312-cp312-win32.whl", hash = "sha256:d88b440e37a16e651bda4c7c2b930eb586fd15ca7406cb39e211fcff3bf3017d"},+ {file = "markupsafe-3.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:26a5784ded40c9e318cfc2bdb30fe164bdb8665ded9cd64d500a34fb42067b1c"},+ {file = "markupsafe-3.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:35add3b638a5d900e807944a078b51922212fb3dedb01633a8defc4b01a3c85f"},+ {file = "markupsafe-3.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e1cf1972137e83c5d4c136c43ced9ac51d0e124706ee1c8aa8532c1287fa8795"},+ {file = "markupsafe-3.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:116bb52f642a37c115f517494ea5feb03889e04df47eeff5b130b1808ce7c219"},+ {file = "markupsafe-3.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:133a43e73a802c5562be9bbcd03d090aa5a1fe899db609c29e8c8d815c5f6de6"},+ {file = "markupsafe-3.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccfcd093f13f0f0b7fdd0f198b90053bf7b2f02a3927a30e63f3ccc9df56b676"},+ {file = "markupsafe-3.0.3-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:509fa21c6deb7a7a273d629cf5ec029bc209d1a51178615ddf718f5918992ab9"},+ {file = "markupsafe-3.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a4afe79fb3de0b7097d81da19090f4df4f8d3a2b3adaa8764138aac2e44f3af1"},+ {file = "markupsafe-3.0.3-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:795e7751525cae078558e679d646ae45574b47ed6e7771863fcc079a6171a0fc"},+ {file = "markupsafe-3.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:8485f406a96febb5140bfeca44a73e3ce5116b2501ac54fe953e488fb1d03b12"},+ {file = "markupsafe-3.0.3-cp313-cp313-win32.whl", hash = "sha256:bdd37121970bfd8be76c5fb069c7751683bdf373db1ed6c010162b2a130248ed"},+ {file = "markupsafe-3.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:9a1abfdc021a164803f4d485104931fb8f8c1efd55bc6b748d2f5774e78b62c5"},+ {file = "markupsafe-3.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:7e68f88e5b8799aa49c85cd116c932a1ac15caaa3f5db09087854d218359e485"},+ {file = "markupsafe-3.0.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:218551f6df4868a8d527e3062d0fb968682fe92054e89978594c28e642c43a73"},+ {file = "markupsafe-3.0.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:3524b778fe5cfb3452a09d31e7b5adefeea8c5be1d43c4f810ba09f2ceb29d37"},+ {file = "markupsafe-3.0.3-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4e885a3d1efa2eadc93c894a21770e4bc67899e3543680313b09f139e149ab19"},+ {file = "markupsafe-3.0.3-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8709b08f4a89aa7586de0aadc8da56180242ee0ada3999749b183aa23df95025"},+ {file = "markupsafe-3.0.3-cp313-cp313t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:b8512a91625c9b3da6f127803b166b629725e68af71f8184ae7e7d54686a56d6"},+ {file = "markupsafe-3.0.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:9b79b7a16f7fedff2495d684f2b59b0457c3b493778c9eed31111be64d58279f"},+ {file = "markupsafe-3.0.3-cp313-cp313t-musllinux_1_2_riscv64.whl", hash = "sha256:12c63dfb4a98206f045aa9563db46507995f7ef6d83b2f68eda65c307c6829eb"},+ {file = "markupsafe-3.0.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8f71bc33915be5186016f675cd83a1e08523649b0e33efdb898db577ef5bb009"},+ {file = "markupsafe-3.0.3-cp313-cp313t-win32.whl", hash = "sha256:69c0b73548bc525c8cb9a251cddf1931d1db4d2258e9599c28c07ef3580ef354"},+ {file = "markupsafe-3.0.3-cp313-cp313t-win_amd64.whl", hash = "sha256:1b4b79e8ebf6b55351f0d91fe80f893b4743f104bff22e90697db1590e47a218"},+ {file = "markupsafe-3.0.3-cp313-cp313t-win_arm64.whl", hash = "sha256:ad2cf8aa28b8c020ab2fc8287b0f823d0a7d8630784c31e9ee5edea20f406287"},+ {file = "markupsafe-3.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe"},+ {file = "markupsafe-3.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026"},+ {file = "markupsafe-3.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737"},+ {file = "markupsafe-3.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97"},+ {file = "markupsafe-3.0.3-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d"},+ {file = "markupsafe-3.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda"},+ {file = "markupsafe-3.0.3-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf"},+ {file = "markupsafe-3.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe"},+ {file = "markupsafe-3.0.3-cp314-cp314-win32.whl", hash = "sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9"},+ {file = "markupsafe-3.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581"},+ {file = "markupsafe-3.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4"},+ {file = "markupsafe-3.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab"},+ {file = "markupsafe-3.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175"},+ {file = "markupsafe-3.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634"},+ {file = "markupsafe-3.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50"},+ {file = "markupsafe-3.0.3-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e"},+ {file = "markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5"},+ {file = "markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523"},+ {file = "markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc"},+ {file = "markupsafe-3.0.3-cp314-cp314t-win32.whl", hash = "sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d"},+ {file = "markupsafe-3.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9"},+ {file = "markupsafe-3.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa"},+ {file = "markupsafe-3.0.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:15d939a21d546304880945ca1ecb8a039db6b4dc49b2c5a400387cdae6a62e26"},+ {file = "markupsafe-3.0.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f71a396b3bf33ecaa1626c255855702aca4d3d9fea5e051b41ac59a9c1c41edc"},+ {file = "markupsafe-3.0.3-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0f4b68347f8c5eab4a13419215bdfd7f8c9b19f2b25520968adfad23eb0ce60c"},+ {file = "markupsafe-3.0.3-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e8fc20152abba6b83724d7ff268c249fa196d8259ff481f3b1476383f8f24e42"},+ {file = "markupsafe-3.0.3-cp39-cp39-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:949b8d66bc381ee8b007cd945914c721d9aba8e27f71959d750a46f7c282b20b"},+ {file = "markupsafe-3.0.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:3537e01efc9d4dccdf77221fb1cb3b8e1a38d5428920e0657ce299b20324d758"},+ {file = "markupsafe-3.0.3-cp39-cp39-musllinux_1_2_riscv64.whl", hash = "sha256:591ae9f2a647529ca990bc681daebdd52c8791ff06c2bfa05b65163e28102ef2"},+ {file = "markupsafe-3.0.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:a320721ab5a1aba0a233739394eb907f8c8da5c98c9181d1161e77a0c8e36f2d"},+ {file = "markupsafe-3.0.3-cp39-cp39-win32.whl", hash = "sha256:df2449253ef108a379b8b5d6b43f4b1a8e81a061d6537becd5582fba5f9196d7"},+ {file = "markupsafe-3.0.3-cp39-cp39-win_amd64.whl", hash = "sha256:7c3fb7d25180895632e5d3148dbdc29ea38ccb7fd210aa27acbd1201a1902c6e"},+ {file = "markupsafe-3.0.3-cp39-cp39-win_arm64.whl", hash = "sha256:38664109c14ffc9e7437e86b4dceb442b0096dfe3541d7864d9cbe1da4cf36c8"},+ {file = "markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698"},+]++[[package]]+name = "mitmproxy"+version = "12.2.3"+description = "An interactive, SSL/TLS-capable intercepting proxy for HTTP/1, HTTP/2, and WebSockets."+optional = false+python-versions = ">=3.12"+groups = ["main"]+files = [+ {file = "mitmproxy-12.2.3-py3-none-any.whl", hash = "sha256:df75ccd15ccb39ab55ce9dd4130312270e8ba208eb927a7cbe50cb52678ec722"},+]++[package.dependencies]+aioquic = "1.2.0"+argon2-cffi = ">=23.1.0,<=25.1.0"+asgiref = ">=3.2.10,<=3.11.1"+bcrypt = "5.0.0"+Brotli = ">=1.0,<=1.2.0"+certifi = ">=2019.9.11"+cryptography = ">=42.0,<=48.1"+flask = ">=3.0,<=3.1.3"+h11 = "0.16.0"+h2 = "4.3.0"+hyperframe = ">=6.0,<=6.1.0"+kaitaistruct = ">=0.10,<=0.11"+ldap3 = ">=2.8,<=2.9.1"+mitmproxy-rs = ">=0.12.6,<0.13"+msgpack = ">=1.0.0,<=1.1.2"+publicsuffix2 = ">=2.20190812,<=2.20191221"+pydivert = {version = ">=2.0.3,<=2.1.0", markers = "sys_platform == \"win32\""}+pyOpenSSL = ">=24.3,<=27.0.0"+pyparsing = ">=2.4.2,<=3.3.2"+pyperclip = ">=1.9.0,<=1.11.0"+"ruamel.yaml" = ">=0.18.10,<=0.19.1"+sortedcontainers = ">=2.3,<=2.4.0"+tornado = ">=6.5.0,<=6.5.5"+typing-extensions = {version = ">=4.13.2,<=4.14", markers = "python_version < \"3.13\""}+urwid = ">=2.6.14,<=3.0.5"+wsproto = ">=1.0,<=1.3.2"+zstandard = "0.25"++[[package]]+name = "mitmproxy-linux"+version = "0.12.11"+description = ""+optional = false+python-versions = ">=3.12"+groups = ["main"]+markers = "sys_platform == \"linux\""+files = [+ {file = "mitmproxy_linux-0.12.11-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3de4f96c11565cca2d051655f8ca23f8f24f4b3220e9ca3b0ad81007f293e9da"},+ {file = "mitmproxy_linux-0.12.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e5670a6b82546ebc0f947d79adfcb3c001ba3136a10ce848a2f4e2f336611c4"},+ {file = "mitmproxy_linux-0.12.11.tar.gz", hash = "sha256:3155d4aa6b3e038f97b39ed5aa7b1fc89e5b7d25d119a19581aa472dc606ae5c"},+]++[[package]]+name = "mitmproxy-macos"+version = "0.12.11"+description = ""+optional = false+python-versions = ">=3.12"+groups = ["main"]+markers = "sys_platform == \"darwin\""+files = [+ {file = "mitmproxy_macos-0.12.11-py3-none-any.whl", hash = "sha256:63349d9b46514ca679547651f7c0548f9222892edfbcba087b82b3244fbae859"},+]++[[package]]+name = "mitmproxy-rs"+version = "0.12.11"+description = ""+optional = false+python-versions = ">=3.12"+groups = ["main"]+files = [+ {file = "mitmproxy_rs-0.12.11-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:93f86706e779dd4a798c2d53cb82886b8c1f20edac5dee05da35f5c644da3531"},+ {file = "mitmproxy_rs-0.12.11-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d57eabeb5317e42a26d2878046c46079865e488f667898b1d67cc6f28d5bf85d"},+ {file = "mitmproxy_rs-0.12.11-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c5d00a02414de0a81c088e1b3b8bcb6af4c55332fa106dd8c454512b671477ba"},+ {file = "mitmproxy_rs-0.12.11-cp312-abi3-win_amd64.whl", hash = "sha256:9a55abf1b9cb0bf0ac073b1297a4fd83a7ae8a6b8311156cb71fb61320be233e"},+ {file = "mitmproxy_rs-0.12.11.tar.gz", hash = "sha256:6f5ecf3dd3c21e56191b84fc90364dc4d1dc95c660beedab4c816a0119ecb785"},+]++[package.dependencies]+mitmproxy-linux = {version = "0.12.11", markers = "sys_platform == \"linux\""}+mitmproxy-macos = {version = "0.12.11", markers = "sys_platform == \"darwin\""}+mitmproxy-windows = {version = "0.12.11", markers = "os_name == \"nt\""}++[[package]]+name = "mitmproxy-windows"+version = "0.12.11"+description = ""+optional = false+python-versions = ">=3.12"+groups = ["main"]+markers = "os_name == \"nt\""+files = [+ {file = "mitmproxy_windows-0.12.11-py3-none-any.whl", hash = "sha256:59addc8864669a08f8cb48d8b29129efb1ca5f6cba9696e2d91f1f506b21a2d7"},+]++[[package]]+name = "msgpack"+version = "1.1.2"+description = "MessagePack serializer"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "msgpack-1.1.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0051fffef5a37ca2cd16978ae4f0aef92f164df86823871b5162812bebecd8e2"},+ {file = "msgpack-1.1.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a605409040f2da88676e9c9e5853b3449ba8011973616189ea5ee55ddbc5bc87"},+ {file = "msgpack-1.1.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8b696e83c9f1532b4af884045ba7f3aa741a63b2bc22617293a2c6a7c645f251"},+ {file = "msgpack-1.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:365c0bbe981a27d8932da71af63ef86acc59ed5c01ad929e09a0b88c6294e28a"},+ {file = "msgpack-1.1.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:41d1a5d875680166d3ac5c38573896453bbbea7092936d2e107214daf43b1d4f"},+ {file = "msgpack-1.1.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:354e81bcdebaab427c3df4281187edc765d5d76bfb3a7c125af9da7a27e8458f"},+ {file = "msgpack-1.1.2-cp310-cp310-win32.whl", hash = "sha256:e64c8d2f5e5d5fda7b842f55dec6133260ea8f53c4257d64494c534f306bf7a9"},+ {file = "msgpack-1.1.2-cp310-cp310-win_amd64.whl", hash = "sha256:db6192777d943bdaaafb6ba66d44bf65aa0e9c5616fa1d2da9bb08828c6b39aa"},+ {file = "msgpack-1.1.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:2e86a607e558d22985d856948c12a3fa7b42efad264dca8a3ebbcfa2735d786c"},+ {file = "msgpack-1.1.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:283ae72fc89da59aa004ba147e8fc2f766647b1251500182fac0350d8af299c0"},+ {file = "msgpack-1.1.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:61c8aa3bd513d87c72ed0b37b53dd5c5a0f58f2ff9f26e1555d3bd7948fb7296"},+ {file = "msgpack-1.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:454e29e186285d2ebe65be34629fa0e8605202c60fbc7c4c650ccd41870896ef"},+ {file = "msgpack-1.1.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7bc8813f88417599564fafa59fd6f95be417179f76b40325b500b3c98409757c"},+ {file = "msgpack-1.1.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bafca952dc13907bdfdedfc6a5f579bf4f292bdd506fadb38389afa3ac5b208e"},+ {file = "msgpack-1.1.2-cp311-cp311-win32.whl", hash = "sha256:602b6740e95ffc55bfb078172d279de3773d7b7db1f703b2f1323566b878b90e"},+ {file = "msgpack-1.1.2-cp311-cp311-win_amd64.whl", hash = "sha256:d198d275222dc54244bf3327eb8cbe00307d220241d9cec4d306d49a44e85f68"},+ {file = "msgpack-1.1.2-cp311-cp311-win_arm64.whl", hash = "sha256:86f8136dfa5c116365a8a651a7d7484b65b13339731dd6faebb9a0242151c406"},+ {file = "msgpack-1.1.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:70a0dff9d1f8da25179ffcf880e10cf1aad55fdb63cd59c9a49a1b82290062aa"},+ {file = "msgpack-1.1.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:446abdd8b94b55c800ac34b102dffd2f6aa0ce643c55dfc017ad89347db3dbdb"},+ {file = "msgpack-1.1.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c63eea553c69ab05b6747901b97d620bb2a690633c77f23feb0c6a947a8a7b8f"},+ {file = "msgpack-1.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:372839311ccf6bdaf39b00b61288e0557916c3729529b301c52c2d88842add42"},+ {file = "msgpack-1.1.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:2929af52106ca73fcb28576218476ffbb531a036c2adbcf54a3664de124303e9"},+ {file = "msgpack-1.1.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:be52a8fc79e45b0364210eef5234a7cf8d330836d0a64dfbb878efa903d84620"},+ {file = "msgpack-1.1.2-cp312-cp312-win32.whl", hash = "sha256:1fff3d825d7859ac888b0fbda39a42d59193543920eda9d9bea44d958a878029"},+ {file = "msgpack-1.1.2-cp312-cp312-win_amd64.whl", hash = "sha256:1de460f0403172cff81169a30b9a92b260cb809c4cb7e2fc79ae8d0510c78b6b"},+ {file = "msgpack-1.1.2-cp312-cp312-win_arm64.whl", hash = "sha256:be5980f3ee0e6bd44f3a9e9dea01054f175b50c3e6cdb692bc9424c0bbb8bf69"},+ {file = "msgpack-1.1.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:4efd7b5979ccb539c221a4c4e16aac1a533efc97f3b759bb5a5ac9f6d10383bf"},+ {file = "msgpack-1.1.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:42eefe2c3e2af97ed470eec850facbe1b5ad1d6eacdbadc42ec98e7dcf68b4b7"},+ {file = "msgpack-1.1.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1fdf7d83102bf09e7ce3357de96c59b627395352a4024f6e2458501f158bf999"},+ {file = "msgpack-1.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fac4be746328f90caa3cd4bc67e6fe36ca2bf61d5c6eb6d895b6527e3f05071e"},+ {file = "msgpack-1.1.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:fffee09044073e69f2bad787071aeec727183e7580443dfeb8556cbf1978d162"},+ {file = "msgpack-1.1.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:5928604de9b032bc17f5099496417f113c45bc6bc21b5c6920caf34b3c428794"},+ {file = "msgpack-1.1.2-cp313-cp313-win32.whl", hash = "sha256:a7787d353595c7c7e145e2331abf8b7ff1e6673a6b974ded96e6d4ec09f00c8c"},+ {file = "msgpack-1.1.2-cp313-cp313-win_amd64.whl", hash = "sha256:a465f0dceb8e13a487e54c07d04ae3ba131c7c5b95e2612596eafde1dccf64a9"},+ {file = "msgpack-1.1.2-cp313-cp313-win_arm64.whl", hash = "sha256:e69b39f8c0aa5ec24b57737ebee40be647035158f14ed4b40e6f150077e21a84"},+ {file = "msgpack-1.1.2-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:e23ce8d5f7aa6ea6d2a2b326b4ba46c985dbb204523759984430db7114f8aa00"},+ {file = "msgpack-1.1.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:6c15b7d74c939ebe620dd8e559384be806204d73b4f9356320632d783d1f7939"},+ {file = "msgpack-1.1.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:99e2cb7b9031568a2a5c73aa077180f93dd2e95b4f8d3b8e14a73ae94a9e667e"},+ {file = "msgpack-1.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:180759d89a057eab503cf62eeec0aa61c4ea1200dee709f3a8e9397dbb3b6931"},+ {file = "msgpack-1.1.2-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:04fb995247a6e83830b62f0b07bf36540c213f6eac8e851166d8d86d83cbd014"},+ {file = "msgpack-1.1.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:8e22ab046fa7ede9e36eeb4cfad44d46450f37bb05d5ec482b02868f451c95e2"},+ {file = "msgpack-1.1.2-cp314-cp314-win32.whl", hash = "sha256:80a0ff7d4abf5fecb995fcf235d4064b9a9a8a40a3ab80999e6ac1e30b702717"},+ {file = "msgpack-1.1.2-cp314-cp314-win_amd64.whl", hash = "sha256:9ade919fac6a3e7260b7f64cea89df6bec59104987cbea34d34a2fa15d74310b"},+ {file = "msgpack-1.1.2-cp314-cp314-win_arm64.whl", hash = "sha256:59415c6076b1e30e563eb732e23b994a61c159cec44deaf584e5cc1dd662f2af"},+ {file = "msgpack-1.1.2-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:897c478140877e5307760b0ea66e0932738879e7aa68144d9b78ea4c8302a84a"},+ {file = "msgpack-1.1.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:a668204fa43e6d02f89dbe79a30b0d67238d9ec4c5bd8a940fc3a004a47b721b"},+ {file = "msgpack-1.1.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5559d03930d3aa0f3aacb4c42c776af1a2ace2611871c84a75afe436695e6245"},+ {file = "msgpack-1.1.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:70c5a7a9fea7f036b716191c29047374c10721c389c21e9ffafad04df8c52c90"},+ {file = "msgpack-1.1.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:f2cb069d8b981abc72b41aea1c580ce92d57c673ec61af4c500153a626cb9e20"},+ {file = "msgpack-1.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:d62ce1f483f355f61adb5433ebfd8868c5f078d1a52d042b0a998682b4fa8c27"},+ {file = "msgpack-1.1.2-cp314-cp314t-win32.whl", hash = "sha256:1d1418482b1ee984625d88aa9585db570180c286d942da463533b238b98b812b"},+ {file = "msgpack-1.1.2-cp314-cp314t-win_amd64.whl", hash = "sha256:5a46bf7e831d09470ad92dff02b8b1ac92175ca36b087f904a0519857c6be3ff"},+ {file = "msgpack-1.1.2-cp314-cp314t-win_arm64.whl", hash = "sha256:d99ef64f349d5ec3293688e91486c5fdb925ed03807f64d98d205d2713c60b46"},+ {file = "msgpack-1.1.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ea5405c46e690122a76531ab97a079e184c0daf491e588592d6a23d3e32af99e"},+ {file = "msgpack-1.1.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9fba231af7a933400238cb357ecccf8ab5d51535ea95d94fc35b7806218ff844"},+ {file = "msgpack-1.1.2-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a8f6e7d30253714751aa0b0c84ae28948e852ee7fb0524082e6716769124bc23"},+ {file = "msgpack-1.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:94fd7dc7d8cb0a54432f296f2246bc39474e017204ca6f4ff345941d4ed285a7"},+ {file = "msgpack-1.1.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:350ad5353a467d9e3b126d8d1b90fe05ad081e2e1cef5753f8c345217c37e7b8"},+ {file = "msgpack-1.1.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:6bde749afe671dc44893f8d08e83bf475a1a14570d67c4bb5cec5573463c8833"},+ {file = "msgpack-1.1.2-cp39-cp39-win32.whl", hash = "sha256:ad09b984828d6b7bb52d1d1d0c9be68ad781fa004ca39216c8a1e63c0f34ba3c"},+ {file = "msgpack-1.1.2-cp39-cp39-win_amd64.whl", hash = "sha256:67016ae8c8965124fdede9d3769528ad8284f14d635337ffa6a713a580f6c030"},+ {file = "msgpack-1.1.2.tar.gz", hash = "sha256:3b60763c1373dd60f398488069bcdc703cd08a711477b5d480eecc9f9626f47e"},+]++[[package]]+name = "mypy-extensions"+version = "1.1.0"+description = "Type system extensions for programs checked with the mypy type checker."+optional = false+python-versions = ">=3.8"+groups = ["dev"]+files = [+ {file = "mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505"},+ {file = "mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"},+]++[[package]]+name = "nodeenv"+version = "1.10.0"+description = "Node.js virtual environment builder"+optional = false+python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"+groups = ["dev"]+files = [+ {file = "nodeenv-1.10.0-py2.py3-none-any.whl", hash = "sha256:5bb13e3eed2923615535339b3c620e76779af4cb4c6a90deccc9e36b274d3827"},+ {file = "nodeenv-1.10.0.tar.gz", hash = "sha256:996c191ad80897d076bdfba80a41994c2b47c68e224c542b48feba42ba00f8bb"},+]++[[package]]+name = "packaging"+version = "26.3"+description = "Core utilities for Python packages"+optional = false+python-versions = ">=3.9"+groups = ["dev"]+files = [+ {file = "packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c"},+ {file = "packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79"},+]++[[package]]+name = "pathspec"+version = "1.1.1"+description = "Utility library for gitignore style pattern matching of file paths."+optional = false+python-versions = ">=3.9"+groups = ["dev"]+files = [+ {file = "pathspec-1.1.1-py3-none-any.whl", hash = "sha256:a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189"},+ {file = "pathspec-1.1.1.tar.gz", hash = "sha256:17db5ecd524104a120e173814c90367a96a98d07c45b2e10c2f3919fff91bf5a"},+]++[package.extras]+hyperscan = ["hyperscan (>=0.7)"]+optional = ["typing-extensions (>=4)"]+re2 = ["google-re2 (>=1.1)"]++[[package]]+name = "platformdirs"+version = "4.11.9"+description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`."+optional = false+python-versions = ">=3.10"+groups = ["dev"]+files = [+ {file = "platformdirs-4.11.9-py3-none-any.whl", hash = "sha256:0a3958f58a9e30321eaef0a424dd0b77cce242886b36b8aa992f9731ef2d59c1"},+ {file = "platformdirs-4.11.9.tar.gz", hash = "sha256:e2c66a8d384596cd98e3c4aea2d761df7bac95d9d8a2cc3946daa8cdafdaebc1"},+]++[[package]]+name = "pluggy"+version = "1.6.0"+description = "plugin and hook calling mechanisms for python"+optional = false+python-versions = ">=3.9"+groups = ["dev"]+files = [+ {file = "pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746"},+ {file = "pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3"},+]++[package.extras]+dev = ["pre-commit", "tox"]+testing = ["coverage", "pytest", "pytest-benchmark"]++[[package]]+name = "publicsuffix2"+version = "2.20191221"+description = "Get a public suffix for a domain name using the Public Suffix List. Forked from and using the same API as the publicsuffix package."+optional = false+python-versions = "*"+groups = ["main"]+files = [+ {file = "publicsuffix2-2.20191221-py2.py3-none-any.whl", hash = "sha256:786b5e36205b88758bd3518725ec8cfe7a8173f5269354641f581c6b80a99893"},+ {file = "publicsuffix2-2.20191221.tar.gz", hash = "sha256:00f8cc31aa8d0d5592a5ced19cccba7de428ebca985db26ac852d920ddd6fe7b"},+]++[[package]]+name = "pyasn1"+version = "0.6.4"+description = "Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "pyasn1-0.6.4-py3-none-any.whl", hash = "sha256:deda9277cfd454080ec40b207fb6df82206a3a2688735233cdcd8d3d565f088b"},+ {file = "pyasn1-0.6.4.tar.gz", hash = "sha256:9c447d8431c947fe4c8febc4ed9e760bc29011a5b01e5c74b67025bd9fb8ce81"},+]++[[package]]+name = "pycparser"+version = "3.0"+description = "C parser in Python"+optional = false+python-versions = ">=3.10"+groups = ["main"]+markers = "implementation_name != \"PyPy\""+files = [+ {file = "pycparser-3.0-py3-none-any.whl", hash = "sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992"},+ {file = "pycparser-3.0.tar.gz", hash = "sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29"},+]++[[package]]+name = "pydivert"+version = "2.1.0"+description = "Python binding to windivert driver"+optional = false+python-versions = "*"+groups = ["main"]+markers = "sys_platform == \"win32\""+files = [+ {file = "pydivert-2.1.0-py2.py3-none-any.whl", hash = "sha256:382db488e3c37c03ec9ec94e061a0b24334d78dbaeebb7d4e4d32ce4355d9da1"},+ {file = "pydivert-2.1.0.tar.gz", hash = "sha256:f0e150f4ff591b78e35f514e319561dadff7f24a82186a171dd4d465483de5b4"},+]++[package.extras]+docs = ["sphinx (>=1.4.8)"]+test = ["codecov (>=2.0.5)", "hypothesis (>=3.5.3)", "mock (>=1.0.1)", "pytest (>=3.0.3)", "pytest-cov (>=2.2.1)", "pytest-faulthandler (>=1.3.0,<2)", "pytest-timeout (>=1.0.0,<2)", "wheel (>=0.29)"]++[[package]]+name = "pygments"+version = "2.21.0"+description = "Pygments is a syntax highlighting package written in Python."+optional = false+python-versions = ">=3.9"+groups = ["dev"]+files = [+ {file = "pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9"},+ {file = "pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c"},+]++[package.extras]+windows-terminal = ["colorama (>=0.4.6)"]++[[package]]+name = "pylsqpack"+version = "0.3.24"+description = "Python wrapper for the ls-qpack QPACK library"+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "pylsqpack-0.3.24-cp310-abi3-macosx_10_9_x86_64.whl", hash = "sha256:8edf48d0a023cd3629b2c4aaccac9b79a46d566c0f61e7416b5678228433763d"},+ {file = "pylsqpack-0.3.24-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:e7d956dbc8f7d597b237b9157d0a16bc7c655a1b031239763c18dc8582aff8cc"},+ {file = "pylsqpack-0.3.24-cp310-abi3-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:b6a8bb42127d5ece8d301a673c8205df25b73b69f8c46b9f0c3034588de1789a"},+ {file = "pylsqpack-0.3.24-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e3f977d419c60c1d6c2240e6d7a52df820d37eb8c36b4057113bcd7859f53e2c"},+ {file = "pylsqpack-0.3.24-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6024854eb16d32803d4890fb90a73b9348c74b61c0770680aefaaa75f8456e8c"},+ {file = "pylsqpack-0.3.24-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:54978a9879471596d84bbad5e67d727014048926bc5bb2dac0eb3701b48c5ac9"},+ {file = "pylsqpack-0.3.24-cp310-abi3-musllinux_1_2_i686.whl", hash = "sha256:caf63ddc2e581c764d17432893acce02c5c29ff879d77c2abf1e26aa4eeb831b"},+ {file = "pylsqpack-0.3.24-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:e3dc5f146fd456b50b227858aed59faa0ff8445aa426e69bb4e50d46c487aab0"},+ {file = "pylsqpack-0.3.24-cp310-abi3-win32.whl", hash = "sha256:8da12be7b35b7c9a8cf73a4c077f72e5022a311f80a401c79904213376f2d767"},+ {file = "pylsqpack-0.3.24-cp310-abi3-win_amd64.whl", hash = "sha256:c3e2327af25ee616ce4483a8748f0957cf017cbca82d58ed15efea68f70f94ff"},+ {file = "pylsqpack-0.3.24-cp310-abi3-win_arm64.whl", hash = "sha256:23b4d8af48836893beac356c10ca268161953de5bf9ed691526a93f5c82433e9"},+ {file = "pylsqpack-0.3.24.tar.gz", hash = "sha256:8ec455f44614228f89e38d40c1b1e37895620e20ec6b21e3b562fa8b79a23890"},+]++[[package]]+name = "pyopenssl"+version = "26.2.0"+description = "Python wrapper module around the OpenSSL library"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "pyopenssl-26.2.0-py3-none-any.whl", hash = "sha256:4f9d971bc5298b8bc1fab282803da04bf000c755d4ad9d99b52de2569ca19a70"},+ {file = "pyopenssl-26.2.0.tar.gz", hash = "sha256:8c6fcecd1183a7fc897548dfe388b0cdb7f37e018200d8409cf33959dbe35387"},+]++[package.dependencies]+cryptography = ">=46.0.0,<49"+typing-extensions = {version = ">=4.9", markers = "python_version < \"3.13\" and python_version >= \"3.8\""}++[package.extras]+docs = ["sphinx (!=5.2.0,!=5.2.0.post0,!=7.2.5)", "sphinx_rtd_theme"]+test = ["pretend", "pytest (>=3.0.1)", "pytest-rerunfailures"]++[[package]]+name = "pyparsing"+version = "3.3.2"+description = "pyparsing - Classes and methods to define and execute parsing grammars"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "pyparsing-3.3.2-py3-none-any.whl", hash = "sha256:850ba148bd908d7e2411587e247a1e4f0327839c40e2e5e6d05a007ecc69911d"},+ {file = "pyparsing-3.3.2.tar.gz", hash = "sha256:c777f4d763f140633dcb6d8a3eda953bf7a214dc4eff598413c070bcdc117cbc"},+]++[package.extras]+diagrams = ["jinja2", "railroad-diagrams"]++[[package]]+name = "pyperclip"+version = "1.11.0"+description = "A cross-platform clipboard module for Python. (Only handles plain text for now.)"+optional = false+python-versions = "*"+groups = ["main"]+files = [+ {file = "pyperclip-1.11.0-py3-none-any.whl", hash = "sha256:299403e9ff44581cb9ba2ffeed69c7aa96a008622ad0c46cb575ca75b5b84273"},+ {file = "pyperclip-1.11.0.tar.gz", hash = "sha256:244035963e4428530d9e3a6101a1ef97209c6825edab1567beac148ccc1db1b6"},+]++[[package]]+name = "pyright"+version = "1.1.414"+description = "Command line wrapper for pyright"+optional = false+python-versions = ">=3.7"+groups = ["dev"]+files = [+ {file = "pyright-1.1.414-py3-none-any.whl", hash = "sha256:2a6b4b3298c9eec174c5ed83bd338de6eee82df2992f3e1930e6199d381be36f"},+ {file = "pyright-1.1.414.tar.gz", hash = "sha256:523c0a97c60da6333234955c277730c9cf4f5bd6d5399e7b7d2b0fc5d3599524"},+]++[package.dependencies]+nodeenv = ">=1.6.0"+typing-extensions = ">=4.1"++[package.extras]+all = ["nodejs-wheel-binaries", "twine (>=3.4.1)"]+dev = ["twine (>=3.4.1)"]+nodejs = ["nodejs-wheel-binaries"]++[[package]]+name = "pytest"+version = "8.4.2"+description = "pytest: simple powerful testing with Python"+optional = false+python-versions = ">=3.9"+groups = ["dev"]+files = [+ {file = "pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79"},+ {file = "pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01"},+]++[package.dependencies]+colorama = {version = ">=0.4", markers = "sys_platform == \"win32\""}+iniconfig = ">=1"+packaging = ">=20"+pluggy = ">=1.5,<2"+pygments = ">=2.7.2"++[package.extras]+dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "requests", "setuptools", "xmlschema"]++[[package]]+name = "pytest-asyncio"+version = "1.4.0"+description = "Pytest support for asyncio"+optional = false+python-versions = ">=3.10"+groups = ["dev"]+files = [+ {file = "pytest_asyncio-1.4.0-py3-none-any.whl", hash = "sha256:933ca923a23075a87fb7070c0ec272a6848489824d887c85c812670932835aa1"},+ {file = "pytest_asyncio-1.4.0.tar.gz", hash = "sha256:c6c0d2259945122819f171a32ecea2c349ead889ee28176caaf492143424be42"},+]++[package.dependencies]+pytest = ">=8.4,<10"+typing-extensions = {version = ">=4.12", markers = "python_version < \"3.13\""}++[package.extras]+docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1)", "sphinx-tabs (>=3.5)"]+testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"]++[[package]]+name = "redis"+version = "8.1.0"+description = "Python client for Redis database and key-value store"+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "redis-8.1.0-py3-none-any.whl", hash = "sha256:a4fe1aac3d3b3cc791d4b3d5931c5a956045dc951ee74d1c913ee3ac4d2ee9fb"},+ {file = "redis-8.1.0.tar.gz", hash = "sha256:6e1a19beef9225c83efd689c7e6b7da2d5215b1f42cd13b7fc3714d0a09c7b25"},+]++[package.extras]+circuit-breaker = ["pybreaker (>=1.4.0)"]+hiredis = ["hiredis (>=3.2.0)"]+jwt = ["pyjwt (>=2.13.0)"]+ocsp = ["cryptography (>=36.0.1)", "pyopenssl (>=20.0.1)", "requests (>=2.31.0)"]+otel = ["opentelemetry-api (>=1.39.1)", "opentelemetry-exporter-otlp-proto-http (>=1.39.1)", "opentelemetry-sdk (>=1.39.1)"]+xxhash = ["xxhash (>=3.6.0,<3.7.0)"]++[[package]]+name = "ruamel-yaml"+version = "0.19.1"+description = "ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "ruamel_yaml-0.19.1-py3-none-any.whl", hash = "sha256:27592957fedf6e0b62f281e96effd28043345e0e66001f97683aa9a40c667c93"},+ {file = "ruamel_yaml-0.19.1.tar.gz", hash = "sha256:53eb66cd27849eff968ebf8f0bf61f46cdac2da1d1f3576dd4ccee9b25c31993"},+]++[package.extras]+docs = ["mercurial (>5.7)", "ryd"]+jinja2 = ["ruamel.yaml.jinja2 (>=0.2)"]+libyaml = ["ruamel.yaml.clibz (>=0.3.7) ; platform_python_implementation == \"CPython\""]+oldlibyaml = ["ruamel.yaml.clib ; platform_python_implementation == \"CPython\""]++[[package]]+name = "ruff"+version = "0.15.22"+description = "An extremely fast Python linter and code formatter, written in Rust."+optional = false+python-versions = ">=3.7"+groups = ["dev"]+files = [+ {file = "ruff-0.15.22-py3-none-linux_armv6l.whl", hash = "sha256:44423e73493737f5e7c5b41d475483898ff37afcdae38bc3da5085e29af1c2d8"},+ {file = "ruff-0.15.22-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b82c6482946e9eda7ff2e091d25b8bad3f718684e1916d41bd56873cee05b697"},+ {file = "ruff-0.15.22-py3-none-macosx_11_0_arm64.whl", hash = "sha256:11c1c715af53a09f714e011106bffc419751ec8232fcb5da42173284ea3fec6f"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:742a29cf29bddb7c8327895d6a10e0e6c5b38a96dd407af9b5d0857f809c0576"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:72af58b951b0ae395935ae79763dc349bc0eb706319d28f7a33ad2cfb3cfc178"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:62d425005c1835eb24e2ee4161cb90e8db263415f4a71c8c72c33abaa6c0c224"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e8b9b3f8779a4f08c969defc3c8c35abffaa757e601ed5ae66d6d1db6519969a"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1e0dd1b2e4d3d585f897a0d137cbf4eaf6223bef4e8ce34d6bb12556c5f9249e"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:365523eb91d9224e1bcb03b022fbf0facb8f9e23792a2c53d9d4b3924bdbdebb"},+ {file = "ruff-0.15.22-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:fabfd168afdf29fee5be98b831efa9683c94d7c5a3b58b9ce5a2e38444589a74"},+ {file = "ruff-0.15.22-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:225dbf095a87f1d9f90f5fd7924d2613ee452a75a4308c63a8f50f761787aa7c"},+ {file = "ruff-0.15.22-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1877d63b9d24ed278744f1523fd11b85540566d54641f97c566d7d9dc5ca5296"},+ {file = "ruff-0.15.22-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a1606c510bd7215680d32efab38965f7cdec3ef69f5170a3f4791404ffdd5262"},+ {file = "ruff-0.15.22-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:630479b18625f5ffc373f77603a22a9f8ac0acd7ff0501178b5db28ec71e9c64"},+ {file = "ruff-0.15.22-py3-none-win32.whl", hash = "sha256:e5ba0e4a13fd14abbed2a77b517a3911290c6c6c59ef67784328d1668fab76cf"},+ {file = "ruff-0.15.22-py3-none-win_amd64.whl", hash = "sha256:9be63ba1eb936acd2d1342fb8337c356353706fce233b2a15a09a97037e6acde"},+ {file = "ruff-0.15.22-py3-none-win_arm64.whl", hash = "sha256:e1168075b72158510839f250027659cdd78476f40507dd517892304c41318661"},+ {file = "ruff-0.15.22.tar.gz", hash = "sha256:3f15175b1fb580126f58285a5dae6b2ea89000136d980c64499211f116b54809"},+]++[[package]]+name = "service-identity"+version = "26.1.0"+description = "Service identity verification for pyOpenSSL & cryptography."+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "service_identity-26.1.0-py3-none-any.whl", hash = "sha256:68c32dadbb69135fb951077677e07cd7f6031020f3a8c8f47a28cda8a0742118"},+ {file = "service_identity-26.1.0.tar.gz", hash = "sha256:6358c52882c96e66ac4a55eb3a72c7dd4a70763f8cc6fa4e70abde2656f4bf3b"},+]++[package.dependencies]+attrs = ">=19.1.0"+cryptography = ">=47"++[package.extras]+idna = ["idna"]++[[package]]+name = "sortedcontainers"+version = "2.4.0"+description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set"+optional = false+python-versions = "*"+groups = ["main"]+files = [+ {file = "sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"},+ {file = "sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88"},+]++[[package]]+name = "tornado"+version = "6.5.5"+description = "Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed."+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "tornado-6.5.5-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:487dc9cc380e29f58c7ab88f9e27cdeef04b2140862e5076a66fb6bb68bb1bfa"},+ {file = "tornado-6.5.5-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:65a7f1d46d4bb41df1ac99f5fcb685fb25c7e61613742d5108b010975a9a6521"},+ {file = "tornado-6.5.5-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:e74c92e8e65086b338fd56333fb9a68b9f6f2fe7ad532645a290a464bcf46be5"},+ {file = "tornado-6.5.5-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:435319e9e340276428bbdb4e7fa732c2d399386d1de5686cb331ec8eee754f07"},+ {file = "tornado-6.5.5-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:3f54aa540bdbfee7b9eb268ead60e7d199de5021facd276819c193c0fb28ea4e"},+ {file = "tornado-6.5.5-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:36abed1754faeb80fbd6e64db2758091e1320f6bba74a4cf8c09cd18ccce8aca"},+ {file = "tornado-6.5.5-cp39-abi3-win32.whl", hash = "sha256:dd3eafaaeec1c7f2f8fdcd5f964e8907ad788fe8a5a32c4426fbbdda621223b7"},+ {file = "tornado-6.5.5-cp39-abi3-win_amd64.whl", hash = "sha256:6443a794ba961a9f619b1ae926a2e900ac20c34483eea67be4ed8f1e58d3ef7b"},+ {file = "tornado-6.5.5-cp39-abi3-win_arm64.whl", hash = "sha256:2c9a876e094109333f888539ddb2de4361743e5d21eece20688e3e351e4990a6"},+ {file = "tornado-6.5.5.tar.gz", hash = "sha256:192b8f3ea91bd7f1f50c06955416ed76c6b72f96779b962f07f911b91e8d30e9"},+]++[[package]]+name = "typing-extensions"+version = "4.14.0"+description = "Backported and Experimental Type Hints for Python 3.9+"+optional = false+python-versions = ">=3.9"+groups = ["main", "dev"]+files = [+ {file = "typing_extensions-4.14.0-py3-none-any.whl", hash = "sha256:a1514509136dd0b477638fc68d6a91497af5076466ad0fa6c338e44e359944af"},+ {file = "typing_extensions-4.14.0.tar.gz", hash = "sha256:8676b788e32f02ab42d9e7c61324048ae4c6d844a399eebace3d4979d75ceef4"},+]+markers = {main = "python_version == \"3.12\""}++[[package]]+name = "urwid"+version = "3.0.5"+description = "A full-featured console (xterm et al.) user interface library"+optional = false+python-versions = ">=3.9.0"+groups = ["main"]+files = [+ {file = "urwid-3.0.5-py3-none-any.whl", hash = "sha256:f188144261224fdfc9b56b4222869bd0eac90fd7895cf1e376129cdc7e13bc84"},+ {file = "urwid-3.0.5.tar.gz", hash = "sha256:24be27ffafdb68c09cd95dc21b60ccfd02843320b25ce5feee1708b34fad5a23"},+]++[package.dependencies]+wcwidth = ">=0.4"++[package.extras]+curses = ["windows-curses ; sys_platform == \"win32\""]+glib = ["PyGObject"]+lcd = ["pyserial"]+serial = ["pyserial"]+tornado = ["tornado (>=5.0)"]+trio = ["exceptiongroup ; python_version < \"3.11\"", "trio (>=0.24.0)"]+twisted = ["twisted"]+zmq = ["zmq"]++[[package]]+name = "wcwidth"+version = "0.8.3"+description = "Measures the displayed width of unicode strings in a terminal"+optional = false+python-versions = ">=3.8"+groups = ["main"]+files = [+ {file = "wcwidth-0.8.3-py3-none-any.whl", hash = "sha256:d5b73dba6158a595ec9370350e7f2637bcac8d6c5e4fde34f30fcffb6103a5e4"},+ {file = "wcwidth-0.8.3.tar.gz", hash = "sha256:d128512515fbf4612e0ff21fd6380399210318b7b54a9af59dff8454cf9730eb"},+]++[[package]]+name = "werkzeug"+version = "3.1.8"+description = "The comprehensive WSGI web application library."+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "werkzeug-3.1.8-py3-none-any.whl", hash = "sha256:63a77fb8892bf28ebc3178683445222aa500e48ebad5ec77b0ad80f8726b1f50"},+ {file = "werkzeug-3.1.8.tar.gz", hash = "sha256:9bad61a4268dac112f1c5cd4630a56ede601b6ed420300677a869083d70a4c44"},+]++[package.dependencies]+markupsafe = ">=2.1.1"++[package.extras]+watchdog = ["watchdog (>=2.3)"]++[[package]]+name = "wsproto"+version = "1.3.2"+description = "Pure-Python WebSocket protocol implementation"+optional = false+python-versions = ">=3.10"+groups = ["main"]+files = [+ {file = "wsproto-1.3.2-py3-none-any.whl", hash = "sha256:61eea322cdf56e8cc904bd3ad7573359a242ba65688716b0710a5eb12beab584"},+ {file = "wsproto-1.3.2.tar.gz", hash = "sha256:b86885dcf294e15204919950f666e06ffc6c7c114ca900b060d6e16293528294"},+]++[package.dependencies]+h11 = ">=0.16.0,<1"++[[package]]+name = "zstandard"+version = "0.25.0"+description = "Zstandard bindings for Python"+optional = false+python-versions = ">=3.9"+groups = ["main"]+files = [+ {file = "zstandard-0.25.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e59fdc271772f6686e01e1b3b74537259800f57e24280be3f29c8a0deb1904dd"},+ {file = "zstandard-0.25.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4d441506e9b372386a5271c64125f72d5df6d2a8e8a2a45a0ae09b03cb781ef7"},+ {file = "zstandard-0.25.0-cp310-cp310-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:ab85470ab54c2cb96e176f40342d9ed41e58ca5733be6a893b730e7af9c40550"},+ {file = "zstandard-0.25.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:e05ab82ea7753354bb054b92e2f288afb750e6b439ff6ca78af52939ebbc476d"},+ {file = "zstandard-0.25.0-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:78228d8a6a1c177a96b94f7e2e8d012c55f9c760761980da16ae7546a15a8e9b"},+ {file = "zstandard-0.25.0-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:2b6bd67528ee8b5c5f10255735abc21aa106931f0dbaf297c7be0c886353c3d0"},+ {file = "zstandard-0.25.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:4b6d83057e713ff235a12e73916b6d356e3084fd3d14ced499d84240f3eecee0"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:9174f4ed06f790a6869b41cba05b43eeb9a35f8993c4422ab853b705e8112bbd"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:25f8f3cd45087d089aef5ba3848cd9efe3ad41163d3400862fb42f81a3a46701"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3756b3e9da9b83da1796f8809dd57cb024f838b9eeafde28f3cb472012797ac1"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:81dad8d145d8fd981b2962b686b2241d3a1ea07733e76a2f15435dfb7fb60150"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a5a419712cf88862a45a23def0ae063686db3d324cec7edbe40509d1a79a0aab"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:e7360eae90809efd19b886e59a09dad07da4ca9ba096752e61a2e03c8aca188e"},+ {file = "zstandard-0.25.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:75ffc32a569fb049499e63ce68c743155477610532da1eb38e7f24bf7cd29e74"},+ {file = "zstandard-0.25.0-cp310-cp310-win32.whl", hash = "sha256:106281ae350e494f4ac8a80470e66d1fe27e497052c8d9c3b95dc4cf1ade81aa"},+ {file = "zstandard-0.25.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea9d54cc3d8064260114a0bbf3479fc4a98b21dffc89b3459edd506b69262f6e"},+ {file = "zstandard-0.25.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:933b65d7680ea337180733cf9e87293cc5500cc0eb3fc8769f4d3c88d724ec5c"},+ {file = "zstandard-0.25.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a3f79487c687b1fc69f19e487cd949bf3aae653d181dfb5fde3bf6d18894706f"},+ {file = "zstandard-0.25.0-cp311-cp311-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:0bbc9a0c65ce0eea3c34a691e3c4b6889f5f3909ba4822ab385fab9057099431"},+ {file = "zstandard-0.25.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:01582723b3ccd6939ab7b3a78622c573799d5d8737b534b86d0e06ac18dbde4a"},+ {file = "zstandard-0.25.0-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:5f1ad7bf88535edcf30038f6919abe087f606f62c00a87d7e33e7fc57cb69fcc"},+ {file = "zstandard-0.25.0-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:06acb75eebeedb77b69048031282737717a63e71e4ae3f77cc0c3b9508320df6"},+ {file = "zstandard-0.25.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9300d02ea7c6506f00e627e287e0492a5eb0371ec1670ae852fefffa6164b072"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfd06b1c5584b657a2892a6014c2f4c20e0db0208c159148fa78c65f7e0b0277"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f373da2c1757bb7f1acaf09369cdc1d51d84131e50d5fa9863982fd626466313"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6c0e5a65158a7946e7a7affa6418878ef97ab66636f13353b8502d7ea03c8097"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:c8e167d5adf59476fa3e37bee730890e389410c354771a62e3c076c86f9f7778"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:98750a309eb2f020da61e727de7d7ba3c57c97cf6213f6f6277bb7fb42a8e065"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:22a086cff1b6ceca18a8dd6096ec631e430e93a8e70a9ca5efa7561a00f826fa"},+ {file = "zstandard-0.25.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:72d35d7aa0bba323965da807a462b0966c91608ef3a48ba761678cb20ce5d8b7"},+ {file = "zstandard-0.25.0-cp311-cp311-win32.whl", hash = "sha256:f5aeea11ded7320a84dcdd62a3d95b5186834224a9e55b92ccae35d21a8b63d4"},+ {file = "zstandard-0.25.0-cp311-cp311-win_amd64.whl", hash = "sha256:daab68faadb847063d0c56f361a289c4f268706b598afbf9ad113cbe5c38b6b2"},+ {file = "zstandard-0.25.0-cp311-cp311-win_arm64.whl", hash = "sha256:22a06c5df3751bb7dc67406f5374734ccee8ed37fc5981bf1ad7041831fa1137"},+ {file = "zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b"},+ {file = "zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00"},+ {file = "zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64"},+ {file = "zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea"},+ {file = "zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb"},+ {file = "zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a"},+ {file = "zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512"},+ {file = "zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa"},+ {file = "zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd"},+ {file = "zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01"},+ {file = "zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9"},+ {file = "zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94"},+ {file = "zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1"},+ {file = "zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f"},+ {file = "zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea"},+ {file = "zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e"},+ {file = "zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551"},+ {file = "zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98"},+ {file = "zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf"},+ {file = "zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09"},+ {file = "zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5"},+ {file = "zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049"},+ {file = "zstandard-0.25.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:e29f0cf06974c899b2c188ef7f783607dbef36da4c242eb6c82dcd8b512855e3"},+ {file = "zstandard-0.25.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:05df5136bc5a011f33cd25bc9f506e7426c0c9b3f9954f056831ce68f3b6689f"},+ {file = "zstandard-0.25.0-cp314-cp314-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:f604efd28f239cc21b3adb53eb061e2a205dc164be408e553b41ba2ffe0ca15c"},+ {file = "zstandard-0.25.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:223415140608d0f0da010499eaa8ccdb9af210a543fac54bce15babbcfc78439"},+ {file = "zstandard-0.25.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2e54296a283f3ab5a26fc9b8b5d4978ea0532f37b231644f367aa588930aa043"},+ {file = "zstandard-0.25.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:ca54090275939dc8ec5dea2d2afb400e0f83444b2fc24e07df7fdef677110859"},+ {file = "zstandard-0.25.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e09bb6252b6476d8d56100e8147b803befa9a12cea144bbe629dd508800d1ad0"},+ {file = "zstandard-0.25.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:a9ec8c642d1ec73287ae3e726792dd86c96f5681eb8df274a757bf62b750eae7"},+ {file = "zstandard-0.25.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4089a10e598eae6393756b036e0f419e8c1d60f44a831520f9af41c14216cf2"},+ {file = "zstandard-0.25.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:f67e8f1a324a900e75b5e28ffb152bcac9fbed1cc7b43f99cd90f395c4375344"},+ {file = "zstandard-0.25.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:9654dbc012d8b06fc3d19cc825af3f7bf8ae242226df5f83936cb39f5fdc846c"},+ {file = "zstandard-0.25.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4203ce3b31aec23012d3a4cf4a2ed64d12fea5269c49aed5e4c3611b938e4088"},+ {file = "zstandard-0.25.0-cp314-cp314-win32.whl", hash = "sha256:da469dc041701583e34de852d8634703550348d5822e66a0c827d39b05365b12"},+ {file = "zstandard-0.25.0-cp314-cp314-win_amd64.whl", hash = "sha256:c19bcdd826e95671065f8692b5a4aa95c52dc7a02a4c5a0cac46deb879a017a2"},+ {file = "zstandard-0.25.0-cp314-cp314-win_arm64.whl", hash = "sha256:d7541afd73985c630bafcd6338d2518ae96060075f9463d7dc14cfb33514383d"},+ {file = "zstandard-0.25.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b9af1fe743828123e12b41dd8091eca1074d0c1569cc42e6e1eee98027f2bbd0"},+ {file = "zstandard-0.25.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4b14abacf83dfb5c25eb4e4a79520de9e7e205f72c9ee7702f91233ae57d33a2"},+ {file = "zstandard-0.25.0-cp39-cp39-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:a51ff14f8017338e2f2e5dab738ce1ec3b5a851f23b18c1ae1359b1eecbee6df"},+ {file = "zstandard-0.25.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:3b870ce5a02d4b22286cf4944c628e0f0881b11b3f14667c1d62185a99e04f53"},+ {file = "zstandard-0.25.0-cp39-cp39-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:05353cef599a7b0b98baca9b068dd36810c3ef0f42bf282583f438caf6ddcee3"},+ {file = "zstandard-0.25.0-cp39-cp39-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:19796b39075201d51d5f5f790bf849221e58b48a39a5fc74837675d8bafc7362"},+ {file = "zstandard-0.25.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:53e08b2445a6bc241261fea89d065536f00a581f02535f8122eba42db9375530"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:1f3689581a72eaba9131b1d9bdbfe520ccd169999219b41000ede2fca5c1bfdb"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d8c56bb4e6c795fc77d74d8e8b80846e1fb8292fc0b5060cd8131d522974b751"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:53f94448fe5b10ee75d246497168e5825135d54325458c4bfffbaafabcc0a577"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:c2ba942c94e0691467ab901fc51b6f2085ff48f2eea77b1a48240f011e8247c7"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:07b527a69c1e1c8b5ab1ab14e2afe0675614a09182213f21a0717b62027b5936"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:51526324f1b23229001eb3735bc8c94f9c578b1bd9e867a0a646a3b17109f388"},+ {file = "zstandard-0.25.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:89c4b48479a43f820b749df49cd7ba2dbc2b1b78560ecb5ab52985574fd40b27"},+ {file = "zstandard-0.25.0-cp39-cp39-win32.whl", hash = "sha256:1cd5da4d8e8ee0e88be976c294db744773459d51bb32f707a0f166e5ad5c8649"},+ {file = "zstandard-0.25.0-cp39-cp39-win_amd64.whl", hash = "sha256:37daddd452c0ffb65da00620afb8e17abd4adaae6ce6310702841760c2c26860"},+ {file = "zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b"},+]++[package.extras]+cffi = ["cffi (>=1.17,<2.0) ; platform_python_implementation != \"PyPy\" and python_version < \"3.14\"", "cffi (>=2.0.0b) ; platform_python_implementation != \"PyPy\" and python_version >= \"3.14\""]++[metadata]+lock-version = "2.1"+python-versions = ">=3.12,<3.14"+content-hash = "fd37f95c016409583ca7748f27b59d7b8cef351765825b38096134657149be4e"diff --git a/autogpt_platform/swap_proxy/pyproject.toml b/autogpt_platform/swap_proxy/pyproject.tomlnew file mode 100644index 0000000000..a0559413f6--- /dev/null+++ b/autogpt_platform/swap_proxy/pyproject.toml@@ -0,0 +1,48 @@+[tool.poetry]+name = "autogpt-swap-proxy"+version = "0.1.0"+description = "The proxy every AutoPilot sandbox egresses through: swaps credential placeholders for real values on the way out"+authors = ["AutoGPT <[email protected]>"]+readme = "README.md"+packages = [{ include = "swap_proxy" }]++[tool.poetry.dependencies]+python = ">=3.12,<3.14"+# These three come with mitmproxy; named because decode.py and addon.py use+# them directly, and brotli's bounded decode (output_buffer_limit) needs 1.2.+brotli = ">=1.2.0"+httpx = "^0.28.1"+mitmproxy = "^12.2.3"+pyopenssl = ">=24"+redis = "^8.1.0"+zstandard = ">=0.23.0"++[tool.poetry.group.dev.dependencies]+black = "^24.10.0"+isort = "^5.13.2"+pyright = "^1.1.407"+pytest = "^8.4.1"+pytest-asyncio = "^1.1.0"+ruff = "^0.15.0"++[tool.poetry.scripts]+swap-proxy = "swap_proxy.__main__:main"++[build-system]+requires = ["poetry-core"]+build-backend = "poetry.core.masonry.api"++[tool.black]+line-length = 88++[tool.isort]+profile = "black"++[tool.ruff]+target-version = "py312"++[tool.pyright]+pythonVersion = "3.12"++[tool.pytest.ini_options]+asyncio_mode = "auto"diff --git a/autogpt_platform/swap_proxy/swap_proxy/__init__.py b/autogpt_platform/swap_proxy/swap_proxy/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/autogpt_platform/swap_proxy/swap_proxy/__main__.py b/autogpt_platform/swap_proxy/swap_proxy/__main__.pynew file mode 100644index 0000000000..206e45d774--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/__main__.py@@ -0,0 +1,136 @@+"""Run the proxy: mitmproxy in SOCKS5 mode with the swap addon."""++import asyncio+import logging+import os++from mitmproxy.options import Options+from mitmproxy.tools.dump import DumpMaster+from redis.asyncio.cluster import ClusterNode, RedisCluster++from swap_proxy.addon import MAX_BODY_BYTES, SwapProxyAddon+from swap_proxy.egress import EgressGuard+from swap_proxy.owners import OwnerDirectory+from swap_proxy.settings import Settings+from swap_proxy.source import BackendCredentialSource++logger = logging.getLogger(__name__)+++def build_master(+ addon: SwapProxyAddon, listen_host: str, listen_port: int, confdir: str+):+ """A mitmproxy master that serves SOCKS5 and authenticates through *addon*."""+ options = Options(+ mode=[f"socks5@{listen_host}:{listen_port}"],+ confdir=os.path.expanduser(confdir),+ # The swap trusts the upstream certificate check; never turn it off.+ ssl_insecure=False,+ )+ master = DumpMaster(options, with_termlog=True, with_dumper=False)+ # mitmproxy's SOCKS5 layer asks the client for a username and password+ # only when ``proxyauth`` is set, and its built-in addon of that name would+ # then also demand credentials of its own on every request. Remove the+ # addon and keep the option: the value is never compared to anything, the+ # pair is judged by SwapProxyAddon.socks5_auth alone.+ master.addons.remove(master.addons.get("proxyauth"))+ master.addons.add(addon)+ master.options.update(+ proxyauth="per-box",+ # A proxy carrying every box's downloads cannot hold them in memory.+ # The addon decides what that means for a body that needed a swap or a+ # scrub; see "Bodies and streaming" in ``addon.py``.+ stream_large_bodies=str(MAX_BODY_BYTES),+ # Upstream first, so that by the time a request is read the name its+ # certificate was verified for is known.+ connection_strategy="eager",+ )+ return master+++CA_FILE = "mitmproxy-ca.pem"+DHPARAM_FILE = "mitmproxy-dhparam.pem"+++class MissingCA(RuntimeError):+ pass+++def require_ca(confdir: str, generate: bool) -> None:+ """Refuse to start without the provisioned CA.++ mitmproxy generates one when the directory has none. The boxes trust one+ certificate, so a CA made up by a restarted or second replica breaks TLS+ to every bound host inside every box, and reads there as a certificate+ bug, not as missing provisioning. Better not to come up at all.+ """+ directory = os.path.expanduser(confdir)+ path = os.path.join(directory, CA_FILE)+ if os.path.isfile(path):+ dhparam = os.path.join(directory, DHPARAM_FILE)+ if not os.path.isfile(dhparam) and not os.access(directory, os.W_OK):+ # mitmproxy writes this file next to the CA when it is missing.+ raise MissingCA(+ f"{directory} is read-only and has no {DHPARAM_FILE}. Mount it "+ f"beside {CA_FILE} (it is not a secret: fixed public parameters "+ "mitmproxy writes out with every CA), or make the directory writable."+ )+ return+ if generate:+ logger.warning("No CA at %s: generating one. Local use only.", path)+ return+ raise MissingCA(+ f"No signing CA at {path}. Mount the provisioned CA (private key and "+ f"certificate in one PEM file named {CA_FILE}) into SWAP_PROXY_CONFDIR; "+ "every replica must get the same one. For a local run, set "+ "SWAP_PROXY_GENERATE_CA=true."+ )+++def connect_redis(settings: Settings) -> RedisCluster:+ def remap(address: tuple[str, int]) -> tuple[str, int]:+ # As the backend does: pin every shard to the seed host unless the+ # announced names resolve from here.+ if settings.redis_use_announced_address:+ return address+ return settings.redis_host, address[1]++ return RedisCluster(+ startup_nodes=[ClusterNode(settings.redis_host, settings.redis_port)],+ password=settings.redis_password,+ socket_timeout=5,+ socket_connect_timeout=5,+ address_remap=remap,+ )+++async def run() -> None:+ settings = Settings()+ require_ca(settings.confdir, settings.generate_ca)+ redis = connect_redis(settings)+ await redis.ping()+ source = BackendCredentialSource(settings.backend_url)+ addon = SwapProxyAddon(+ OwnerDirectory(redis), source, EgressGuard(settings.egress_allow)+ )+ master = build_master(+ addon, settings.listen_host, settings.listen_port, settings.confdir+ )+ logger.info("Swap proxy on %s:%s", settings.listen_host, settings.listen_port)+ try:+ await master.run()+ finally:+ await source.aclose()+ await redis.aclose()+++def main() -> None:+ logging.basicConfig(+ level=os.getenv("SWAP_PROXY_LOG_LEVEL", "INFO"),+ format="%(asctime)s %(levelname)s %(name)s %(message)s",+ )+ asyncio.run(run())+++if __name__ == "__main__":+ main()diff --git a/autogpt_platform/swap_proxy/swap_proxy/addon.py b/autogpt_platform/swap_proxy/swap_proxy/addon.pynew file mode 100644index 0000000000..347d9e0934--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/addon.py@@ -0,0 +1,798 @@+"""The mitmproxy addon: owners at the door, the guard on the way out, the swap+in between.++One connection's life:++1. ``socks5_auth``: E2B's host presents the box's proxy credential. It+ resolves to an owner or the connection is refused (``owners.py``).+2. ``server_connect``: the destination is resolved, checked against private+ address space and pinned (``egress.py``).+3. ``tls_clienthello``: if no credential is bound to the host being dialled,+ the connection is passed through untouched: no interception, no decryption.+ If the backend has never answered, a swapping owner's connection is opened+ anyway, so that what cannot be scrubbed is refused rather than tunnelled.+ Only hosts that can receive a credential are opened. spark-vm intercepts+ everything; serving many users, we decrypt only what we must.+4. ``request``: placeholders are swapped for the owner's values (``swap.py``),+ fetched from the backend for this user and this host (``source.py``). By+ default only in the ``Authorization`` header; anywhere else only for a+ credential with ``swap_anywhere``, which nothing sets yet.+5. ``response``: known values are scrubbed back into placeholders. Websocket+ messages get the same two steps, one per direction (the swap into a+ message only with ``swap_anywhere``).++Bodies and streaming. mitmproxy streams a body larger than ``MAX_BODY_BYTES``+instead of holding it, and a streamed message's head is on the wire before+``request`` / ``response`` fire, so those two hooks alone would swap too late+and scrub nothing. ``requestheaders`` and ``responseheaders`` therefore decide+first, for any body not known to fit:++- The head of a request (the ``Authorization`` header; with ``swap_anywhere``+ also other headers, path and query) is swapped in ``requestheaders``,+ before anything is sent. A large ``git push`` authenticates this way while+ its pack streams through.+- A text body of unknown length (chunked, or HTTP/2 without a length) is held+ back by ``BufferedBody`` up to ``MAX_BODY_BYTES`` and swapped or scrubbed+ whole. A request body only if a credential for the host has+ ``swap_anywhere``: otherwise nothing can be swapped into it, and it streams.+- A text *response* that is, or turns out to be, larger than that is refused:+ the flow is killed and the refusal audited. It is never passed on+ unscrubbed.+- A text *request* body larger than that goes out as it is, its placeholders+ literal, and (with ``swap_anywhere``) the audit says so. That is the safe direction: the request+ fails at the provider and nothing leaks.+- Binary bodies stream untouched in both directions; they are neither swapped+ nor scrubbed at any size.+- A held body with a ``Content-Encoding`` is decoded within+ ``MAX_DECODED_BYTES`` (``decode.py``), never through mitmproxy's unbounded+ ``.content``. Past that, or in an encoding that cannot be decoded within a+ bound, a response is refused like one too large to scrub, and a request+ body goes out as it is, audited as not swapped.++The audit records a swap only for bytes that have not left yet.++What is scrubbed is the owner's current values for the host plus those+swapped into the flow itself. When the backend cannot say what the owner's+values are, a text response is refused and a server websocket message is+dropped, for an owner who gets swaps: an empty answer is not an empty set.++A value is swapped only into a request that is provably going to the bound+host: the scheme is https, mitmproxy has verified the upstream certificate+(its default, never turned off here), and the ``Host`` the request names is+the name that certificate was verified for. The SOCKS5 destination alone+proves nothing, since the box chooses it.++Known limit: a connection stays authenticated for as long as it stays open,+also after its box's credential was rotated by a reconnect. The credential it+presented was valid and the box is the same box; new connections need the new+one.+"""++import ipaddress+import json+import logging+import weakref+from collections.abc import Callable, Iterable+from dataclasses import dataclass, field+from datetime import datetime, timezone+from typing import Optional, Union++from mitmproxy import connection, http, tls+from mitmproxy.net.http.http1.read import expected_http_body_size+from mitmproxy.net.http.url import parse_authority+from mitmproxy.proxy import commands, events, layer, layers, server_hooks+from mitmproxy.proxy.layers import modes+from OpenSSL import SSL++from swap_proxy.decode import DecodedTooLarge, Undecodable, bounded_decode+from swap_proxy.egress import EgressGuard+from swap_proxy.owners import Owner, OwnerDirectory+from swap_proxy.source import CredentialSource, SourceUnavailable+from swap_proxy.swap import (+ PLACEHOLDER_RE,+ Credential,+ RequestSwap,+ SwapEvent,+ is_scrubbable,+ placeholder_names,+ scrub_bytes,+ scrub_text,+)++logger = logging.getLogger(__name__)+audit_logger = logging.getLogger("swap_proxy.audit")++# The one size in this service. Up to here a body is held in memory, so it can+# be swapped or scrubbed; mitmproxy streams anything larger+# (``stream_large_bodies`` is set to this very number in ``__main__``). It+# bounds what one connection can make the proxy hold, and the synchronous swap+# and scrub work one message can put on the shared event loop.+MAX_BODY_BYTES = 5 * 1024 * 1024+# What a held body may decode to. ``MAX_BODY_BYTES`` counts bytes on the wire,+# and a compressed body stands for more: ordinary JSON or HTML shrinks to a+# fifth or less, a bomb to a thousandth. Four times the wire limit lets most+# honest compressed bodies through and keeps one message's memory, and its+# decode-swap-scrub-encode time on the shared event loop, within a small+# multiple of what an unencoded body costs. Enforced while decoding+# (``decode.py``), never by measuring a body that was already decoded.+MAX_DECODED_BYTES = 4 * MAX_BODY_BYTES++_HEAD_SWAPPED = "swap_proxy_head_swapped"+# The credentials whose values went into this flow, by name, and the swapped+# Basic pairs (``RequestSwap.encoded``).+_SWAPPED = "swap_proxy_swapped"+_ENCODED = "swap_proxy_encoded"+++class BufferedBody:+ """A ``stream`` callable that holds a body back and releases it transformed.++ mitmproxy calls it with every chunk and once more with ``b""`` at the end.+ Up to *limit* bytes are kept and nothing is forwarded; at the end+ *transform* gets the whole body and its result is sent. Past the limit,+ or if data follows the end marker (an empty chunk mid-body would otherwise+ split a value across two transforms), *overflow* is told why, once. What+ it returns decides the rest: ``True`` releases what was held and lets the+ remainder through untouched, ``False`` forwards nothing more.++ It returns lists: an empty ``bytes`` would be sent as a zero-length chunk,+ which ends a chunked body.+ """++ def __init__(+ self,+ limit: int,+ transform: Callable[[bytes], bytes],+ overflow: Callable[[str], bool],+ ):+ self._limit = limit+ self._transform = transform+ self._overflow = overflow+ self._held: list[bytes] = []+ self._size = 0+ self._ended = False+ self._release: Optional[bool] = None # set once overflowed++ def __call__(self, chunk: bytes) -> list[bytes]:+ if self._release is not None:+ return [chunk] if self._release and chunk else []+ if chunk and self._ended:+ return self._give_up("data-after-end", chunk)+ if not chunk:+ self._ended = True+ body, self._held, self._size = b"".join(self._held), [], 0+ out = self._transform(body) if body else b""+ return [out] if out else []+ self._size += len(chunk)+ if self._size > self._limit:+ return self._give_up("body-too-large", chunk)+ self._held.append(chunk)+ return []++ def _give_up(self, reason: str, chunk: bytes) -> list[bytes]:+ held, self._held = self._held, []+ self._release = self._overflow(reason)+ return [*held, chunk] if self._release else []+++_UNAVAILABLE = "resolver-unavailable"+++@dataclass+class _Lookup:+ """The owner's credentials for a host, and why each other name has none."""++ credentials: dict[str, Credential] = field(default_factory=dict)+ refused: dict[str, str] = field(default_factory=dict)+ # A reason that holds for every name, whatever it is.+ blanket: str = ""++ @property+ def unavailable(self) -> bool:+ """The backend could not say, for some name or all of them: what the+ owner has for this host is unknown, which is not the same as nothing."""+ return self.blanket == _UNAVAILABLE or _UNAVAILABLE in self.refused.values()++ def refusals(self, names: set[str]) -> list[SwapEvent]:+ return [+ SwapEvent(+ "refused",+ f"hsurr:{name}",+ self.blanket or self.refused.get(name, "unbound-host"),+ )+ for name in sorted(names - self.credentials.keys())+ ]+++def _any_anywhere(lookup: _Lookup) -> bool:+ """Could a value of these go into a request body?"""+ return any(c.swap_anywhere for c in lookup.credentials.values())+++_NOT_READABLE = {+ DecodedTooLarge: "decoded-too-large",+ Undecodable: "undecodable-encoding",+}+++def plain_copy(message: http.Message) -> http.Message:+ """*message* with its content encoding undone, within ``MAX_DECODED_BYTES``:+ itself if it has none, else a copy. mitmproxy's own ``.content`` and+ ``.text`` decode without a bound, so an encoded body is only ever read+ through this. Raises ``DecodedTooLarge`` or ``Undecodable``."""+ encoding = message.headers.get("content-encoding", "")+ if encoding.strip().lower() in ("", "none", "identity"):+ return message+ decoded = bounded_decode(message.raw_content or b"", encoding, MAX_DECODED_BYTES)+ plain = message.copy()+ del plain.headers["content-encoding"]+ plain.raw_content = decoded+ return plain+++def put_back(message: http.Message, plain: http.Message) -> None:+ """Re-encode what was changed in a ``plain_copy`` into the message."""+ if plain is not message:+ message.content = plain.raw_content+++def is_address(host: str) -> bool:+ try:+ ipaddress.ip_address(host.strip("[]").split("%")[0])+ except ValueError:+ return False+ return True+++def known_size(+ request: http.Request, response: Optional[http.Response]+) -> Optional[int]:+ """The body's length if it is fixed before the body arrives, else ``None``:+ chunked, read-until-close, HTTP/2 without a length, or a bad header."""+ message = response or request+ try:+ size = expected_http_body_size(request, response)+ except ValueError:+ return None+ if size is None or size < 0:+ return None+ if "content-length" not in message.headers and not request.http_version.startswith(+ "HTTP/1"+ ):+ return None+ return size+++class ClosingLayer(layer.Layer):+ """Closes the connection on its first event: a refusal the box sees at+ once, rather than a layer that waits for data that never makes sense."""++ _closed = False++ def _handle_event(self, event: events.Event) -> layer.CommandGenerator[None]:+ if self._closed:+ return+ self._closed = True+ yield commands.CloseConnection(self.context.client)+ if self.context.server.connected:+ yield commands.CloseConnection(self.context.server)+++class SwapProxyAddon:+ def __init__(+ self,+ owners: OwnerDirectory,+ source: CredentialSource,+ guard: EgressGuard,+ *,+ allow_insecure_swap: bool = False,+ ):+ self._directory = owners+ self._source = source+ self._guard = guard+ # Tests only: lets a swap happen over plain http to a local upstream.+ self._allow_insecure_swap = allow_insecure_swap+ self._owners: weakref.WeakKeyDictionary[connection.Client, Owner] = (+ weakref.WeakKeyDictionary()+ )+ # Connections whose TLS handshake is to be failed (``tls_start_client``).+ self._refused_tls: weakref.WeakSet[connection.Client] = weakref.WeakSet()++ # ------------------------------------------------------------ the door++ async def socks5_auth(self, data: modes.Socks5AuthData) -> None:+ owner = await self._directory.authenticate(data.username, data.password)+ if owner is None:+ self._audit(None, "-", "refused-connection", reason="unknown-credential")+ return+ data.valid = True+ self._owners[data.client_conn] = owner++ # ------------------------------------------------------------ the way out++ async def server_connect(self, data: server_hooks.ServerConnectionHookData) -> None:+ address = data.server.address+ if not address:+ return+ owner = self._owners.get(data.client)+ if owner is None:+ data.server.error = "swap-proxy: connection has no owner"+ return+ host = address[0]+ verdict = await self._guard.check(host)+ if verdict.ip is None:+ self._audit(+ owner,+ host,+ "refused-egress",+ reason=verdict.refused or "",+ ip=verdict.refused_ip or "-",+ )+ data.server.error = f"swap-proxy: egress refused ({verdict.refused})"+ return+ # The address that was checked is the address that is dialled. SNI is+ # unaffected: it comes from the client's hello, not from this.+ data.server.address = (verdict.ip, address[1])++ async def tls_clienthello(self, data: tls.ClientHelloData) -> None:+ sni = data.client_hello.sni+ owner = self._owners.get(data.context.client)+ swaps = owner is not None and owner.swap_user_id is not None+ if not sni:+ # Bindings are names, so with none nothing can be swapped in, and+ # nothing that comes back can be judged: a box that gets swaps+ # could reach a bound provider by address and read, unscrubbed,+ # a value it stored there through an earlier swap. Refused for+ # such a box; anyone else's is passed through.+ if swaps:+ self._audit(owner, "-", "refused-connection", reason="no-sni")+ self._refused_tls.add(data.context.client)+ else:+ data.ignore_connection = True+ return+ try:+ bound = bool(await self._source.bound_names(sni))+ except SourceUnavailable:+ # No bindings table at all yet (a cold start with the backend+ # down): whether this host is bound is unknown. For an owner who+ # gets swaps it is opened, so that the response hooks refuse what+ # they cannot scrub; passed through, a value stored there earlier+ # would reach the box unread. Anyone else's is left alone.+ bound = swaps+ if not bound:+ data.ignore_connection = True++ def next_layer(self, nextlayer: layer.NextLayer) -> None:+ """Inside a connection the proxy opened, only HTTP.++ mitmproxy relays anything that does not look like HTTP as raw TCP+ (``rawtcp``), and a raw relay has no hook that scrubs. Turning+ ``rawtcp`` off everywhere would also break plain-text protocols that+ were never opened (ssh, say), so this is narrower: for an owner who+ gets swaps, inside TLS the proxy terminated, the raw relay is replaced+ by one that closes the connection at once.+ (A ``101`` that is not a websocket is refused in ``response``.)+ """+ chosen = nextlayer.layer+ if not isinstance(chosen, layers.TCPLayer) or chosen.flow is None:+ return+ client = nextlayer.context.client+ owner = self._owners.get(client)+ if owner is None or owner.swap_user_id is None or not client.tls:+ return+ self._audit(owner, client.sni or "-", "refused-connection", reason="not-http")+ nextlayer.layer = ClosingLayer(nextlayer.context)++ def tls_start_client(self, data: tls.TlsData) -> None:+ """Runs after mitmproxy's own ``tlsconfig`` has built the connection,+ and swaps it for one with no certificate: the handshake fails with an+ alert and mitmproxy closes the connection, so a refused box sees a+ clean TLS error. (Leaving ``ssl_conn`` empty instead, which mitmproxy+ also treats as a failure, leaves the box waiting.)"""+ if data.context.client in self._refused_tls:+ context = SSL.Context(SSL.TLS_SERVER_METHOD)+ # Never completes a handshake, but no context of ours offers+ # anything below TLS 1.2.+ context.set_min_proto_version(SSL.TLS1_2_VERSION)+ context.set_options(+ SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3 | SSL.OP_NO_TLSv1 | SSL.OP_NO_TLSv1_1+ )+ refused = SSL.Connection(context)+ refused.set_accept_state()+ data.ssl_conn = refused++ # ------------------------------------------------------------ the swap++ async def requestheaders(self, flow: http.HTTPFlow) -> None:+ """Before anything is sent. A body known to fit is left to ``request``;+ for any other the head is swapped here, because it leaves first."""+ owner = self._owners.get(flow.client_conn)+ if owner is None:+ flow.kill()+ return+ request = flow.request+ if (+ owner.swap_user_id is not None+ and request.scheme == "http"+ and is_address(request.pretty_host)+ ):+ # Plain http names no host a binding could match either: the+ # same case as TLS without SNI, refused for the same box.+ self._audit(owner, request.pretty_host, "refused-request", reason="no-sni")+ flow.kill()+ return+ size = known_size(request, None)+ if size is not None and size <= MAX_BODY_BYTES:+ return+ host = request.pretty_host+ flow.metadata[_HEAD_SWAPPED] = True+ names = placeholder_names(request, body=False)+ if names:+ lookup = await self._lookup(flow, owner, host, names)+ swap = RequestSwap(lookup.credentials, host, request.method, request.path)+ swap.head(request)+ self._record_swap(flow, owner, host, lookup, names, swap)+ if not is_scrubbable(request.headers.get("content-type", "")):+ return # binary: streams through as it is+ # Every credential the body could name: it is not here to be read yet.+ # Only one that may be swapped into a body (``swap_anywhere``) is worth+ # holding the body back for; by default none is.+ lookup = await self._lookup(flow, owner, host, None)+ if not _any_anywhere(lookup):+ return+ if size is not None:+ self._audit(owner, host, "body-not-swapped", reason="body-too-large")+ return+ method, path = request.method, request.path++ def swap_body(body: bytes) -> bytes:+ whole = request.copy()+ whole.raw_content = body+ try:+ plain = plain_copy(whole)+ except (DecodedTooLarge, Undecodable) as e:+ too_large(_NOT_READABLE[type(e)])+ return body+ before = plain.raw_content+ swap = RequestSwap(lookup.credentials, host, method, path)+ swap.body(plain)+ named = placeholder_names(plain, head=False)+ self._record_swap(flow, owner, host, lookup, named, swap)+ if plain.raw_content == before:+ return body+ put_back(whole, plain)+ return whole.raw_content or b""++ def too_large(reason: str) -> bool:+ self._audit(owner, host, "body-not-swapped", reason=reason)+ return True # out as it is, placeholders literal++ request.stream = BufferedBody(MAX_BODY_BYTES, swap_body, too_large)++ async def request(self, flow: http.HTTPFlow) -> None:+ owner = self._owners.get(flow.client_conn)+ if owner is None:+ if flow.killable:+ flow.kill()+ return+ request = flow.request+ if request.stream:+ # Streamed: its bytes have left. ``requestheaders`` swapped what+ # could be swapped; a swap now would reach no wire, only the audit.+ return+ head = not flow.metadata.get(_HEAD_SWAPPED)+ host = request.pretty_host+ names = placeholder_names(request, head=head, body=False)+ plain: Optional[http.Message] = None+ try:+ plain = plain_copy(request)+ names |= placeholder_names(plain, head=False)+ except (DecodedTooLarge, Undecodable) as e:+ # Without decoding it nobody can say whether it names a credential.+ # It goes out as it is, which is the safe direction, and the audit+ # says so whenever this owner has anything that could have gone in.+ if _any_anywhere(await self._lookup(flow, owner, host, None)):+ self._audit(+ owner, host, "body-not-swapped", reason=_NOT_READABLE[type(e)]+ )+ if not names:+ return+ lookup = await self._lookup(flow, owner, host, names)+ swap = RequestSwap(lookup.credentials, host, request.method, request.path)+ if head:+ swap.head(request)+ if plain is not None:+ before = plain.raw_content+ swap.body(plain)+ if plain.raw_content != before:+ put_back(request, plain)+ self._record_swap(flow, owner, host, lookup, names, swap)++ async def websocket_message(self, flow: http.HTTPFlow) -> None:+ owner = self._owners.get(flow.client_conn)+ if owner is None or flow.websocket is None or not flow.websocket.messages:+ return+ message = flow.websocket.messages[-1]+ if message.is_text is False:+ return+ try:+ text = message.content.decode("utf-8")+ except UnicodeDecodeError:+ return+ host = flow.request.pretty_host+ if not message.from_client:+ # What the server says back is scrubbed like a response body.+ credentials = await self._scrub_credentials(flow, owner)+ if credentials is None:+ message.drop()+ self._audit(owner, host, "refused-message", reason=_UNAVAILABLE)+ return+ scrubbed = scrub_text(text, credentials, flow.metadata.get(_ENCODED, ()))+ if scrubbed != text:+ message.content = scrubbed.encode("utf-8")+ self._audit(owner, host, "scrubbed")+ return+ names = {m.group(1) for m in PLACEHOLDER_RE.finditer(text)}+ if not names:+ return+ lookup = await self._lookup(flow, owner, host, names)+ # No method and no path: a credential limited by either never swaps.+ swap = RequestSwap(lookup.credentials, host)+ new_text = swap.text(text)+ if new_text != text:+ message.content = new_text.encode("utf-8")+ self._record_swap(flow, owner, host, lookup, names, swap)++ async def responseheaders(self, flow: http.HTTPFlow) -> None:+ """Before the body arrives: a text response that may echo a value is+ never left for mitmproxy to stream past the scrub."""+ owner = self._owners.get(flow.client_conn)+ response = flow.response+ if owner is None or response is None or flow.error:+ return+ if not is_scrubbable(response.headers.get("content-type", "")):+ return+ size = known_size(flow.request, response)+ if size is not None and size <= MAX_BODY_BYTES:+ return # held whole by mitmproxy; ``response`` scrubs it+ credentials = await self._scrub_credentials(flow, owner)++ def refuse(reason: str) -> bool:+ self._refuse_response(flow, owner, reason)+ return False++ if credentials is None:+ refuse(_UNAVAILABLE)+ return+ if not credentials:+ return+ host = flow.request.pretty_host+ if size is not None:+ refuse("too-large-to-scrub")+ return++ def scrub_body(body: bytes) -> bytes:+ whole = response.copy()+ whole.raw_content = body+ try:+ if self._scrub(whole, credentials, flow.metadata.get(_ENCODED, ())):+ self._audit(owner, host, "scrubbed")+ except (DecodedTooLarge, Undecodable) as e:+ refuse(_NOT_READABLE[type(e)])+ return b""+ return whole.raw_content or b""++ response.stream = BufferedBody(+ MAX_BODY_BYTES,+ scrub_body,+ lambda reason: refuse(+ "too-large-to-scrub" if reason == "body-too-large" else reason+ ),+ )++ async def response(self, flow: http.HTTPFlow) -> None:+ owner = self._owners.get(flow.client_conn)+ response = flow.response+ if owner is None or response is None:+ return+ if (+ response.status_code == 101+ and flow.websocket is None+ and owner.swap_user_id is not None+ ):+ # An upgrade mitmproxy does not take for a websocket goes on as a+ # raw relay, which nothing scrubs. Refused before it switches.+ self._refuse_response(flow, owner, "unscrubbable-upgrade")+ return+ if response.stream:+ return # binary, or already handled by ``responseheaders``+ if not response.raw_content or not is_scrubbable(+ response.headers.get("content-type", "")+ ):+ return+ credentials = await self._scrub_credentials(flow, owner)+ if credentials is None:+ self._refuse_response(flow, owner, _UNAVAILABLE)+ return+ try:+ if self._scrub(response, credentials, flow.metadata.get(_ENCODED, ())):+ self._audit(owner, flow.request.pretty_host, "scrubbed")+ except (DecodedTooLarge, Undecodable) as e:+ # A body that cannot be read cannot be vouched for: the box could+ # decode what the proxy would not. Not passed on.+ self._refuse_response(flow, owner, _NOT_READABLE[type(e)])++ # ------------------------------------------------------------ helpers++ def _provably_bound(self, flow: http.HTTPFlow) -> bool:+ """Is this request really going to the host it names?"""+ if self._allow_insecure_swap:+ return True+ if flow.request.scheme != "https":+ return False+ sni = (flow.server_conn.sni or "").lower()+ if not sni or sni != flow.request.pretty_host.lower():+ return False+ # An HTTP/1 absolute-form target ("GET https://other.example/x") is+ # forwarded as it is, and RFC 9112 3.2.2 has the server honour it over+ # ``Host``: a front shared by many origins would route on it. So the+ # target's authority, when there is one, must name the same host.+ # (For HTTP/2 mitmproxy already rejects an :authority that disagrees.)+ authority = flow.request.authority+ if authority:+ try:+ host, _ = parse_authority(authority, check=True)+ except ValueError:+ return False+ return host.lower() == sni+ return True++ async def _scrub_credentials(+ self, flow: http.HTTPFlow, owner: Owner+ ) -> Optional[list[Credential]]:+ """Every value of the owner's that this host may have been sent, and+ every value swapped into this very flow (a credential rotated since+ is still scrubbed).++ ``None`` when the backend cannot say, for an owner who gets swaps. An+ empty answer would pass the body on as if it had been scrubbed, and a+ value can come back in a response that did not ask for it: one the+ box had swapped into something the provider stores (a gist, an issue,+ a file) comes back from a later, placeholder-free read. So the+ caller refuses what it cannot scrub.+ """+ # The host the request names and the one the connection named, since+ # the two need not agree (and over plain http nothing proves either).+ hosts = {flow.request.pretty_host.lower()}+ if flow.server_conn.sni:+ hosts.add(flow.server_conn.sni.lower())+ credentials: list[Credential] = []+ for host in sorted(hosts):+ lookup = await self._lookup(flow, owner, host, None, proof=False)+ if owner.swap_user_id is not None and lookup.unavailable:+ return None+ credentials += lookup.credentials.values()+ swapped: dict[str, Credential] = flow.metadata.get(_SWAPPED, {})+ return [*credentials, *swapped.values()]++ def _refuse_response(self, flow: http.HTTPFlow, owner: Owner, reason: str) -> None:+ self._audit(owner, flow.request.pretty_host, "refused-response", reason=reason)+ if flow.killable:+ flow.kill()++ def _record_swap(+ self,+ flow: http.HTTPFlow,+ owner: Owner,+ host: str,+ lookup: _Lookup,+ names: set[str],+ swap: RequestSwap,+ ) -> None:+ """Audit a swap and remember which credentials went into the flow, and+ the Basic pairs they went into, for the scrub of its response."""+ self._audit_events(owner, host, lookup.refusals(names) + swap.events)+ flow.metadata.setdefault(_ENCODED, []).extend(swap.encoded)+ swapped = flow.metadata.setdefault(_SWAPPED, {})+ for event in swap.events:+ name = event.placeholder.split(":")[1]+ if event.kind == "swapped" and name in lookup.credentials:+ swapped[name] = lookup.credentials[name]++ @staticmethod+ def _scrub(+ message: Union[http.Response, http.Request],+ credentials: list[Credential],+ encoded: Iterable[tuple[str, str]] = (),+ ) -> bool:+ """Scrub a whole text body in place; ``True`` if a value was in it.+ Raises ``DecodedTooLarge`` or ``Undecodable`` for a body it cannot read."""+ if not credentials or not message.raw_content:+ return False+ plain = plain_copy(message)+ changed = False+ try:+ text = plain.get_text(strict=True)+ except ValueError:+ # Not in the charset it declares, or an unknown one: the box may+ # read it anyway, so it is scrubbed as bytes below, never let by.+ text = None+ if text:+ scrubbed = scrub_text(text, credentials, encoded)+ if scrubbed != text:+ plain.text = scrubbed+ changed = True+ # Also as bytes, always: the charset the proxy decoded with need not be+ # the one the box reads with.+ raw = plain.raw_content or b""+ cleaned = scrub_bytes(raw, credentials, encoded)+ if cleaned != raw:+ plain.content = cleaned+ changed = True+ if changed:+ put_back(message, plain)+ return changed++ async def _lookup(+ self,+ flow: http.HTTPFlow,+ owner: Owner,+ host: str,+ names: Optional[set[str]],+ *,+ proof: bool = True,+ ) -> _Lookup:+ """The owner's credentials among *names* that may go to *host*, and the+ reason for every name left out. ``None`` asks for all bound to it.++ *proof* is for a swap: only where the connection proves the host. A+ scrub asks without it, since removing a value never sends one."""+ if proof and not self._provably_bound(flow):+ return _Lookup(blanket="unverified-destination")+ try:+ bound = await self._source.bound_names(host)+ except SourceUnavailable:+ return _Lookup(blanket=_UNAVAILABLE)+ # A placeholder on its way to a host it is not bound to is the one+ # signal that one went somewhere it should not: ``unbound-host``.+ wanted = bound if names is None else names & bound+ user_id = owner.swap_user_id+ if user_id is None:+ return _Lookup(refused=dict.fromkeys(wanted, "owner-does-not-swap"))+ lookup = _Lookup()+ for name in sorted(wanted):+ try:+ credential = await self._source.resolve(user_id, name, host)+ except SourceUnavailable:+ lookup.refused[name] = _UNAVAILABLE+ continue+ if credential is None:+ lookup.refused[name] = "not-connected"+ else:+ lookup.credentials[name] = credential+ return lookup++ def _audit_events(self, owner: Owner, host: str, events: list[SwapEvent]) -> None:+ for event in events:+ self._audit(+ owner,+ host,+ event.kind,+ placeholder=event.placeholder,+ reason=event.reason,+ )++ def _audit(+ self, owner: Optional[Owner], host: str, event: str, **fields: str+ ) -> None:+ """One line per fact. Names and reasons; never a value."""+ record = {+ "ts": datetime.now(timezone.utc).isoformat(timespec="seconds"),+ "event": event,+ "owner": owner.label if owner else None,+ "user_id": owner.user_id if owner else None,+ "sandbox_id": owner.sandbox_id if owner else None,+ "host": host,+ **{k: v for k, v in fields.items() if v},+ }+ audit_logger.info(json.dumps(record, sort_keys=True))diff --git a/autogpt_platform/swap_proxy/swap_proxy/addon_test.py b/autogpt_platform/swap_proxy/swap_proxy/addon_test.pynew file mode 100644index 0000000000..5036abca55--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/addon_test.py@@ -0,0 +1,891 @@+"""The addon's hooks against mitmproxy's own test flows: what the e2e suites+cannot reach over a hand-written HTTP/1 client (websockets, HTTP/2 framing)+and the body buffer on its own."""++import gzip+import json+import logging+from types import SimpleNamespace+from typing import Any++import pytest+from mitmproxy import http+from mitmproxy.options import Options+from mitmproxy.proxy import layers+from mitmproxy.proxy.context import Context+from mitmproxy.proxy.layers.http import HTTPMode+from mitmproxy.test import tflow+from OpenSSL import SSL+from wsproto.frame_protocol import Opcode++from swap_proxy.addon import (+ MAX_BODY_BYTES,+ MAX_DECODED_BYTES,+ BufferedBody,+ ClosingLayer,+ SwapProxyAddon,+ known_size,+)+from swap_proxy.egress import EgressGuard+from swap_proxy.owners import Owner, OwnerDirectory+from swap_proxy.source import SourceUnavailable+from swap_proxy.swap import Credential++TOKEN = "ghp_userAsecretvalue0001"+HOST = "api.github.com"+++class Source:+ """*down* makes every value lookup fail, *bindings_down* the table too."""++ def __init__(self):+ self.token: str | None = TOKEN+ self.down = self.bindings_down = False+ self.anywhere = False # the credential's ``swap_anywhere``++ async def bound_names(self, host):+ if self.bindings_down:+ raise SourceUnavailable("bindings")+ return {"github"} if host == HOST else set()++ async def resolve(self, user_id, name, host):+ if self.down:+ raise SourceUnavailable("resolve")+ if self.token is None:+ return None+ return Credential(+ "github",+ {"access_token": self.token},+ (HOST,),+ swap_anywhere=self.anywhere,+ )+++class NoRedis:+ async def get(self, name):+ return None+++def addon_for(+ flow: http.HTTPFlow,+ swaps: bool = True,+ source: Source | None = None,+ anywhere: bool = False,+) -> SwapProxyAddon:+ source = source or Source()+ source.anywhere = anywhere+ addon = SwapProxyAddon(OwnerDirectory(NoRedis()), source, EgressGuard())+ addon._owners[flow.client_conn] = Owner("session:s-a", "user-a", "sb-1", swaps)+ flow.request.host, flow.request.scheme = HOST, "https"+ flow.request.headers["host"] = HOST+ flow.server_conn.sni = HOST+ return addon+++def audit(caplog) -> list[tuple]:+ return [+ (line["event"], line.get("placeholder") or line.get("reason"))+ for line in (+ json.loads(r.message)+ for r in caplog.records+ if r.name == "swap_proxy.audit"+ )+ ]+++# ------------------------------------------------------------ websockets+++def websocket_flow(text: str, from_client: bool) -> http.HTTPFlow:+ flow = tflow.twebsocketflow()+ assert flow.websocket is not None+ message = flow.websocket.messages[-1]+ message.from_client, message.content = from_client, text.encode()+ return flow+++def last_message(flow: http.HTTPFlow) -> str:+ assert flow.websocket is not None+ return flow.websocket.messages[-1].content.decode()+++async def test_a_placeholder_in_a_frame_from_the_box_is_swapped(caplog):+ flow = websocket_flow('{"auth": "hsurr:github"}', from_client=True)+ addon = addon_for(flow, anywhere=True)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.websocket_message(flow)+ assert last_message(flow) == '{"auth": "%s"}' % TOKEN+ assert audit(caplog) == [("swapped", "hsurr:github")]+++async def test_a_token_echoed_in_a_frame_from_the_server_is_scrubbed(caplog):+ flow = websocket_flow('{"ack": "%s"}' % TOKEN, from_client=False)+ addon = addon_for(flow)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.websocket_message(flow)+ assert last_message(flow) == '{"ack": "hsurr:github"}'+ assert audit(caplog) == [("scrubbed", None)]+ assert TOKEN not in caplog.text+++async def test_a_placeholder_in_a_frame_from_the_server_is_not_swapped():+ """The swap is for what the box sends out, never for what comes back."""+ flow = websocket_flow("hsurr:github", from_client=False)+ await addon_for(flow).websocket_message(flow)+ assert last_message(flow) == "hsurr:github"++[email protected]("from_client", [True, False])+async def test_frames_of_a_box_that_does_not_swap_are_left_alone(from_client):+ text = "hsurr:github" if from_client else TOKEN+ flow = websocket_flow(text, from_client)+ await addon_for(flow, swaps=False).websocket_message(flow)+ assert last_message(flow) == text+++async def test_a_binary_frame_is_left_alone():+ flow = websocket_flow(TOKEN, from_client=False)+ assert flow.websocket is not None+ flow.websocket.messages[-1].type = Opcode.BINARY+ await addon_for(flow).websocket_message(flow)+ assert last_message(flow) == TOKEN+++# ------------------------------------------------------------ the body buffer+++def buffered(limit=10, release=True):+ reasons: list[str] = []++ def overflow(reason):+ reasons.append(reason)+ return release++ return BufferedBody(limit, lambda body: body.upper(), overflow), reasons+++def test_a_body_is_held_until_its_end_and_released_transformed():+ body, reasons = buffered()+ # Lists, never b"": an empty chunk on the wire ends a chunked body.+ assert [body(b"abc"), body(b"def"), body(b"")] == [[], [], [b"ABCDEF"]]+ assert reasons == []+++def test_an_empty_body_sends_nothing():+ body, _ = buffered()+ assert body(b"") == []+++def test_past_the_limit_a_request_body_is_released_as_it_was():+ body, reasons = buffered(limit=4, release=True)+ assert body(b"abc") == []+ assert body(b"def") == [b"abc", b"def"]+ assert body(b"ghi") == [b"ghi"] and body(b"") == []+ assert reasons == ["body-too-large"]+++def test_past_the_limit_a_response_body_is_withheld_for_good():+ body, reasons = buffered(limit=4, release=False)+ assert [body(b"abc"), body(b"def"), body(b"ghi"), body(b"")] == [[], [], [], []]+ assert reasons == ["body-too-large"]+++def test_data_after_the_end_marker_is_not_transformed_in_two_halves():+ """An empty DATA frame mid-body looks like the end. A value split around+ it would survive two separate scrubs, so the rest is refused."""+ body, reasons = buffered(limit=100, release=False)+ assert body(b"ghp_userAsecr") == [] and body(b"") == [b"GHP_USERASECR"]+ assert body(b"etvalue0001") == []+ assert reasons == ["data-after-end"]+++# ------------------------------------------------------------ what is known early+++def test_the_size_of_a_body_is_known_only_when_its_framing_says_so():+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ flow.request.headers["content-length"] = "12"+ assert known_size(flow.request, None) == 12+ flow.response.headers["content-length"] = "7"+ assert known_size(flow.request, flow.response) == 7+ del flow.response.headers["content-length"]+ flow.response.headers["transfer-encoding"] = "chunked"+ assert known_size(flow.request, flow.response) is None+ del flow.response.headers["transfer-encoding"]+ assert known_size(flow.request, flow.response) is None # read until close+ flow.request.headers["content-length"] = "nonsense"+ assert known_size(flow.request, None) is None+++def test_http2_without_a_length_is_unknown_not_empty():+ flow = tflow.tflow()+ flow.request.http_version = "HTTP/2.0"+ flow.request.headers.pop("content-length", None)+ assert known_size(flow.request, None) is None+++# ------------------------------------------------------------ the header hooks+++async def test_an_http2_upload_without_a_length_is_swapped_head_first_then_body(+ caplog,+):+ flow = tflow.tflow()+ addon = addon_for(flow, anywhere=True)+ flow.request.http_version = "HTTP/2.0"+ flow.request.headers.pop("content-length", None)+ flow.request.headers["authorization"] = "Bearer hsurr:github"+ flow.request.headers["content-type"] = "application/json"+ flow.request.raw_content = None+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.requestheaders(flow)+ # The head is final before the body exists.+ assert flow.request.headers["authorization"] == f"Bearer {TOKEN}"+ stream = flow.request.stream+ assert isinstance(stream, BufferedBody)+ sent = [*stream(b'{"t": "hsurr:gi'), *stream(b'thub"}'), *stream(b"")]+ await addon.request(flow) # fires after the bytes left: must add nothing+ assert b"".join(sent) == b'{"t": "%s"}' % TOKEN.encode()+ assert audit(caplog) == [("swapped", "hsurr:github")] * 2+++async def test_a_gzipped_response_without_a_length_is_scrubbed_inside_its_encoding(+ caplog,+):+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow)+ flow.response.headers["content-type"] = "application/json"+ flow.response.headers["content-encoding"] = "gzip"+ flow.response.text = '{"echo": "%s"}' % TOKEN+ wire = flow.response.raw_content or b""+ del flow.response.headers["content-length"]+ flow.response.headers["transfer-encoding"] = "chunked"+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ stream = flow.response.stream+ assert isinstance(stream, BufferedBody)+ sent = [*stream(wire[:9]), *stream(wire[9:]), *stream(b"")]+ seen = flow.response.copy()+ seen.raw_content = b"".join(sent)+ assert seen.text == '{"echo": "hsurr:github"}'+ assert audit(caplog) == [("scrubbed", None)]+++async def test_a_response_that_outgrows_the_buffer_kills_the_flow(caplog):+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow)+ flow.live = True+ flow.response.headers["content-type"] = "text/plain"+ del flow.response.headers["content-length"]+ flow.response.headers["transfer-encoding"] = "chunked"+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ stream = flow.response.stream+ assert isinstance(stream, BufferedBody)+ assert stream(b"x" * MAX_BODY_BYTES) == []+ assert stream(TOKEN.encode()) == [] and stream(b"") == []+ assert flow.error is not None and not flow.killable+ assert audit(caplog) == [("refused-response", "too-large-to-scrub")]+++async def test_a_response_with_data_after_its_end_is_audited_as_such(caplog):+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow)+ flow.live = True+ flow.response.headers["content-type"] = "text/plain"+ del flow.response.headers["content-length"]+ flow.response.headers["transfer-encoding"] = "chunked"+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ stream = flow.response.stream+ assert isinstance(stream, BufferedBody)+ for chunk in (b"abc", b"", b"def"):+ stream(chunk)+ assert flow.error is not None+ assert audit(caplog) == [("refused-response", "data-after-end")]++[email protected]("content_type", ["image/png", "application/zip"])+async def test_a_binary_response_is_left_to_stream(content_type):+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow)+ flow.response.headers["content-type"] = content_type+ flow.response.headers["content-length"] = str(MAX_BODY_BYTES * 4)+ await addon.responseheaders(flow)+ assert flow.response.stream is False and flow.error is None+++async def test_a_box_that_does_not_swap_has_no_response_refused():+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow, swaps=False)+ flow.response.headers["content-type"] = "text/plain"+ flow.response.headers["content-length"] = str(MAX_BODY_BYTES * 4)+ await addon.responseheaders(flow)+ assert flow.response.stream is False and flow.error is None+++# ------------------------------------------------------------ what a body decodes to+#+# MAX_BODY_BYTES counts bytes on the wire. A few kilobytes of gzip can stand+# for far more, decoded on the event loop every box shares.++BOMB = gzip.compress(+ b'{"echo": "%s", "pad": "' % TOKEN.encode() + bytes(2 * MAX_DECODED_BYTES)+)+++def no_unbounded_decode(monkeypatch):+ """mitmproxy's own decode has no bound: a bomb must never reach it."""++ def decode(*args, **kwargs):+ raise AssertionError("decoded without a bound")++ monkeypatch.setattr("mitmproxy.http.encoding.decode", decode)+++def test_the_bomb_is_small_on_the_wire():+ assert len(BOMB) < MAX_BODY_BYTES // 50+++def bombed_response(chunked: bool) -> http.HTTPFlow:+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ flow.live = True+ flow.response.headers["content-type"] = "application/json"+ flow.response.headers["content-encoding"] = "gzip"+ if chunked:+ del flow.response.headers["content-length"]+ flow.response.headers["transfer-encoding"] = "chunked"+ else:+ flow.response.raw_content = BOMB+ flow.response.headers["content-length"] = str(len(BOMB))+ return flow+++async def test_a_response_with_a_length_that_decodes_past_the_cap_is_refused(+ caplog, no_unbounded_decode+):+ flow = bombed_response(chunked=False)+ assert flow.response is not None+ addon = addon_for(flow)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ assert flow.response.stream is False # small on the wire: held whole+ await addon.response(flow)+ assert flow.error is not None and not flow.killable+ assert audit(caplog) == [("refused-response", "decoded-too-large")]+++async def test_a_held_response_that_decodes_past_the_cap_is_refused(+ caplog, no_unbounded_decode+):+ flow = bombed_response(chunked=True)+ assert flow.response is not None+ addon = addon_for(flow)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ stream = flow.response.stream+ assert isinstance(stream, BufferedBody)+ assert [*stream(BOMB[:100]), *stream(BOMB[100:]), *stream(b"")] == []+ assert flow.error is not None and not flow.killable+ assert audit(caplog) == [("refused-response", "decoded-too-large")]++[email protected]("encoding", ["compress", "gzip, br"])+async def test_a_response_in_an_encoding_that_cannot_be_bounded_is_refused(+ caplog, encoding+):+ flow = bombed_response(chunked=False)+ assert flow.response is not None+ flow.response.headers["content-encoding"] = encoding+ addon = addon_for(flow)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.response(flow)+ assert flow.error is not None+ assert audit(caplog) == [("refused-response", "undecodable-encoding")]+++async def test_a_box_with_nothing_to_scrub_gets_its_bomb_untouched(+ caplog, no_unbounded_decode+):+ """No value of this owner's can be in it, so it is not the proxy's to read."""+ flow = bombed_response(chunked=False)+ assert flow.response is not None+ addon = addon_for(flow, swaps=False)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.response(flow)+ assert flow.error is None and flow.response.raw_content == BOMB+ assert audit(caplog) == []+++def bombed_request(chunked: bool) -> http.HTTPFlow:+ flow = tflow.tflow()+ flow.request.method = "POST"+ flow.request.headers["authorization"] = "Bearer hsurr:github"+ flow.request.headers["content-type"] = "application/json"+ flow.request.headers["content-encoding"] = "gzip"+ if chunked:+ flow.request.headers.pop("content-length", None)+ flow.request.headers["transfer-encoding"] = "chunked"+ flow.request.raw_content = None+ else:+ flow.request.raw_content = BOMB+ flow.request.headers["content-length"] = str(len(BOMB))+ return flow+++async def test_a_request_body_that_decodes_past_the_cap_goes_out_as_it_is(+ caplog, no_unbounded_decode+):+ flow = bombed_request(chunked=False)+ addon = addon_for(flow, anywhere=True)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.requestheaders(flow)+ await addon.request(flow)+ assert flow.error is None and flow.request.raw_content == BOMB+ # The head is still swapped; no swap is claimed for the body.+ assert flow.request.headers["authorization"] == f"Bearer {TOKEN}"+ assert audit(caplog) == [+ ("body-not-swapped", "decoded-too-large"),+ ("swapped", "hsurr:github"),+ ]+++async def test_a_held_request_body_that_decodes_past_the_cap_goes_out_as_it_is(+ caplog, no_unbounded_decode+):+ flow = bombed_request(chunked=True)+ addon = addon_for(flow, anywhere=True)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.requestheaders(flow)+ stream = flow.request.stream+ assert isinstance(stream, BufferedBody)+ sent = [*stream(BOMB[:100]), *stream(BOMB[100:]), *stream(b"")]+ assert b"".join(sent) == BOMB+ assert audit(caplog) == [+ ("swapped", "hsurr:github"),+ ("body-not-swapped", "decoded-too-large"),+ ]+++async def test_a_gzipped_request_body_within_the_cap_is_swapped_inside_its_encoding(+ caplog, no_unbounded_decode+):+ flow = tflow.tflow()+ addon = addon_for(flow, anywhere=True)+ flow.request.method = "POST"+ flow.request.headers["content-type"] = "application/json"+ flow.request.headers["content-encoding"] = "gzip"+ flow.request.raw_content = gzip.compress(b'{"token": "hsurr:github"}')+ flow.request.headers["content-length"] = str(len(flow.request.raw_content))+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.requestheaders(flow)+ await addon.request(flow)+ sent = gzip.decompress(flow.request.raw_content or b"")+ assert json.loads(sent) == {"token": TOKEN}+ assert flow.request.headers["content-length"] == str(len(flow.request.raw_content))+ assert audit(caplog) == [("swapped", "hsurr:github")]+++async def test_a_token_in_the_second_gzip_member_of_a_response_is_scrubbed(caplog):+ """A client decodes every member; the scrub must see every member too."""+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow)+ flow.response.headers["content-type"] = "application/json"+ flow.response.headers["content-encoding"] = "gzip"+ flow.response.raw_content = gzip.compress(b'{"a": "') + gzip.compress(+ b'%s"}' % TOKEN.encode()+ )+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.response(flow)+ assert gzip.decompress(flow.response.raw_content or b"") == b'{"a": "hsurr:github"}'+ assert audit(caplog) == [("scrubbed", None)]+++async def test_a_response_with_data_after_its_gzip_stream_is_refused(caplog):+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ addon = addon_for(flow)+ flow.live = True+ flow.response.headers["content-type"] = "application/json"+ flow.response.headers["content-encoding"] = "gzip"+ flow.response.raw_content = gzip.compress(b"{}") + TOKEN.encode()+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.response(flow)+ assert flow.error is not None+ assert audit(caplog) == [("refused-response", "undecodable-encoding")]+++# ------------------------------------------------------------ the backend is down+#+# An empty answer is not the same as "cannot say". Scrubbing with nothing+# would pass an echoed value on as if it had been scrubbed.+++def text_response(body: bytes, *, chunked: bool = False) -> http.HTTPFlow:+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ flow.live = True+ flow.response.headers["content-type"] = "application/json"+ flow.response.raw_content = body+ if chunked:+ del flow.response.headers["content-length"]+ flow.response.headers["transfer-encoding"] = "chunked"+ else:+ flow.response.headers["content-length"] = str(len(body))+ return flow++[email protected]("which", ["down", "bindings_down"])+async def test_a_response_the_backend_cannot_vouch_for_is_refused(caplog, which):+ source = Source()+ setattr(source, which, True)+ flow = text_response(b'{"echo": "%s"}' % TOKEN.encode())+ addon = addon_for(flow, source=source)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ await addon.response(flow)+ assert flow.error is not None and not flow.killable+ assert audit(caplog) == [("refused-response", "resolver-unavailable")]+++async def test_a_response_without_a_length_is_refused_before_its_body(caplog):+ source = Source()+ source.down = True+ flow = text_response(b"", chunked=True)+ addon = addon_for(flow, source=source)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.responseheaders(flow)+ assert flow.error is not None+ assert audit(caplog) == [("refused-response", "resolver-unavailable")]+++async def test_a_value_the_box_stored_earlier_is_not_read_back_during_an_outage():+ """The read carries no placeholder, so nothing was swapped into it; the+ value came from an earlier write. Only the lookup could have caught it."""+ source = Source()+ source.down = True+ flow = text_response(b'{"gist": "%s"}' % TOKEN.encode())+ flow.request.headers.pop("authorization", None)+ await addon_for(flow, source=source).response(flow)+ assert flow.error is not None+++ "body, swaps", [(b"", True), (b'{"echo": "%s"}' % TOKEN.encode(), False)]+)+async def test_an_outage_refuses_nothing_there_is_nothing_to_scrub_in(body, swaps):+ """An empty body, or a box that never gets swaps: no value of the user's+ can have reached either, so an outage is no reason to cut it off."""+ source = Source()+ source.down = source.bindings_down = True+ flow = text_response(body)+ addon = addon_for(flow, swaps=swaps, source=source)+ await addon.responseheaders(flow)+ await addon.response(flow)+ assert flow.error is None+ assert flow.response is not None and flow.response.raw_content == body+++async def test_a_frame_from_the_server_the_backend_cannot_vouch_for_is_dropped(+ caplog,+):+ source = Source()+ source.down = True+ flow = websocket_flow('{"ack": "%s"}' % TOKEN, from_client=False)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon_for(flow, source=source).websocket_message(flow)+ assert flow.websocket is not None and flow.websocket.messages[-1].dropped+ assert audit(caplog) == [("refused-message", "resolver-unavailable")]+++async def test_during_an_outage_a_request_still_goes_out_unswapped(caplog):+ source = Source()+ source.down = True+ flow = tflow.tflow()+ flow.request.headers["authorization"] = "Bearer hsurr:github"+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon_for(flow, source=source).request(flow)+ assert flow.error is None+ assert flow.request.headers["authorization"] == "Bearer hsurr:github"+ assert audit(caplog) == [("refused", "hsurr:github")]+++async def test_a_value_swapped_into_the_request_is_scrubbed_after_it_is_rotated(+ caplog,+):+ """Rotated or disconnected between the request and its response: the+ lookup no longer knows the old value, the flow still does."""+ source = Source()+ flow = text_response(b'{"echo": "%s"}' % TOKEN.encode())+ flow.request.headers["authorization"] = "Bearer hsurr:github"+ addon = addon_for(flow, source=source)+ await addon.request(flow)+ assert flow.request.headers["authorization"] == f"Bearer {TOKEN}"+ source.token = None # disconnected+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.response(flow)+ assert flow.response is not None+ assert flow.response.raw_content == b'{"echo": "hsurr:github"}'+ assert audit(caplog) == [("scrubbed", None)]+++# ------------------------------------------------------------ what gets opened+++ "sni, bindings_down, swaps, outcome",+ [+ (HOST, False, True, "opened"),+ # Bound: opened, so a stray placeholder is audited.+ (HOST, False, False, "opened"),+ ("example.com", False, True, "passed"),+ # No table yet: unknown whether bound. Opened only where a response+ # could hold a value of the owner's, so that it is refused.+ ("example.com", True, True, "opened"),+ ("example.com", True, False, "passed"),+ # No name: nothing that comes back could be judged. Refused for a+ # box that gets swaps, passed through for any other.+ (None, False, True, "refused"),+ (None, True, True, "refused"),+ (None, False, False, "passed"),+ ],+)+async def test_which_connections_are_opened(caplog, sni, bindings_down, swaps, outcome):+ flow = tflow.tflow()+ source = Source()+ source.bindings_down = bindings_down+ addon = addon_for(flow, swaps=swaps, source=source)+ context = SimpleNamespace(client=flow.client_conn)+ hello: Any = SimpleNamespace(+ client_hello=SimpleNamespace(sni=sni), context=context, ignore_connection=False+ )+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.tls_clienthello(hello)+ start: Any = SimpleNamespace(context=context, ssl_conn=object())+ addon.tls_start_client(start)+ seen = (+ "passed"+ if hello.ignore_connection+ else "refused" if isinstance(start.ssl_conn, SSL.Connection) else "opened"+ )+ assert seen == outcome+ refusals = [("refused-connection", "no-sni")] if outcome == "refused" else []+ assert audit(caplog) == refusals+++ "host, swaps, killed",+ [+ ("140.82.112.5", True, True),+ ("[2606:50c0:8000::154]", True, True),+ ("140.82.112.5", False, False),+ ("api.github.com", True, False),+ ],+)+async def test_plain_http_by_address_is_refused_for_a_box_that_swaps(+ caplog, host, swaps, killed+):+ flow = tflow.tflow()+ addon = addon_for(flow, swaps=swaps)+ flow.request.scheme = "http"+ flow.request.host = host.strip("[]")+ flow.request.headers["host"] = host+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.requestheaders(flow)+ assert (flow.error is not None) is killed+ assert audit(caplog) == ([("refused-request", "no-sni")] if killed else [])+++# ------------------------------------------------------------ Authorization only+#+# The default. Nothing sets ``swap_anywhere`` yet, so this is what runs.+++async def test_a_frame_from_the_box_is_not_swapped_by_default(caplog):+ flow = websocket_flow('{"auth": "hsurr:github"}', from_client=True)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon_for(flow).websocket_message(flow)+ assert last_message(flow) == '{"auth": "hsurr:github"}'+ assert audit(caplog) == [("refused", "hsurr:github")]+++async def test_a_request_body_is_not_swapped_by_default_and_the_header_is(caplog):+ flow = tflow.tflow()+ flow.request.method = "POST"+ flow.request.headers["authorization"] = "Bearer hsurr:github"+ flow.request.headers["content-type"] = "application/json"+ flow.request.content = b'{"content": "hsurr:github"}'+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon_for(flow).request(flow)+ assert flow.request.headers["authorization"] == f"Bearer {TOKEN}"+ assert flow.request.content == b'{"content": "hsurr:github"}'+ lines = [+ json.loads(r.message) for r in caplog.records if r.name == "swap_proxy.audit"+ ]+ assert [(x["event"], x.get("reason")) for x in lines] == [+ ("swapped", None),+ ("refused", "outside-authorization"),+ ]+++async def test_a_request_body_is_not_held_back_by_default():+ """Nothing can be swapped into it, so it streams as it arrives."""+ flow = tflow.tflow()+ flow.request.method = "POST"+ flow.request.http_version = "HTTP/2.0"+ flow.request.headers.pop("content-length", None)+ flow.request.headers["content-type"] = "application/json"+ flow.request.raw_content = None+ await addon_for(flow).requestheaders(flow)+ assert not isinstance(flow.request.stream, BufferedBody)+ await addon_for(flow, anywhere=True).requestheaders(flow)+ assert isinstance(flow.request.stream, BufferedBody)+++# ------------------------------------------------------------ bodies that do not decode+++ "content_type, body",+ [+ # One stray byte in a body that says it is UTF-8.+ ("application/json; charset=utf-8", b'{"echo": "%s", "x": "\xff"}'),+ ("text/plain; charset=bogus", b"echo %s"),+ # Declared UTF-16, but the box can read the bytes as ASCII.+ ("text/plain; charset=utf-16", b"echo %s!"),+ ],+ ids=["stray byte", "unknown charset", "declared utf-16"],+)+async def test_a_body_that_does_not_decode_as_declared_is_still_scrubbed(+ caplog, content_type, body+):+ flow = text_response(body % TOKEN.encode())+ assert flow.response is not None+ flow.response.headers["content-type"] = content_type+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon_for(flow).response(flow)+ assert flow.error is None+ raw = flow.response.raw_content or b""+ assert TOKEN.encode() not in raw and b"hsurr:github" in raw+ assert flow.response.headers["content-length"] == str(len(raw))+ assert audit(caplog) == [("scrubbed", None)]+++async def test_a_utf16_value_in_a_body_that_does_not_decode_is_scrubbed():+ body = "echo ".encode("utf-16-le") + TOKEN.encode("utf-16-le") + b"\x00"+ flow = text_response(body)+ assert flow.response is not None+ flow.response.headers["content-type"] = "text/plain; charset=utf-16-le"+ await addon_for(flow).response(flow)+ raw = flow.response.raw_content or b""+ assert TOKEN.encode("utf-16-le") not in raw+ assert "hsurr:github".encode("utf-16-le") in raw+++# ------------------------------------------------------------ the target names the host too+++ "authority, swapped",+ [+ ("", True), # origin-form: Host alone names the host+ (HOST, True),+ (f"{HOST}:443", True),+ ("API.GitHub.com", True),+ ("evil.example", False), # absolute-form to another origin+ ("evil.example:443", False),+ ("[::1]:443", False),+ ("not a host", False),+ ],+)+async def test_an_absolute_form_target_must_name_the_verified_host(+ caplog, authority, swapped+):+ """``GET https://evil.example/x`` with ``Host: api.github.com`` is+ forwarded as it is, and a front shared by many origins routes on the+ target: it must not carry the value there."""+ flow = tflow.tflow()+ flow.request.headers["authorization"] = "Bearer hsurr:github"+ addon = addon_for(flow)+ flow.request.authority = authority+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon.request(flow)+ sent = flow.request.headers["authorization"]+ assert (sent == f"Bearer {TOKEN}") is swapped+ if not swapped:+ lines = [+ json.loads(r.message)+ for r in caplog.records+ if r.name == "swap_proxy.audit"+ ]+ assert [x.get("reason") for x in lines] == ["unverified-destination"]+++# ------------------------------------------------------------ raw relays+++def next_layer_for(flow: http.HTTPFlow, chosen: str, intercepted: bool) -> Any:+ context = Context(flow.client_conn, Options())+ flow.client_conn.tls = intercepted+ layer: Any = {+ "tcp": layers.TCPLayer(context),+ "ignored": layers.TCPLayer(context, ignore=True),+ "http": layers.HttpLayer(context, HTTPMode.transparent),+ }[chosen]+ return SimpleNamespace(layer=layer, context=context)+++ "chosen, intercepted, swaps, closed",+ [+ # Not HTTP inside TLS the proxy terminated: no raw relay for a box that+ # gets swaps, since nothing on a raw relay is scrubbed.+ ("tcp", True, True, True),+ ("tcp", True, False, False),+ # Never opened (ssh in the clear, say): left as it is.+ ("tcp", False, True, False),+ ("ignored", True, True, False),+ ("http", True, True, False),+ ],+)+async def test_a_raw_relay_inside_an_opened_connection_is_not_allowed(+ caplog, chosen, intercepted, swaps, closed+):+ flow = tflow.tflow()+ addon = addon_for(flow, swaps=swaps)+ nextlayer = next_layer_for(flow, chosen, intercepted)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ addon.next_layer(nextlayer)+ assert isinstance(nextlayer.layer, ClosingLayer) is closed+ assert audit(caplog) == ([("refused-connection", "not-http")] if closed else [])++[email protected]("swaps, refused", [(True, True), (False, False)])+async def test_an_upgrade_that_is_not_a_websocket_is_refused(caplog, swaps, refused):+ flow = tflow.tflow(resp=True)+ assert flow.response is not None+ flow.live = True+ flow.response.status_code = 101+ flow.response.headers["upgrade"] = "something-else"+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await addon_for(flow, swaps=swaps).response(flow)+ assert (flow.error is not None) is refused+ expected = [("refused-response", "unscrubbable-upgrade")] if refused else []+ assert audit(caplog) == expected+++async def test_a_websocket_upgrade_is_not_refused():+ flow = websocket_flow("hello", from_client=False)+ assert flow.response is not None+ flow.live = True+ await addon_for(flow).response(flow)+ assert flow.error is Nonediff --git a/autogpt_platform/swap_proxy/swap_proxy/decode.py b/autogpt_platform/swap_proxy/swap_proxy/decode.pynew file mode 100644index 0000000000..6c15543270--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/decode.py@@ -0,0 +1,199 @@+"""Undo a ``Content-Encoding`` without ever holding more than a set amount.++mitmproxy decodes a compressed body in one call with no bound on the result,+and a few kilobytes of gzip can stand for gigabytes. The proxy decodes bodies+on the event loop every box shares, so here the bound is part of the decode:+each decoder is asked for at most ``limit + 1`` bytes and the body is refused+the moment it has more to give. The whole decoded body is never produced+first and measured after.++The encodings are the ones mitmproxy knows (``mitmproxy.net.encoding``), one+per message as there. Anything else cannot be read, which the caller must+treat as a body it cannot vouch for; so is a stream that is cut short or has+anything but a further gzip member after its end, since a client may still+make something of it.+"""++import zlib+from collections.abc import Callable+from io import BytesIO+from typing import Any++import brotli+import zstandard++_GZIP_MAGIC = b"\x1f\x8b"+_WINDOW = 64 * 1024+# Gzip members or zstd frames in one body. Each costs a decoder of its own,+# and a box can send 5 MiB of empty ones (a quarter of a million) to hold the+# shared event loop for most of a second. Real bodies have one, rarely a few.+_MAX_STREAMS = 64+++class DecodedTooLarge(Exception):+ """The body decodes to more than the limit."""+++class Undecodable(Exception):+ """An encoding this cannot decode within a bound, or corrupt data."""+++class _Feed:+ """The body in windows of ``_WINDOW`` bytes. A decoder copies whatever+ input is left after its stream's end into ``unused_data``; given the whole+ body, many tiny gzip members would cost time quadratic in its size."""++ def __init__(self, raw: bytes):+ self._view = memoryview(raw)+ self._pos = 0+ self.carry = b"" # read past the end of the last stream++ @property+ def done(self) -> bool:+ return not self.carry and self._pos >= len(self._view)++ def take(self) -> bytes:+ if self.carry:+ data, self.carry = self.carry, b""+ return data+ return self._window()++ def head(self, n: int, strip: bytes = b"") -> bytes:+ """At least *n* bytes of what follows (fewer at the end), with any+ leading *strip* bytes dropped for good."""+ while True:+ if strip:+ self.carry = self.carry.lstrip(strip)+ if len(self.carry) >= n or self._pos >= len(self._view):+ return self.carry+ self.carry += self._window()++ def _window(self) -> bytes:+ data = bytes(self._view[self._pos : self._pos + _WINDOW])+ self._pos += len(data)+ return data+++def _stream(+ decoder: Any,+ step: Callable[[Any, bytes, int], bytes],+ feed: _Feed,+ out: bytearray,+ limit: int,+) -> None:+ """Decode one complete stream (a gzip member, a zlib or zstd frame) from+ *feed* into *out*. A stream that stops short is ``Undecodable``: zlib and+ zstd hand back what they have of a cut stream without complaint, and a+ partial body would be scrubbed as if it were the whole one."""+ data = feed.take()+ while True:+ out += step(decoder, data, limit - len(out) + 1)+ if len(out) > limit:+ raise DecodedTooLarge+ if decoder.eof:+ feed.carry = decoder.unused_data+ return+ if feed.done:+ raise Undecodable("truncated stream")+ data = feed.take()+++def _zlib_step(decoder: Any, data: bytes, budget: int) -> bytes:+ return decoder.decompress(data, budget)+++def _gzip(raw: bytes, limit: int) -> bytes:+ """Every member, as a client decodes it: a gzip body may be several+ members back to back (RFC 1952 2.2), and a value in the second one must+ not pass because only the first was read. Zero padding after the last+ member is allowed, as Python's ``gzip`` allows it; anything else is not."""+ feed, out = _Feed(raw), bytearray()+ # 32 + 15: gzip or zlib header, detected, as mitmproxy does.+ _stream(zlib.decompressobj(32 + zlib.MAX_WBITS), _zlib_step, feed, out, limit)+ streams = 1+ while head := feed.head(2, strip=b"\0"):+ if not head.startswith(_GZIP_MAGIC):+ raise Undecodable("data after the end of the stream")+ streams += 1+ if streams > _MAX_STREAMS:+ raise Undecodable("too many gzip members")+ decoder = zlib.decompressobj(16 + zlib.MAX_WBITS)+ _stream(decoder, _zlib_step, feed, out, limit)+ return bytes(out)+++def _single(raw: bytes, limit: int, wbits: int) -> bytes:+ feed, out = _Feed(raw), bytearray()+ _stream(zlib.decompressobj(wbits), _zlib_step, feed, out, limit)+ if feed.head(1):+ raise Undecodable("data after the end of the stream")+ return bytes(out)+++def _deflate(raw: bytes, limit: int) -> bytes:+ try:+ return _single(raw, limit, zlib.MAX_WBITS)+ except zlib.error:+ # Some servers send raw DEFLATE, with no zlib header or checksum.+ return _single(raw, limit, -zlib.MAX_WBITS)+++def _brotli(raw: bytes, limit: int) -> bytes:+ decoder = brotli.Decompressor()+ out = decoder.process(raw, output_buffer_limit=limit + 1)+ # Output still pending means the limit stopped it, not the end of the data.+ if len(out) > limit or not decoder.can_accept_more_data():+ raise DecodedTooLarge+ # Data after the end is a ``brotli.error`` from ``process`` itself.+ if not decoder.is_finished():+ raise Undecodable("truncated brotli stream")+ return out+++def _zstd(raw: bytes, limit: int) -> bytes:+ reader = zstandard.ZstdDecompressor().stream_reader(+ BytesIO(raw), read_across_frames=True+ )+ out = reader.read(limit + 1)+ if len(out) > limit or reader.read(1):+ raise DecodedTooLarge+ # The reader returns a cut frame's output, or none of it, without an+ # error. All of it decodes to at most *limit* bytes (the reader ran out+ # first), so a second pass frame by frame, which does not bound its own+ # output, costs no more than the first and can tell a whole frame from a+ # cut one.+ feed, seen = _Feed(raw), bytearray()+ for _ in range(_MAX_STREAMS):+ if not feed.head(1):+ return out+ decoder = zstandard.ZstdDecompressor().decompressobj()+ _stream(decoder, lambda d, data, _: d.decompress(data), feed, seen, limit)+ if feed.head(1):+ raise Undecodable("too many zstd frames")+ return out+++def bounded_decode(raw: bytes, content_encoding: str, limit: int) -> bytes:+ """*raw* with its content encoding undone, if that is at most *limit* bytes.++ Raises ``DecodedTooLarge`` or ``Undecodable``.+ """+ encoding = content_encoding.strip().lower()+ if encoding in ("", "none", "identity"):+ if len(raw) > limit:+ raise DecodedTooLarge+ return raw+ if not raw:+ return b""+ try:+ if encoding == "gzip":+ return _gzip(raw, limit)+ if encoding in ("deflate", "deflateraw"):+ return _deflate(raw, limit)+ if encoding == "br":+ return _brotli(raw, limit)+ if encoding == "zstd":+ return _zstd(raw, limit)+ except (zlib.error, brotli.error, zstandard.ZstdError) as e:+ raise Undecodable(type(e).__name__) from None+ raise Undecodable(f"unsupported content encoding: {encoding[:32]!r}")diff --git a/autogpt_platform/swap_proxy/swap_proxy/decode_test.py b/autogpt_platform/swap_proxy/swap_proxy/decode_test.pynew file mode 100644index 0000000000..4285ac64a0--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/decode_test.py@@ -0,0 +1,159 @@+"""The bound is part of the decode: a small bomb per encoding, and proof that+refusing one does not first produce what it stands for."""++import gzip+import tracemalloc+import zlib++import brotli+import pytest+import zstandard++from swap_proxy.decode import DecodedTooLarge, Undecodable, bounded_decode++LIMIT = 1024 * 1024+TEXT = b'{"echo": "ghp_userAsecretvalue0001"}' * 100+++def raw_deflate(data: bytes) -> bytes:+ compressor = zlib.compressobj(wbits=-zlib.MAX_WBITS)+ return compressor.compress(data) + compressor.flush()+++ENCODERS = {+ "gzip": gzip.compress,+ "deflate": zlib.compress,+ "deflateraw": raw_deflate,+ "br": brotli.compress,+ "zstd": zstandard.ZstdCompressor().compress,+}++[email protected]("encoding", ENCODERS)+def test_a_body_within_the_limit_decodes_to_what_it_was(encoding):+ assert bounded_decode(ENCODERS[encoding](TEXT), encoding, LIMIT) == TEXT+ assert bounded_decode(ENCODERS[encoding](TEXT), encoding, len(TEXT)) == TEXT++[email protected]("encoding", ENCODERS)+def test_one_byte_over_the_limit_is_too_large(encoding):+ with pytest.raises(DecodedTooLarge):+ bounded_decode(ENCODERS[encoding](TEXT), encoding, len(TEXT) - 1)++[email protected]("encoding", ENCODERS)+def test_a_bomb_is_refused_without_being_decoded_first(encoding):+ """A few kilobytes on the wire standing for 64 MiB: refused, and the+ memory it took stays near the limit, nowhere near the decoded size."""+ bomb = ENCODERS[encoding](bytes(64 * 1024 * 1024))+ assert len(bomb) < LIMIT+ tracemalloc.start()+ try:+ with pytest.raises(DecodedTooLarge):+ bounded_decode(bomb, encoding, LIMIT)+ _, peak = tracemalloc.get_traced_memory()+ finally:+ tracemalloc.stop()+ assert peak < 8 * LIMIT++[email protected]("encoding", ["", "identity", "none", " Identity "])+def test_an_unencoded_body_is_bounded_by_its_own_length(encoding):+ assert bounded_decode(TEXT, encoding, len(TEXT)) == TEXT+ with pytest.raises(DecodedTooLarge):+ bounded_decode(TEXT, encoding, len(TEXT) - 1)++[email protected]("encoding", ["compress", "gzip, br", "x-made-up"])+def test_an_encoding_that_cannot_be_decoded_within_a_bound_is_undecodable(encoding):+ with pytest.raises(Undecodable):+ bounded_decode(b"\x1f\x8b whatever", encoding, LIMIT)++[email protected]("encoding", ["gzip", "deflate", "br", "zstd"])+def test_corrupt_data_is_undecodable(encoding):+ with pytest.raises(Undecodable):+ bounded_decode(b"this is not compressed data at all", encoding, LIMIT)+++def test_a_truncated_brotli_stream_is_undecodable():+ with pytest.raises(Undecodable):+ bounded_decode(brotli.compress(TEXT)[:-4], "br", LIMIT)++[email protected]("encoding", ENCODERS)+def test_an_empty_body_is_empty(encoding):+ assert bounded_decode(b"", encoding, LIMIT) == b""+++# ------------------------------------------------------------ whole streams only+#+# zlib stops at the end of the first stream and hands back what it has of a+# cut one without complaint. A client may read on, so the proxy must too.++TOKEN = b"ghp_userAsecretvalue0001"+++def test_every_gzip_member_is_decoded():+ """The second member carries the token: it must be there to be scrubbed."""+ body = gzip.compress(b"first ") + gzip.compress(TOKEN)+ assert bounded_decode(body, "gzip", LIMIT) == b"first " + TOKEN+ assert gzip.decompress(body) == b"first " + TOKEN # what a client reads+++def test_members_together_are_held_to_one_limit():+ body = gzip.compress(TEXT) + gzip.compress(TEXT)+ assert bounded_decode(body, "gzip", 2 * len(TEXT)) == TEXT + TEXT+ with pytest.raises(DecodedTooLarge):+ bounded_decode(body, "gzip", 2 * len(TEXT) - 1)+++def test_many_members_each_a_bomb_stay_within_the_limit():+ member = gzip.compress(bytes(LIMIT // 2 + 1))+ with pytest.raises(DecodedTooLarge):+ bounded_decode(member * 3, "gzip", LIMIT)+++def test_zero_padding_after_the_last_member_is_allowed():+ assert bounded_decode(gzip.compress(TEXT) + bytes(8), "gzip", LIMIT) == TEXT++[email protected]("encoding", ["gzip", "deflate", "deflateraw", "br", "zstd"])+def test_data_after_the_end_of_the_stream_is_undecodable(encoding):+ with pytest.raises(Undecodable):+ bounded_decode(ENCODERS[encoding](TEXT) + b"trailing " + TOKEN, encoding, LIMIT)++[email protected]("encoding", ["gzip", "deflate", "deflateraw", "br", "zstd"])[email protected]("cut", [1, 4, 0.5])+def test_a_truncated_stream_is_undecodable(encoding, cut):+ """Cut in the checksum, or halfway through: partial output is not the body."""+ body = ENCODERS[encoding](TEXT + bytes(range(256)) * 64)+ end = int(len(body) * cut) if isinstance(cut, float) else len(body) - cut+ with pytest.raises(Undecodable):+ bounded_decode(body[:end], encoding, LIMIT)+++def test_a_truncated_second_member_is_undecodable():+ body = gzip.compress(b"first ") + gzip.compress(TOKEN)[:-4]+ with pytest.raises(Undecodable):+ bounded_decode(body, "gzip", LIMIT)++[email protected]("encoding", ["gzip", "zstd"])+def test_a_body_of_many_tiny_streams_is_undecodable(encoding):+ """Each member or frame is a decoder of its own: a quarter of a million+ empty ones would hold the event loop. A few are fine."""+ empty = ENCODERS[encoding](b"")+ assert bounded_decode(empty * 64, encoding, LIMIT) == b""+ with pytest.raises(Undecodable):+ bounded_decode(empty * 65, encoding, LIMIT)+ with pytest.raises(Undecodable):+ bounded_decode(empty * (5 * 1024 * 1024 // len(empty)), encoding, LIMIT)+++def test_a_zstd_body_of_several_frames_decodes_whole():+ frame = ENCODERS["zstd"]+ assert bounded_decode(frame(b"first ") + frame(TOKEN), "zstd", LIMIT) == (+ b"first " + TOKEN+ )diff --git a/autogpt_platform/swap_proxy/swap_proxy/e2e_test.py b/autogpt_platform/swap_proxy/swap_proxy/e2e_test.pynew file mode 100644index 0000000000..682d4f5f5e--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/e2e_test.py@@ -0,0 +1,594 @@+"""The whole proxy, over real sockets: a SOCKS5 client on one side, an HTTP+server on the other, mitmproxy with the addon in between.++This is where the tenant boundary is tested adversarially: what a box can and+cannot get by presenting credentials that are wrong, stale, or another's.+"""++import asyncio+import base64+import hashlib+import json+import logging+from typing import Optional++import pytest++from swap_proxy.__main__ import build_master+from swap_proxy.addon import MAX_BODY_BYTES, SwapProxyAddon+from swap_proxy.egress import EgressGuard+from swap_proxy.owners import CREDENTIAL_KEY_PREFIX, OwnerDirectory+from swap_proxy.source import SourceUnavailable+from swap_proxy.swap import Credential, host_in_list++TOKEN_A = "ghp_userAsecretvalue0001"+TOKEN_B = "ghp_userBsecretvalue0002"+UPSTREAM_HOST = "localhost"+++class FakeRedis:+ def __init__(self):+ self.store: dict[str, str] = {}++ async def get(self, name):+ return self.store.get(name)++ def add_box(+ self,+ username: str,+ secret: str,+ user_id: Optional[str],+ owner: str,+ swaps: Optional[bool] = None,+ ):+ self.store[CREDENTIAL_KEY_PREFIX + username] = json.dumps(+ {+ "owner": owner,+ "user_id": user_id,+ "swaps": user_id is not None if swaps is None else swaps,+ "sandbox_id": "sb-" + username[-4:],+ "secret_sha256": hashlib.sha256(secret.encode()).hexdigest(),+ }+ )+++class FakeSource:+ """github is bound to the upstream's name; each user has their own token."""++ def __init__(self):+ self.tokens = {"user-a": TOKEN_A, "user-b": TOKEN_B}+ self.hosts: tuple[str, ...] = (UPSTREAM_HOST,)+ self.down = False+ self.anywhere = False # the credential's ``swap_anywhere``+ self.asked: list[tuple[str, str, str]] = []++ async def bound_names(self, host):+ if self.down:+ raise SourceUnavailable("down")+ return {"github"} if host_in_list(host, self.hosts) else set()++ async def resolve(self, user_id, name, host):+ self.asked.append((user_id, name, host))+ if self.down:+ raise SourceUnavailable("down")+ token = self.tokens.get(user_id)+ if name != "github" or token is None or not host_in_list(host, self.hosts):+ return None+ return Credential(+ "github", {"access_token": token}, self.hosts, swap_anywhere=self.anywhere+ )+++class Upstream:+ """Answers every request with what it received, as JSON.++ *pad* grows the answer by that many bytes; *chunked* sends it without a+ length, cut in the middle of *split_at* so a value straddles two chunks.+ """++ def __init__(self):+ self.seen: list[dict] = []+ self.port = 0+ self.pad = 0+ self.chunked = False+ self.split_at = b""+ # Something the provider holds and answers every request with, as a+ # gist the box once wrote a swapped value into would.+ self.stored = ""++ async def start(self):+ self._server = await asyncio.start_server(self._handle, "127.0.0.1", 0)+ self.port = self._server.sockets[0].getsockname()[1]++ async def stop(self):+ self._server.close()+ await self._server.wait_closed()++ async def _handle(self, reader, writer):+ try:+ head = (await reader.readuntil(b"\r\n\r\n")).decode()+ lines = head.split("\r\n")+ method, path, _ = lines[0].split(" ")+ headers = dict(line.split(": ", 1) for line in lines[1:] if ": " in line)+ headers = {k.lower(): v for k, v in headers.items()}+ if "chunked" in headers.get("transfer-encoding", ""):+ body = await self._read_chunked(reader)+ else:+ body = await reader.readexactly(int(headers.get("content-length", 0)))+ received = {+ "method": method,+ "path": path,+ "headers": headers,+ "body": body.decode("utf-8", "replace"),+ }+ self.seen.append(received)+ # A large body is kept for the test to look at, not echoed back.+ echoed = received if len(body) < 65536 else {**received, "body": ""}+ stored = {"stored": self.stored} if self.stored else {}+ payload = json.dumps({**echoed, **stored, "pad": "x" * self.pad}).encode()+ head = b"HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n"+ if self.chunked:+ cut = payload.find(self.split_at) + len(self.split_at) // 2+ writer.write(+ head + b"Transfer-Encoding: chunked\r\nConnection: close\r\n\r\n"+ )+ for part in (payload[:cut], payload[cut:]):+ writer.write(f"{len(part):x}\r\n".encode() + part + b"\r\n")+ await writer.drain()+ writer.write(b"0\r\n\r\n")+ else:+ writer.write(+ head+ + f"Content-Length: {len(payload)}\r\n".encode()+ + b"Connection: close\r\n\r\n"+ + payload+ )+ await writer.drain()+ except (ConnectionError, asyncio.IncompleteReadError):+ pass # the proxy refused the exchange and hung up+ finally:+ writer.close()++ @staticmethod+ async def _read_chunked(reader) -> bytes:+ body = b""+ while size := int((await reader.readline()).strip(), 16):+ body += (await reader.readexactly(size + 2))[:-2]+ await reader.readline()+ return body+++class Proxy:+ def __init__(self, redis, source, allow, allow_insecure_swap=True):+ self.redis, self.source = redis, source+ self._addon = SwapProxyAddon(+ OwnerDirectory(redis),+ source,+ EgressGuard(allow),+ allow_insecure_swap=allow_insecure_swap,+ )++ async def start(self, tmp_path):+ self.master = build_master(self._addon, "127.0.0.1", 0, str(tmp_path))+ self._task = asyncio.create_task(self.master.run())+ server = self.master.addons.get("proxyserver")+ assert server is not None+ for _ in range(200):+ addrs = server.listen_addrs()+ if addrs and addrs[0][1]:+ self.port = addrs[0][1]+ return+ await asyncio.sleep(0.05)+ raise RuntimeError("proxy did not start")++ async def stop(self):+ self.master.shutdown()+ await self._task+++async def socks5_request(+ proxy_port: int,+ username: str,+ secret: str,+ dest_host: str,+ dest_port: int,+ request: bytes,+) -> Optional[bytes]:+ """Speak SOCKS5 by hand; ``None`` means the proxy refused the connection."""+ reader, writer = await asyncio.open_connection("127.0.0.1", proxy_port)+ try:+ writer.write(b"\x05\x01\x02") # one method offered: username/password+ if await reader.readexactly(2) != b"\x05\x02":+ return None+ u, p = username.encode(), secret.encode()+ writer.write(b"\x01" + bytes([len(u)]) + u + bytes([len(p)]) + p)+ if await reader.readexactly(2) != b"\x01\x00":+ return None+ h = dest_host.encode()+ writer.write(+ b"\x05\x01\x00\x03" + bytes([len(h)]) + h + dest_port.to_bytes(2, "big")+ )+ reply = await reader.readexactly(10)+ if reply[1] != 0:+ return None+ writer.write(request)+ await writer.drain()+ return await asyncio.wait_for(reader.read(), timeout=10)+ except (asyncio.IncompleteReadError, ConnectionError):+ return None+ finally:+ writer.close()+++def http_get(path="/user", headers=None, host=UPSTREAM_HOST) -> bytes:+ lines = [f"GET {path} HTTP/1.1", f"Host: {host}", "Connection: close"]+ lines += [f"{k}: {v}" for k, v in (headers or {}).items()]+ return ("\r\n".join(lines) + "\r\n\r\n").encode()+++def http_post(+ body: bytes,+ content_type: str,+ *,+ chunks: Optional[list[bytes]] = None,+ authorization: str = "Bearer hsurr:github",+) -> bytes:+ """With a length, or (given *chunks*) chunked and without one."""+ lines = [+ "POST /repo.git/git-receive-pack HTTP/1.1",+ f"Host: {UPSTREAM_HOST}",+ "Connection: close",+ f"Authorization: {authorization}",+ f"Content-Type: {content_type}",+ ]+ if chunks is None:+ lines.append(f"Content-Length: {len(body)}")+ return ("\r\n".join(lines) + "\r\n\r\n").encode() + body+ lines.append("Transfer-Encoding: chunked")+ framed = b"".join(f"{len(c):x}\r\n".encode() + c + b"\r\n" for c in chunks)+ return ("\r\n".join(lines) + "\r\n\r\n").encode() + framed + b"0\r\n\r\n"+++def body_of(raw: Optional[bytes]) -> dict:+ assert raw, "no response through the proxy"+ head, _, body = raw.partition(b"\r\n\r\n")+ if b"chunked" in head.lower():+ decoded = b""+ while body:+ size, _, body = body.partition(b"\r\n")+ decoded += body[: int(size, 16)]+ body = body[int(size, 16) + 2 :]+ body = decoded+ return json.loads(body)+++def audit_lines(caplog) -> list[dict]:+ return [+ json.loads(r.message) for r in caplog.records if r.name == "swap_proxy.audit"+ ]+++async def stack(tmp_path):+ redis, source, upstream = FakeRedis(), FakeSource(), Upstream()+ await upstream.start()+ proxy = Proxy(redis, source, allow=["127.0.0.0/8", "::1"])+ await proxy.start(tmp_path)+ redis.add_box("box-" + "a" * 16, "secret-a", "user-a", "session:s-a")+ redis.add_box("box-" + "b" * 16, "secret-b", "user-b", "expert:e-b")+ redis.add_box("box-" + "c" * 16, "secret-c", None, "session:anonymous")+ redis.add_box("box-" + "d" * 16, "secret-d", "user-a", "block:user-a", swaps=False)+ yield proxy, upstream, source+ await proxy.stop()+ await upstream.stop()+++BOX_A = ("box-" + "a" * 16, "secret-a")+BOX_B = ("box-" + "b" * 16, "secret-b")+BOX_C = ("box-" + "c" * 16, "secret-c")+BOX_D = ("box-" + "d" * 16, "secret-d")+BEARER = {"Authorization": "Bearer hsurr:github"}+++async def test_a_placeholder_becomes_the_owners_token_and_the_echo_is_scrubbed(stack):+ proxy, upstream, _ = stack+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ # The provider received the real token...+ assert upstream.seen[0]["headers"]["authorization"] == f"Bearer {TOKEN_A}"+ # ...and the box, which got its own request echoed back, did not.+ assert TOKEN_A.encode() not in (raw or b"")+ assert body_of(raw)["headers"]["authorization"] == "Bearer hsurr:github"+++async def test_each_box_gets_its_own_users_token(stack):+ proxy, upstream, _ = stack+ for box in (BOX_A, BOX_B):+ await socks5_request(+ proxy.port, *box, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ sent = [seen["headers"]["authorization"] for seen in upstream.seen]+ assert sent == [f"Bearer {TOKEN_A}", f"Bearer {TOKEN_B}"]+++ "username, secret",+ [+ (BOX_A[0], "wrong-secret"),+ (BOX_A[0], BOX_B[1]), # another box's secret+ ("box-" + "f" * 16, "secret-a"), # a username nobody minted+ ("e2b:egress:cred:" + BOX_A[0], "secret-a"), # not a username at all+ (BOX_A[0], ""),+ ],+)+async def test_a_connection_nobody_vouches_for_is_refused_at_the_door(+ stack, username, secret+):+ proxy, upstream, _ = stack+ raw = await socks5_request(+ proxy.port, username, secret, UPSTREAM_HOST, upstream.port, http_get()+ )+ assert raw is None and upstream.seen == []+++async def test_no_authentication_is_not_an_offer_the_proxy_accepts(stack):+ proxy, _, _ = stack+ reader, writer = await asyncio.open_connection("127.0.0.1", proxy.port)+ writer.write(b"\x05\x01\x00") # "no authentication" only+ assert (await reader.readexactly(2))[1] == 0xFF+ writer.close()+++async def test_a_rotated_credential_stops_opening_the_door(stack):+ proxy, upstream, _ = stack+ del proxy.redis.store[CREDENTIAL_KEY_PREFIX + BOX_A[0]]+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get()+ )+ assert raw is None++[email protected]("box", [BOX_C, BOX_D], ids=["no user", "a block's box"])+async def test_a_box_that_does_not_swap_egresses_with_its_placeholder_intact(+ stack, box+):+ """A block runs a graph someone else may have written: it has a user, and+ still must not get to act with that user's accounts."""+ proxy, upstream, source = stack+ username, secret = box+ request = http_get(headers=BEARER)+ await socks5_request(+ proxy.port, username, secret, UPSTREAM_HOST, upstream.port, request+ )+ assert upstream.seen[0]["headers"]["authorization"] == "Bearer hsurr:github"+ assert source.asked == []+++async def test_a_placeholder_for_an_unbound_host_goes_out_literally(stack, caplog):+ proxy, upstream, source = stack+ source.hosts = ("api.github.com",)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ assert upstream.seen[0]["headers"]["authorization"] == "Bearer hsurr:github"+ assert source.asked == []+ (line,) = audit_lines(caplog)+ assert (line["event"], line["reason"]) == ("refused", "unbound-host")+ assert line["owner"] == "session:s-a" and line["placeholder"] == "hsurr:github"+++async def test_a_backend_that_cannot_be_asked_means_no_swap_and_no_answer(+ stack, caplog+):+ """Nothing is swapped in, and what comes back is not passed on: without the+ backend the proxy cannot tell which of the user's values it might hold."""+ proxy, upstream, source = stack+ source.down = True+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ assert upstream.seen[0]["headers"]["authorization"] == "Bearer hsurr:github"+ assert b"200 OK" not in (raw or b"")+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ assert events == [+ ("refused", "resolver-unavailable"),+ ("refused-response", "resolver-unavailable"),+ ]+++async def test_the_audit_names_the_swap_and_never_the_value(stack, caplog):+ proxy, upstream, _ = stack+ with caplog.at_level(logging.INFO):+ await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ audit = audit_lines(caplog)+ who = {+ "owner": "session:s-a",+ "user_id": "user-a",+ "sandbox_id": "sb-aaaa",+ "host": UPSTREAM_HOST,+ }+ assert audit == [+ {"ts": audit[0]["ts"], "event": "swapped", "placeholder": "hsurr:github"} | who,+ # The upstream echoed the token back; the box got the placeholder.+ {"ts": audit[1]["ts"], "event": "scrubbed"} | who,+ ]+ assert TOKEN_A not in caplog.text+++# ------------------------------------------------- bodies too large to hold+#+# mitmproxy streams a body over MAX_BODY_BYTES, and a box chooses the size of+# what it sends and, by what it asks for, of what comes back.++OVER = MAX_BODY_BYTES + 1024 * 1024+++async def test_a_padded_response_that_echoes_the_token_is_refused_not_passed_on(+ stack, caplog+):+ proxy, upstream, _ = stack+ upstream.pad = OVER+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ assert upstream.seen[0]["headers"]["authorization"] == f"Bearer {TOKEN_A}"+ assert TOKEN_A.encode() not in (raw or b"") and b"xxxx" not in (raw or b"")+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ assert events == [("swapped", None), ("refused-response", "too-large-to-scrub")]+++async def test_a_padded_response_without_a_length_is_refused_too(stack, caplog):+ proxy, upstream, _ = stack+ upstream.pad, upstream.chunked, upstream.split_at = OVER, True, TOKEN_A.encode()+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ assert TOKEN_A.encode() not in (raw or b"") and b"xxxx" not in (raw or b"")+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ assert events == [("swapped", None), ("refused-response", "too-large-to-scrub")]+++async def test_a_token_split_across_two_chunks_of_a_response_is_scrubbed(stack, caplog):+ proxy, upstream, _ = stack+ upstream.pad, upstream.chunked, upstream.split_at = 1024, True, TOKEN_A.encode()+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, http_get(headers=BEARER)+ )+ assert TOKEN_A.encode() not in (raw or b"")+ assert body_of(raw)["headers"]["authorization"] == "Bearer hsurr:github"+ assert [line["event"] for line in audit_lines(caplog)] == ["swapped", "scrubbed"]+++GIT_BASIC = "Basic " + base64.b64encode(b"x-access-token:hsurr:github").decode()++[email protected]("chunked", [False, True], ids=["with a length", "chunked"])+async def test_a_large_push_authenticates_while_its_pack_streams(+ stack, caplog, chunked+):+ """As git sends it: HTTP Basic (also for a token in the remote URL, which+ git turns into this header). The body is binary and is not touched; the+ header must still be swapped before it leaves, and the audit must be about+ what reached the wire."""+ proxy, upstream, _ = stack+ pack = b"PACK\x00\xff" + b"\x00" * OVER+ chunks = [pack[: len(pack) // 2], pack[len(pack) // 2 :]] if chunked else None+ request = http_post(+ pack,+ "application/x-git-receive-pack-request",+ chunks=chunks,+ authorization=GIT_BASIC,+ )+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await socks5_request(proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, request)+ sent = upstream.seen[0]["headers"]["authorization"]+ assert base64.b64decode(sent.split()[1]) == f"x-access-token:{TOKEN_A}".encode()+ assert len(upstream.seen[0]["body"]) == len(pack)+ # One swap, then the scrub of the header the upstream echoed back.+ assert [line["event"] for line in audit_lines(caplog)] == ["swapped", "scrubbed"]++[email protected]("chunked", [False, True], ids=["with a length", "chunked"])+async def test_a_text_body_too_large_to_hold_goes_out_literally_and_the_audit_says_so(+ stack, caplog, chunked+):+ """For a credential that may go into a body at all (``swap_anywhere``)."""+ proxy, upstream, source = stack+ source.anywhere = True+ body = b'{"token": "hsurr:github", "pad": "' + b"x" * OVER + b'"}'+ chunks = [body[:20], body[20:]] if chunked else None+ request = http_post(body, "application/json", chunks=chunks)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await socks5_request(proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, request)+ seen = upstream.seen[0]+ assert seen["headers"]["authorization"] == f"Bearer {TOKEN_A}"+ assert seen["body"] == body.decode() # intact, placeholder and all+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ # One swap, the header's; the body's placeholder is not claimed.+ assert events == [+ ("swapped", None),+ ("body-not-swapped", "body-too-large"),+ ("scrubbed", None), # the echoed header+ ]+++async def test_a_placeholder_split_across_two_chunks_of_a_request_is_swapped(+ stack, caplog+):+ """For a credential that may go into a body at all (``swap_anywhere``)."""+ proxy, upstream, source = stack+ source.anywhere = True+ body = b'{"token": "hsurr:github"}'+ request = http_post(body, "application/json", chunks=[body[:15], body[15:]])+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, request+ )+ assert json.loads(upstream.seen[0]["body"]) == {"token": TOKEN_A}+ assert TOKEN_A.encode() not in (raw or b"")+ events = [line["event"] for line in audit_lines(caplog)]+ assert events == ["swapped", "swapped", "scrubbed"]+++async def test_private_address_space_is_out_of_reach(tmp_path):+ """The same stack with nothing allowed: the upstream on loopback stands in+ for a metadata server or a neighbouring service."""+ redis, upstream = FakeRedis(), Upstream()+ await upstream.start()+ proxy = Proxy(redis, FakeSource(), allow=[])+ await proxy.start(tmp_path)+ redis.add_box(*BOX_A, "user-a", "session:s-a")+ try:+ for dest in ("localhost", "127.0.0.1", "::ffff:127.0.0.1"):+ raw = await socks5_request(+ proxy.port, *BOX_A, dest, upstream.port, http_get()+ )+ assert not raw or b"200 OK" not in raw+ assert upstream.seen == []+ finally:+ await proxy.stop()+ await upstream.stop()++[email protected]("chunked", [False, True], ids=["with a length", "chunked"])+async def test_by_default_a_body_goes_out_literally_and_only_the_header_is_swapped(+ stack, caplog, chunked+):+ """A value swapped into a body could be stored at the provider and read+ back in any encoding it offers; so by default it is not."""+ proxy, upstream, _ = stack+ body = b'{"files": {"a.txt": {"content": "hsurr:github"}}}'+ chunks = [body[:15], body[15:]] if chunked else None+ request = http_post(body, "application/json", chunks=chunks)+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ await socks5_request(proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, request)+ seen = upstream.seen[0]+ assert seen["headers"]["authorization"] == f"Bearer {TOKEN_A}"+ assert seen["body"] == body.decode()+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ # Under the streaming limit mitmproxy holds even a chunked body, so the+ # literal placeholder is seen and audited either way.+ assert events == [+ ("swapped", None),+ ("refused", "outside-authorization"),+ ("scrubbed", None),+ ]+++async def test_gh_style_token_authorization_is_swapped(stack):+ """``gh`` sends ``Authorization: token ...``."""+ proxy, upstream, _ = stack+ request = http_get(headers={"Authorization": "token hsurr:github"})+ raw = await socks5_request(+ proxy.port, *BOX_A, UPSTREAM_HOST, upstream.port, request+ )+ assert upstream.seen[0]["headers"]["authorization"] == f"token {TOKEN_A}"+ assert body_of(raw)["headers"]["authorization"] == "token hsurr:github"diff --git a/autogpt_platform/swap_proxy/swap_proxy/e2e_tls_test.py b/autogpt_platform/swap_proxy/swap_proxy/e2e_tls_test.pynew file mode 100644index 0000000000..26779fbb98--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/e2e_tls_test.py@@ -0,0 +1,314 @@+"""The same stack over TLS, where the rules that matter in production live:+only bound hosts are opened, and a value goes only where the upstream+certificate proves the request is going."""++import asyncio+import datetime+import ipaddress+import logging+import ssl++import pytest+from cryptography import x509+from cryptography.hazmat.primitives import hashes, serialization+from cryptography.hazmat.primitives.asymmetric import ec+from cryptography.x509.oid import NameOID++from swap_proxy.e2e_test import (+ BOX_A,+ BOX_D,+ TOKEN_A,+ FakeRedis,+ FakeSource,+ Proxy,+ Upstream,+ audit_lines,+ body_of,+ http_get,+ socks5_request,+)++BOUND, ALSO_BOUND, UNBOUND = "localhost", "alt.localhost", "unbound.localhost"+++def _make_ca_and_cert(tmp_path, names):+ """A throwaway CA and a server certificate for *names* signed by it."""+ now = datetime.datetime.now(datetime.timezone.utc)++ def build(subject, issuer, public_key, signing_key, *, ca):+ ski = x509.SubjectKeyIdentifier.from_public_key+ aki = x509.AuthorityKeyIdentifier.from_issuer_public_key+ builder = (+ x509.CertificateBuilder()+ .subject_name(subject)+ .issuer_name(issuer)+ .public_key(public_key)+ .serial_number(x509.random_serial_number())+ .not_valid_before(now - datetime.timedelta(minutes=5))+ .not_valid_after(now + datetime.timedelta(days=1))+ .add_extension(x509.BasicConstraints(ca=ca, path_length=None), True)+ .add_extension(ski(public_key), False)+ .add_extension(aki(signing_key.public_key()), False)+ .add_extension(+ x509.KeyUsage(+ digital_signature=True,+ key_cert_sign=ca,+ crl_sign=ca,+ content_commitment=False,+ key_encipherment=False,+ data_encipherment=False,+ key_agreement=False,+ encipher_only=False,+ decipher_only=False,+ ),+ True,+ )+ )+ if not ca:+ sans: list[x509.GeneralName] = [x509.DNSName(n) for n in names]+ sans.append(x509.IPAddress(ipaddress.ip_address("127.0.0.1")))+ builder = builder.add_extension(x509.SubjectAlternativeName(sans), False)+ return builder.sign(signing_key, hashes.SHA256())++ ca_key = ec.generate_private_key(ec.SECP256R1())+ ca_name = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "test upstream CA")])+ ca_cert = build(ca_name, ca_name, ca_key.public_key(), ca_key, ca=True)+ key = ec.generate_private_key(ec.SECP256R1())+ name = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, names[0])])+ cert = build(name, ca_name, key.public_key(), ca_key, ca=False)++ pem = serialization.Encoding.PEM+ ca_path, cert_path, key_path = (+ tmp_path / "upstream-ca.pem",+ tmp_path / "upstream.pem",+ tmp_path / "upstream.key",+ )+ ca_path.write_bytes(ca_cert.public_bytes(pem))+ cert_path.write_bytes(cert.public_bytes(pem))+ key_path.write_bytes(+ key.private_bytes(+ pem, serialization.PrivateFormat.PKCS8, serialization.NoEncryption()+ )+ )+ return ca_path, cert_path, key_path+++class TLSUpstream(Upstream):+ def __init__(self, cert_path, key_path):+ super().__init__()+ self._context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)+ self._context.load_cert_chain(cert_path, key_path)++ async def start(self):+ self._server = await asyncio.start_server(+ self._handle, "127.0.0.1", 0, ssl=self._context+ )+ self.port = self._server.sockets[0].getsockname()[1]+++async def tls_request(proxy_port, box, dest_port, sni, request, trust) -> tuple:+ """SOCKS5 to the upstream, then TLS inside the tunnel trusting *trust*.+ Returns the response and the issuer of the certificate that was served."""+ reader, writer = await asyncio.open_connection("127.0.0.1", proxy_port)+ try:+ u, p = box[0].encode(), box[1].encode()+ writer.write(b"\x05\x01\x02")+ assert await reader.readexactly(2) == b"\x05\x02"+ writer.write(b"\x01" + bytes([len(u)]) + u + bytes([len(p)]) + p)+ assert await reader.readexactly(2) == b"\x01\x00"+ # By address, as a box that resolved the name itself would.+ writer.write(b"\x05\x01\x00\x01" + bytes([127, 0, 0, 1]))+ writer.write(dest_port.to_bytes(2, "big"))+ assert (await reader.readexactly(10))[1] == 0+ context = ssl.create_default_context(cafile=str(trust))+ context.set_alpn_protocols(["http/1.1"])+ await writer.start_tls(context, server_hostname=sni)+ issuer = dict(pair[0] for pair in writer.get_extra_info("peercert")["issuer"])[+ "commonName"+ ]+ writer.write(request)+ await writer.drain()+ return await asyncio.wait_for(reader.read(), timeout=10), issuer+ finally:+ writer.close()+++async def tls_stack(tmp_path):+ ca_path, cert_path, key_path = _make_ca_and_cert(+ tmp_path, [BOUND, ALSO_BOUND, UNBOUND]+ )+ redis, source = FakeRedis(), FakeSource()+ source.hosts = (BOUND, ALSO_BOUND)+ upstream = TLSUpstream(cert_path, key_path)+ await upstream.start()+ proxy = Proxy(redis, source, allow=["127.0.0.0/8"], allow_insecure_swap=False)+ await proxy.start(tmp_path / "conf")+ proxy.master.options.update(ssl_verify_upstream_trusted_ca=str(ca_path))+ redis.add_box(*BOX_A, "user-a", "session:s-a")+ redis.add_box(*BOX_D, "user-a", "block:user-a", swaps=False)+ mitm_ca = tmp_path / "conf" / "mitmproxy-ca-cert.pem"+ yield proxy, upstream, ca_path, mitm_ca+ await proxy.stop()+ await upstream.stop()+++BEARER = {"Authorization": "Bearer hsurr:github"}+++async def test_a_bound_host_is_opened_and_the_token_swapped(tls_stack):+ proxy, upstream, _, mitm_ca = tls_stack+ raw, issuer = await tls_request(+ proxy.port, BOX_A, upstream.port, BOUND, http_get(headers=BEARER), mitm_ca+ )+ assert issuer == "mitmproxy"+ assert upstream.seen[0]["headers"]["authorization"] == f"Bearer {TOKEN_A}"+ assert body_of(raw)["headers"]["authorization"] == "Bearer hsurr:github"+++async def test_an_unbound_host_is_never_opened(tls_stack):+ """The box talks TLS to the real server; the proxy only moves bytes."""+ proxy, upstream, upstream_ca, _ = tls_stack+ request = http_get(headers=BEARER, host=UNBOUND)+ raw, issuer = await tls_request(+ proxy.port, BOX_A, upstream.port, UNBOUND, request, upstream_ca+ )+ assert issuer == "test upstream CA"+ assert body_of(raw)["headers"]["authorization"] == "Bearer hsurr:github"+++async def test_a_host_header_the_certificate_was_not_verified_for_gets_nothing(+ tls_stack,+):+ """Both names are bound, but the connection proved only one of them."""+ proxy, upstream, _, mitm_ca = tls_stack+ request = http_get(headers=BEARER, host=ALSO_BOUND)+ await tls_request(proxy.port, BOX_A, upstream.port, BOUND, request, mitm_ca)+ assert upstream.seen[0]["headers"]["authorization"] == "Bearer hsurr:github"+++async def test_an_upstream_whose_certificate_does_not_verify_gets_nothing(tls_stack):+ proxy, upstream, _, mitm_ca = tls_stack+ proxy.master.options.update(ssl_verify_upstream_trusted_ca=None)+ try:+ raw, _ = await tls_request(+ proxy.port, BOX_A, upstream.port, BOUND, http_get(headers=BEARER), mitm_ca+ )+ except (ssl.SSLError, ConnectionError, asyncio.IncompleteReadError):+ raw = b""+ assert upstream.seen == [] and TOKEN_A.encode() not in raw+ assert b"200 OK" not in raw+++async def test_plain_http_proves_nothing_so_nothing_is_swapped(tmp_path, caplog):+ """No certificate, no proof of where the request is going: a token must+ not cross the network in the clear to whoever answers on port 80."""+ redis, source, upstream = FakeRedis(), FakeSource(), Upstream()+ await upstream.start()+ proxy = Proxy(redis, source, allow=["127.0.0.0/8"], allow_insecure_swap=False)+ await proxy.start(tmp_path)+ redis.add_box(*BOX_A, "user-a", "session:s-a")+ # What the provider holds from an earlier swap comes back over http too.+ upstream.stored = TOKEN_A+ try:+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw = await socks5_request(+ proxy.port, *BOX_A, BOUND, upstream.port, http_get(headers=BEARER)+ )+ finally:+ await proxy.stop()+ await upstream.stop()+ assert upstream.seen[0]["headers"]["authorization"] == "Bearer hsurr:github"+ assert '"reason": "unverified-destination"' in caplog.text+ # Looked up to scrub, which sends nothing: the box gets the placeholder.+ assert TOKEN_A.encode() not in (raw or b"")+ assert body_of(raw)["stored"] == "hsurr:github"+++async def test_a_cold_start_outage_still_opens_a_swapping_boxs_connection(+ tls_stack, caplog+):+ """No bindings table has ever arrived, so whether the host is bound is+ unknown. Tunnelled, the hooks that refuse what cannot be scrubbed would+ never run, and a value the box stored there earlier would come back."""+ proxy, upstream, _, mitm_ca = tls_stack+ proxy.source.down = True+ upstream.stored = TOKEN_A+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw, issuer = await tls_request(+ proxy.port, BOX_A, upstream.port, BOUND, http_get(), mitm_ca+ )+ assert issuer == "mitmproxy"+ assert TOKEN_A.encode() not in raw and b"200 OK" not in raw+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ assert events == [("refused-response", "resolver-unavailable")]+++async def test_a_cold_start_outage_leaves_a_box_that_does_not_swap_alone(tls_stack):+ """Nothing of its user's can be swapped in for it: no reason to read it."""+ proxy, upstream, upstream_ca, _ = tls_stack+ proxy.source.down = True+ raw, issuer = await tls_request(+ proxy.port, BOX_D, upstream.port, BOUND, http_get(), upstream_ca+ )+ assert issuer == "test upstream CA" and b"200 OK" in raw+++async def tls_request_without_sni(proxy_port, box, dest_port, trust) -> bytes:+ """As ``tls_request``, but connecting by address and sending no SNI."""+ reader, writer = await asyncio.open_connection("127.0.0.1", proxy_port)+ try:+ u, p = box[0].encode(), box[1].encode()+ writer.write(b"\x05\x01\x02")+ assert await reader.readexactly(2) == b"\x05\x02"+ writer.write(b"\x01" + bytes([len(u)]) + u + bytes([len(p)]) + p)+ assert await reader.readexactly(2) == b"\x01\x00"+ writer.write(b"\x05\x01\x00\x01" + bytes([127, 0, 0, 1]))+ writer.write(dest_port.to_bytes(2, "big"))+ assert (await reader.readexactly(10))[1] == 0+ context = ssl.create_default_context(cafile=str(trust))+ context.check_hostname = False # an address, and nothing to match+ await asyncio.wait_for(+ writer.start_tls(context, server_hostname=None), timeout=10+ )+ writer.write(http_get(host="127.0.0.1"))+ await writer.drain()+ return await asyncio.wait_for(reader.read(), timeout=10)+ finally:+ writer.close()+++async def test_tls_without_sni_from_a_box_that_swaps_is_refused(tls_stack, caplog):+ """By address, a bound provider could hand back a value stored through an+ earlier swap, and with no name nothing that comes back can be judged."""+ proxy, upstream, upstream_ca, mitm_ca = tls_stack+ upstream.stored = TOKEN_A+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ for trust in (mitm_ca, upstream_ca):+ with pytest.raises((ssl.SSLError, ConnectionError)):+ await tls_request_without_sni(proxy.port, BOX_A, upstream.port, trust)+ assert upstream.seen == []+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ assert events == [("refused-connection", "no-sni")] * 2+++async def test_tls_without_sni_from_a_box_that_does_not_swap_passes_through(+ tls_stack,+):+ proxy, upstream, upstream_ca, _ = tls_stack+ raw = await tls_request_without_sni(proxy.port, BOX_D, upstream.port, upstream_ca)+ assert b"200 OK" in raw+++async def test_not_http_inside_an_opened_connection_is_not_relayed(tls_stack, caplog):+ """mitmproxy would relay it as raw TCP, which nothing scrubs. Refused by+ closing at once, so the box is not left waiting."""+ proxy, upstream, _, mitm_ca = tls_stack+ with caplog.at_level(logging.INFO, logger="swap_proxy.audit"):+ raw, issuer = await tls_request(+ proxy.port, BOX_A, upstream.port, BOUND, b"\x00\x01\x02 binary\n", mitm_ca+ )+ assert issuer == "mitmproxy"+ assert upstream.seen == [] and TOKEN_A.encode() not in raw+ events = [(line["event"], line.get("reason")) for line in audit_lines(caplog)]+ assert events == [("refused-connection", "not-http")]diff --git a/autogpt_platform/swap_proxy/swap_proxy/egress.py b/autogpt_platform/swap_proxy/swap_proxy/egress.pynew file mode 100644index 0000000000..8271747f32--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/egress.py@@ -0,0 +1,178 @@+"""The egress guard: a box must not reach private address space through us.++The proxy sits inside the platform's network and dials out on a box's behalf,+so without this a box could ask it for the metadata server, the database or a+neighbouring service. Ported from spark-vm's ``server_connect`` guard.++The destination is resolved *before* the upstream connect, a refused address+never gets even a SYN, and an allowed one is pinned to the address that was+checked, so the check and the connect use the same answer: no DNS-rebind race.++One departure from spark-vm: a DNS failure is refused, not waved through.+There the connect "fails on its own anyway"; here mitmproxy would resolve the+name again itself, and a name that fails once and answers with a private+address a moment later is exactly the race the pin exists to close.+"""++import asyncio+import ipaddress+import socket+import time+from dataclasses import dataclass+from typing import Optional, Union++from swap_proxy.swap import host_in_list++IPAddress = Union[ipaddress.IPv4Address, ipaddress.IPv6Address]+IPNetwork = Union[ipaddress.IPv4Network, ipaddress.IPv6Network]++# RFC 1918, loopback, link-local (cloud metadata lives there), CGNAT and other+# carrier space, 0.0.0.0/8, IETF assignments, benchmarking and reserved space,+# multicast, and ULA / link-local / multicast v6. ``64:ff9b:1::/48`` is NAT64's+# local-use prefix (RFC 8215): whatever it translates to is inside some network.+PRIVATE_NETS: tuple[IPNetwork, ...] = tuple(+ ipaddress.ip_network(c)+ for c in (+ "0.0.0.0/8",+ "10.0.0.0/8",+ "100.64.0.0/10",+ "127.0.0.0/8",+ "169.254.0.0/16",+ "172.16.0.0/12",+ "192.0.0.0/24",+ "192.168.0.0/16",+ "198.18.0.0/15",+ "224.0.0.0/4",+ "240.0.0.0/4",+ "::/96", # IPv4-compatible (deprecated): ::127.0.0.1, ::1 and :: too+ "::ffff:0:0:0/96", # SIIT's IPv4-translated: ::ffff:0:a9fe:a9fe+ "64:ff9b:1::/48",+ "fc00::/7",+ "fe80::/10",+ "fec0::/10", # site-local (deprecated, still routed by some stacks)+ "ff00::/8",+ )+)+# A v6 address in one of these reaches the v4 address in its low 32 bits+# (NAT64, RFC 6052) or in bits 16-48 (6to4, ``IPv6Address.sixtofour``), wherever+# a translator or relay exists. A DNS64 resolver synthesises the former for+# any v4-only name, the metadata server's included.+_NAT64 = ipaddress.IPv6Network("64:ff9b::/96")+_DNS_TTL = 60+_DNS_CACHE_MAX = 4096+++@dataclass(frozen=True)+class Verdict:+ """Where to connect, or why not. Exactly one of the two is set."""++ ip: Optional[str] = None+ refused: Optional[str] = None+ refused_ip: Optional[str] = None+++def normalize_ip(ip: str) -> Optional[IPAddress]:+ """Parse a literal, unwrapping IPv4-mapped IPv6: ``::ffff:127.0.0.1``+ reaches localhost and must be judged as 127.0.0.1."""+ try:+ addr = ipaddress.ip_address(ip.split("%")[0])+ except ValueError:+ return None+ mapped = getattr(addr, "ipv4_mapped", None)+ return mapped if mapped is not None else addr+++def embedded_ipv4(addr: IPAddress) -> Optional[ipaddress.IPv4Address]:+ """The v4 address a NAT64 or 6to4 address stands for, if it is one."""+ if not isinstance(addr, ipaddress.IPv6Address):+ return None+ if addr in _NAT64:+ return ipaddress.IPv4Address(int(addr) & 0xFFFFFFFF)+ return addr.sixtofour+++def is_private(addr: IPAddress) -> bool:+ """The address itself, and the v4 address it carries if it carries one: the+ v6 form is what gets dialled, the v4 one is where the bytes end up."""+ inner = embedded_ipv4(addr)+ if inner is not None and is_private(inner):+ return True+ return addr.is_unspecified or any(addr in net for net in PRIVATE_NETS)+++def parse_allow(entries: list[str]) -> tuple[list[str], list[IPNetwork]]:+ """Hostnames (exact or leading-dot) and CIDR or address literals."""+ hosts: list[str] = []+ nets: list[IPNetwork] = []+ for entry in entries:+ entry = entry.strip()+ if not entry:+ continue+ try:+ nets.append(ipaddress.ip_network(entry, strict=False))+ except ValueError:+ hosts.append(entry.lower())+ return hosts, nets+++class EgressGuard:+ """Default deny for private space; *allow* is for tests and for the rare+ internal host a deployment means its boxes to reach."""++ def __init__(self, allow: Optional[list[str]] = None):+ self.allow_hosts, self.allow_nets = parse_allow(allow or [])+ self._dns: dict[str, tuple[float, list[str]]] = {}++ async def check(self, host: str) -> Verdict:+ if ":" in host and normalize_ip(host) is None:+ # No name holds a ':', but a SOCKS5 domain can, and the allow-list+ # match (``host_in_list``) cuts at the first one:+ # ``allowed.example:.169.254.169.254.nip.io`` would pass as+ # ``allowed.example`` and resolve to the metadata address.+ return Verdict(refused="malformed-host")+ ips = await self._resolve(host)+ if not ips:+ return Verdict(refused="unresolvable")+ refused_ip = None+ for ip in ips:+ addr = normalize_ip(ip)+ if addr is None:+ continue+ if is_private(addr) and not self._allowed(host, addr):+ refused_ip = refused_ip or str(addr)+ continue+ return Verdict(ip=str(addr))+ return Verdict(refused="private-range", refused_ip=refused_ip)++ def _allowed(self, host: str, addr: IPAddress) -> bool:+ if host_in_list(host, self.allow_hosts):+ return True+ return any(addr in net for net in self.allow_nets)++ async def _resolve(self, host: str) -> Optional[list[str]]:+ """Through the loop's resolver: this runs on mitmproxy's event loop,+ and a slow lookup must not stall every other connection."""+ now = time.monotonic()+ cached = self._dns.get(host)+ if cached and cached[0] > now:+ return cached[1]+ try:+ infos = await asyncio.get_running_loop().getaddrinfo(+ host, None, type=socket.SOCK_STREAM+ )+ except (socket.gaierror, UnicodeError, OSError):+ # Refused, and not remembered: a resolver blip must not keep a+ # host out of reach for a whole TTL after it has recovered.+ self._dns.pop(host, None)+ return None+ # IPv4 first: pinning one address gives up the dialler's fallback from+ # an unroutable AAAA to the A record, and the networks this runs in+ # are more often v4-only than v6-only.+ ordered = sorted(infos, key=lambda info: info[0] != socket.AF_INET)+ ips = list(dict.fromkeys(str(info[4][0]) for info in ordered))+ if not ips:+ return None+ if len(self._dns) >= _DNS_CACHE_MAX:+ self._dns.clear() # only a latency optimisation+ self._dns[host] = (now + _DNS_TTL, ips)+ return ipsdiff --git a/autogpt_platform/swap_proxy/swap_proxy/egress_test.py b/autogpt_platform/swap_proxy/swap_proxy/egress_test.pynew file mode 100644index 0000000000..6427206afa--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/egress_test.py@@ -0,0 +1,161 @@+import asyncio+import socket++import pytest++from swap_proxy.egress import EgressGuard, is_private, normalize_ip+++def _resolving(guard: EgressGuard, answers: dict[str, list[str]]):+ async def resolve(host):+ return answers.get(host)++ guard._resolve = resolve # type: ignore[method-assign]+ return guard+++ "ip",+ [+ "10.1.2.3",+ "172.16.0.1",+ "192.168.1.1",+ "127.0.0.1",+ "169.254.169.254", # cloud metadata+ "100.64.0.1",+ "0.0.0.0",+ "::1",+ "fd00::1",+ "fe80::1%eth0",+ "::ffff:127.0.0.1", # IPv4-mapped: judged as the v4 address it reaches+ "::ffff:169.254.169.254",+ # A v4 address inside a public-looking v6 one: NAT64 and 6to4 reach it+ # wherever a translator or a relay exists.+ "64:ff9b::a9fe:a9fe", # 169.254.169.254+ "64:ff9b::10.0.0.5",+ "64:ff9b:1::a9fe:a9fe", # NAT64's local-use prefix+ "2002:a9fe:a9fe::", # 6to4 of 169.254.169.254+ "2002:7f00:1::1", # 6to4 of 127.0.0.1+ "fec0::1", # site-local+ "::127.0.0.1", # IPv4-compatible+ "::a9fe:a9fe",+ "::ffff:0:a9fe:a9fe", # SIIT IPv4-translated+ ],+)+def test_private_space(ip):+ addr = normalize_ip(ip)+ assert addr is not None and is_private(addr)+++ "ip",+ [+ "140.82.112.3",+ "8.8.8.8",+ "2606:50c0:8000::154",+ "64:ff9b::8c52:7003", # NAT64 of 140.82.112.3: public stays reachable+ "2002:8c52:7003::1", # 6to4 of the same+ ],+)+def test_public_space(ip):+ addr = normalize_ip(ip)+ assert addr is not None and not is_private(addr)+++async def test_a_public_answer_is_pinned():+ guard = _resolving(EgressGuard(), {"api.github.com": ["140.82.112.5"]})+ verdict = await guard.check("api.github.com")+ assert verdict.ip == "140.82.112.5" and verdict.refused is None+++async def test_a_private_answer_is_refused_with_the_address_for_the_audit():+ guard = _resolving(EgressGuard(), {"metadata.internal": ["169.254.169.254"]})+ verdict = await guard.check("metadata.internal")+ assert (verdict.ip, verdict.refused, verdict.refused_ip) == (+ None,+ "private-range",+ "169.254.169.254",+ )+++async def test_a_mixed_answer_connects_only_to_the_public_address():+ guard = _resolving(EgressGuard(), {"rebind.test": ["10.0.0.5", "93.184.216.34"]})+ assert (await guard.check("rebind.test")).ip == "93.184.216.34"+++async def test_a_name_that_does_not_resolve_is_refused():+ """Not waved through: mitmproxy would resolve it again by itself."""+ guard = _resolving(EgressGuard(), {})+ assert (await guard.check("nowhere.test")).refused == "unresolvable"+++async def test_allow_by_host_and_by_network():+ answers = {"db.internal": ["10.0.0.9"], "other.internal": ["10.0.0.10"]}+ by_host = _resolving(EgressGuard(["db.internal"]), answers)+ assert (await by_host.check("db.internal")).ip == "10.0.0.9"+ assert (await by_host.check("other.internal")).refused == "private-range"+ by_net = _resolving(EgressGuard(["10.0.0.8/30"]), answers)+ assert (await by_net.check("db.internal")).ip == "10.0.0.9"+ assert (await by_net.check("other.internal")).ip == "10.0.0.10"+++async def test_literals_resolve_to_themselves_and_ipv4_comes_first(monkeypatch):+ guard = EgressGuard(["127.0.0.0/8", "::1"])+ assert (await guard.check("127.0.0.1")).ip == "127.0.0.1"++ async def both(host, port, **kwargs):+ return [+ (socket.AF_INET6, socket.SOCK_STREAM, 6, "", ("::1", 0, 0, 0)),+ (socket.AF_INET, socket.SOCK_STREAM, 6, "", ("127.0.0.1", 0)),+ ]++ monkeypatch.setattr(asyncio.get_running_loop(), "getaddrinfo", both)+ assert (await EgressGuard(["127.0.0.0/8", "::1"]).check("dual.test")).ip == (+ "127.0.0.1"+ )+++async def test_a_nat64_answer_for_the_metadata_server_is_refused():+ """What a DNS64 resolver would synthesise for a v4-only name."""+ guard = _resolving(EgressGuard(), {"metadata.internal": ["64:ff9b::a9fe:a9fe"]})+ verdict = await guard.check("metadata.internal")+ assert (verdict.ip, verdict.refused) == (None, "private-range")+ # A public v4 address behind the same prefix is dialled in its v6 form.+ guard = _resolving(EgressGuard(), {"api.github.com": ["64:ff9b::8c52:7003"]})+ assert (await guard.check("api.github.com")).ip == "64:ff9b::8c52:7003"+++async def test_a_failed_lookup_is_not_remembered(monkeypatch):+ calls = 0++ async def flaky(host, port, **kwargs):+ nonlocal calls+ calls += 1+ if calls == 1:+ raise socket.gaierror("temporary failure in name resolution")+ return [(socket.AF_INET, socket.SOCK_STREAM, 6, "", ("140.82.112.5", 0))]++ monkeypatch.setattr(asyncio.get_running_loop(), "getaddrinfo", flaky)+ guard = EgressGuard()+ assert (await guard.check("api.github.com")).refused == "unresolvable"+ # Recovered a moment later: asked again, not answered from the failure.+ assert (await guard.check("api.github.com")).ip == "140.82.112.5"+ # A good answer is what gets remembered.+ assert (await guard.check("api.github.com")).ip == "140.82.112.5"+ assert calls == 2+++ "host",+ ["db.internal:.169.254.169.254.nip.io", "db.internal:443", ":db.internal"],+)+async def test_a_name_with_a_colon_is_refused_before_the_allow_list_sees_it(host):+ """``host_in_list`` cuts at the first ':', so this would have matched the+ allowed name and gone wherever the rest of it resolves."""+ guard = _resolving(EgressGuard(["db.internal"]), {host: ["169.254.169.254"]})+ assert (await guard.check(host)).refused == "malformed-host"+++async def test_an_ipv6_literal_is_not_a_name_with_a_colon():+ guard = EgressGuard(["::1"])+ assert (await guard.check("::1")).ip == "::1"diff --git a/autogpt_platform/swap_proxy/swap_proxy/main_test.py b/autogpt_platform/swap_proxy/swap_proxy/main_test.pynew file mode 100644index 0000000000..9d1939041e--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/main_test.py@@ -0,0 +1,41 @@+import logging+import os++import pytest++from swap_proxy.__main__ import CA_FILE, DHPARAM_FILE, MissingCA, require_ca+++def test_without_a_provisioned_ca_the_service_does_not_start(tmp_path):+ """mitmproxy would generate one, different on every replica and restart."""+ with pytest.raises(MissingCA, match="SWAP_PROXY_CONFDIR"):+ require_ca(str(tmp_path), generate=False)+++def test_a_mounted_ca_is_accepted(tmp_path):+ (tmp_path / CA_FILE).write_text("-----BEGIN PRIVATE KEY-----")+ require_ca(str(tmp_path), generate=False)+++def test_a_read_only_mount_needs_the_dhparam_file_beside_the_ca(tmp_path):+ """mitmproxy writes it when it is missing, and would crash on the write."""+ (tmp_path / CA_FILE).write_text("-----BEGIN PRIVATE KEY-----")+ tmp_path.chmod(0o555)+ if os.access(tmp_path, os.W_OK): # root ignores the mode+ tmp_path.chmod(0o755)+ return+ try:+ with pytest.raises(MissingCA, match=DHPARAM_FILE):+ require_ca(str(tmp_path), generate=False)+ tmp_path.chmod(0o755)+ (tmp_path / DHPARAM_FILE).write_text("-----BEGIN DH PARAMETERS-----")+ tmp_path.chmod(0o555)+ require_ca(str(tmp_path), generate=False)+ finally:+ tmp_path.chmod(0o755)+++def test_a_local_run_may_ask_for_a_generated_one(tmp_path, caplog):+ with caplog.at_level(logging.WARNING, logger="swap_proxy.__main__"):+ require_ca(str(tmp_path), generate=True)+ assert "Local use only" in caplog.textdiff --git a/autogpt_platform/swap_proxy/swap_proxy/owners.py b/autogpt_platform/swap_proxy/swap_proxy/owners.pynew file mode 100644index 0000000000..6aae18a23c--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/owners.py@@ -0,0 +1,84 @@+"""Whose connection this is: the tenant boundary.++The backend mints a proxy credential for each running stretch of a box and+records it in Redis (``backend/util/e2b_network.py``): the username is the+key, the record names the owner and the user, and holds a SHA-256 digest of+the secret, never the secret. E2B's host presents the pair in the SOCKS5+handshake; nothing inside the box ever holds it.++So a connection is some owner's only if its username resolves *and* its+secret hashes to the recorded digest. Anything else is refused before a+single byte is relayed. A box cannot claim another owner: it would need that+owner's current 256-bit secret.+"""++import hashlib+import hmac+import json+import logging+import re+from collections.abc import Awaitable+from dataclasses import dataclass+from typing import Any, Optional, Protocol++logger = logging.getLogger(__name__)++CREDENTIAL_KEY_PREFIX = "e2b:egress:cred:"+# What the backend mints. Checked before the lookup so that arbitrary bytes+# from the internet never become a Redis key.+_USERNAME_RE = re.compile(r"box-[0-9a-f]{16}")+++@dataclass(frozen=True)+class Owner:+ """*user_id* is who the box runs for, and is always audited. Their+ credentials are swapped in only if the backend said so (*swaps*): it does+ for CoPilot boxes, not for a block running a graph someone else wrote."""++ label: str+ user_id: Optional[str]+ sandbox_id: Optional[str]+ swaps: bool = False++ @property+ def swap_user_id(self) -> Optional[str]:+ return self.user_id if self.swaps else None+++class RedisReader(Protocol):+ def get(self, name: str) -> Awaitable[Any]: ...+++class OwnerDirectory:+ def __init__(self, redis: RedisReader):+ self._redis = redis++ async def authenticate(self, username: str, secret: str) -> Optional[Owner]:+ # fullmatch: ``$`` would let a trailing newline through.+ if not _USERNAME_RE.fullmatch(username) or not secret:+ return None+ try:+ raw = await self._redis.get(CREDENTIAL_KEY_PREFIX + username)+ except Exception:+ # Fail closed: a connection nobody can vouch for is not relayed.+ logger.exception("Owner lookup failed; refusing the connection")+ return None+ if not raw:+ return None+ try:+ record = json.loads(raw.decode() if isinstance(raw, bytes) else raw)+ expected = str(record["secret_sha256"])+ label = str(record["owner"])+ except (ValueError, KeyError, TypeError):+ logger.warning("Malformed credential record for %s", username)+ return None+ presented = hashlib.sha256(secret.encode()).hexdigest()+ if not hmac.compare_digest(presented, expected):+ return None+ return Owner(+ label=label,+ user_id=record.get("user_id") or None,+ sandbox_id=record.get("sandbox_id") or None,+ # Fail closed: only an explicit true.+ swaps=record.get("swaps") is True,+ )diff --git a/autogpt_platform/swap_proxy/swap_proxy/owners_test.py b/autogpt_platform/swap_proxy/swap_proxy/owners_test.pynew file mode 100644index 0000000000..61774f1a13--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/owners_test.py@@ -0,0 +1,136 @@+"""The tenant boundary on its own: every way ``authenticate`` says no, and+what a record that says nothing about swapping is taken to mean."""++import hashlib+import json+import logging+from typing import Any++import pytest++from swap_proxy.owners import CREDENTIAL_KEY_PREFIX, Owner, OwnerDirectory++USERNAME = "box-" + "a" * 16+SECRET = "secret-a"+++def record(**overrides: Any) -> str:+ fields = {+ "owner": "session:s-a",+ "user_id": "user-a",+ "sandbox_id": "sb-1",+ "swaps": True,+ "secret_sha256": hashlib.sha256(SECRET.encode()).hexdigest(),+ }+ fields.update(overrides)+ return json.dumps({k: v for k, v in fields.items() if v is not ...})+++class Reader:+ def __init__(self, raw: Any = None, error: Exception | None = None):+ self.raw, self.error = raw, error+ self.asked: list[str] = []++ async def get(self, name: str):+ self.asked.append(name)+ if self.error:+ raise self.error+ return self.raw+++async def authenticate(raw: Any, username: str = USERNAME, secret: str = SECRET):+ return await OwnerDirectory(Reader(raw)).authenticate(username, secret)+++async def test_the_right_secret_for_a_minted_username_is_its_owner():+ reader = Reader(record())+ owner = await OwnerDirectory(reader).authenticate(USERNAME, SECRET)+ assert owner == Owner("session:s-a", "user-a", "sb-1", swaps=True)+ assert owner is not None and owner.swap_user_id == "user-a"+ assert reader.asked == [CREDENTIAL_KEY_PREFIX + USERNAME]+++async def test_a_record_stored_as_bytes_reads_the_same():+ owner = await authenticate(record().encode())+ assert owner is not None and owner.label == "session:s-a"+++ "username, secret",+ [+ ("box-" + "A" * 16, SECRET), # not the shape the backend mints+ ("box-" + "a" * 15, SECRET),+ (USERNAME + "\n", SECRET),+ (CREDENTIAL_KEY_PREFIX + USERNAME, SECRET),+ ("", SECRET),+ (USERNAME, ""),+ ],+)+async def test_a_malformed_pair_is_refused_without_touching_redis(username, secret):+ reader = Reader(record())+ assert await OwnerDirectory(reader).authenticate(username, secret) is None+ assert reader.asked == []+++async def test_a_redis_that_cannot_be_asked_refuses_the_connection(caplog):+ directory = OwnerDirectory(Reader(error=ConnectionError("redis is down")))+ with caplog.at_level(logging.ERROR, logger="swap_proxy.owners"):+ assert await directory.authenticate(USERNAME, SECRET) is None+ assert "refusing the connection" in caplog.text++[email protected]("raw", [None, "", b""])+async def test_a_username_nobody_minted_is_refused(raw):+ assert await authenticate(raw) is None+++ "raw",+ [+ "not json",+ "[]",+ '"a string"',+ "null",+ record(secret_sha256=...),+ record(owner=...),+ ],+ ids=["not json", "a list", "a string", "null", "no digest", "no owner"],+)+async def test_a_malformed_record_is_refused(raw, caplog):+ with caplog.at_level(logging.WARNING, logger="swap_proxy.owners"):+ assert await authenticate(raw) is None+ assert "Malformed credential record" in caplog.text+ assert SECRET not in caplog.text++[email protected]("secret", ["wrong", SECRET + "x", SECRET.upper()])+async def test_the_wrong_secret_is_refused(secret):+ assert await authenticate(record(), secret=secret) is None+++async def test_a_secret_is_not_its_own_digest():+ """Whoever reads the record from Redis holds the digest, not the secret."""+ digest = hashlib.sha256(SECRET.encode()).hexdigest()+ assert await authenticate(record(), secret=digest) is None+++async def test_a_record_without_swaps_swaps_nothing():+ """What the base PR's ``_remember`` wrote before the field existed: during+ a rolling deploy the proxy meets such records, and must not swap for them."""+ owner = await authenticate(record(swaps=...))+ assert owner is not None and owner.user_id == "user-a"+ assert owner.swaps is False and owner.swap_user_id is None++[email protected]("swaps", [False, None, "true", 1, "yes", [True]])+async def test_only_an_explicit_true_swaps(swaps):+ owner = await authenticate(record(swaps=swaps))+ assert owner is not None+ assert owner.swaps is False and owner.swap_user_id is None+++async def test_an_owner_without_a_user_has_nobody_to_swap_for():+ owner = await authenticate(record(user_id=None, sandbox_id=""))+ assert owner is not None and owner.swaps is True+ assert owner.user_id is None and owner.sandbox_id is None+ assert owner.swap_user_id is Nonediff --git a/autogpt_platform/swap_proxy/swap_proxy/settings.py b/autogpt_platform/swap_proxy/swap_proxy/settings.pynew file mode 100644index 0000000000..6b952f4adb--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/settings.py@@ -0,0 +1,59 @@+"""Configuration, all from the environment.++Redis uses the backend's own variable names so that a deployment hands both+the same values.+"""++import os+from dataclasses import dataclass, field+++def _flag(name: str) -> bool:+ return os.getenv(name, "").lower() in ("1", "true", "yes")+++def _list(name: str) -> list[str]:+ return [e.strip() for e in os.getenv(name, "").split(",") if e.strip()]+++@dataclass(frozen=True)+class Settings:+ listen_host: str = field(+ default_factory=lambda: os.getenv("SWAP_PROXY_LISTEN_HOST", "0.0.0.0")+ )+ listen_port: int = field(+ default_factory=lambda: int(os.getenv("SWAP_PROXY_LISTEN_PORT", "1080"))+ )+ # The backend's internal service (DatabaseManager), e.g. http://host:8005+ backend_url: str = field(+ default_factory=lambda: os.getenv(+ "SWAP_PROXY_BACKEND_URL", "http://localhost:8005"+ )+ )+ # Where the CA the proxy signs with is mounted (``mitmproxy-ca.pem``: key+ # and certificate). The boxes' image trusts its certificate, so it is one+ # CA for every replica and every restart: provisioned, never generated.+ confdir: str = field(+ default_factory=lambda: os.getenv("SWAP_PROXY_CONFDIR", "~/.mitmproxy")+ )+ # Local runs only: let mitmproxy make up a CA when none is there.+ generate_ca: bool = field(default_factory=lambda: _flag("SWAP_PROXY_GENERATE_CA"))+ # Private hosts or CIDRs boxes may reach anyway. Empty: default deny.+ egress_allow: list[str] = field(+ default_factory=lambda: _list("SWAP_PROXY_EGRESS_ALLOW")+ )+ redis_host: str = field(+ default_factory=lambda: os.getenv("REDIS_CLUSTER_HOST")+ or os.getenv("REDIS_HOST", "localhost")+ )+ redis_port: int = field(+ default_factory=lambda: int(+ os.getenv("REDIS_CLUSTER_PORT") or os.getenv("REDIS_PORT", "6379")+ )+ )+ redis_password: str | None = field(+ default_factory=lambda: os.getenv("REDIS_PASSWORD") or None+ )+ redis_use_announced_address: bool = field(+ default_factory=lambda: _flag("REDIS_USE_ANNOUNCED_ADDRESS")+ )diff --git a/autogpt_platform/swap_proxy/swap_proxy/source.py b/autogpt_platform/swap_proxy/swap_proxy/source.pynew file mode 100644index 0000000000..a7558ece31--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/source.py@@ -0,0 +1,118 @@+"""Where credentials come from: the backend, asked at swap time.++The proxy holds no database access and no encryption key. It asks the+backend's internal service two things (``backend/copilot/swap_credentials.py``):+which hosts any credential is bound to, with no values, and one user's+credential for one host. The backend does the lookup, the OAuth refresh and+the binding check; what arrives here is only what the request in hand needs.++Both answers are cached briefly. The backend already invalidates its own+token cache across processes, so the few seconds here are a burst damper (one+``git push`` is many requests), not a second source of truth: a rotated or+revoked credential is gone from the proxy within ``_CREDENTIAL_TTL``.++Anything but a clean answer means no swap. The placeholder goes out as it is+and the request fails at the provider: loudly, and with nothing leaked.+"""++import logging+import time+from typing import Optional, Protocol++import httpx++from swap_proxy.swap import Credential, host_in_list++logger = logging.getLogger(__name__)++_BINDINGS_TTL = 300.0+# After a failed refresh the previous table is kept this long before the+# backend is asked again: each attempt can take the whole timeout, and asking+# on every lookup would add it to every request for as long as the outage lasts.+_BINDINGS_RETRY = 30.0+_CREDENTIAL_TTL = 15.0+_CACHE_MAX = 10_000+_TIMEOUT = httpx.Timeout(10.0, connect=3.0)+++class SourceUnavailable(Exception):+ """The backend could not be asked; the caller must not swap."""+++class CredentialSource(Protocol):+ async def bound_names(self, host: str) -> set[str]: ...++ async def resolve(+ self, user_id: str, name: str, host: str+ ) -> Optional[Credential]: ...+++class BackendCredentialSource:+ def __init__(self, base_url: str, client: Optional[httpx.AsyncClient] = None):+ self._base_url = base_url.rstrip("/")+ self._client = client or httpx.AsyncClient(timeout=_TIMEOUT)+ self._bindings: Optional[tuple[float, dict[str, tuple[str, ...]]]] = None+ self._credentials: dict[+ tuple[str, str, str], tuple[float, Optional[Credential]]+ ] = {}++ async def bindings(self) -> dict[str, tuple[str, ...]]:+ now = time.monotonic()+ if self._bindings and self._bindings[0] > now:+ return self._bindings[1]+ try:+ data = await self._call("get_swap_bindings", {})+ fresh = {str(n): tuple(str(h) for h in hosts) for n, hosts in data.items()}+ except (SourceUnavailable, AttributeError, TypeError):+ if self._bindings:+ # Bindings are a static table; a stale copy beats treating+ # every host as unbound while the backend restarts.+ logger.warning("Bindings refresh failed; keeping the previous table")+ self._bindings = (now + _BINDINGS_RETRY, self._bindings[1])+ return self._bindings[1]+ raise SourceUnavailable("bindings") from None+ self._bindings = (now + _BINDINGS_TTL, fresh)+ return fresh++ async def bound_names(self, host: str) -> set[str]:+ """The credentials that may ever be sent to *host*."""+ table = await self.bindings()+ return {name for name, hosts in table.items() if host_in_list(host, hosts)}++ async def resolve(self, user_id: str, name: str, host: str) -> Optional[Credential]:+ key = (user_id, name, host.lower())+ now = time.monotonic()+ cached = self._credentials.get(key)+ if cached and cached[0] > now:+ return cached[1]+ data = await self._call(+ "resolve_swap_credential",+ {"user_id": user_id, "name": name, "host": host},+ )+ credential = None+ if data is not None:+ try:+ credential = Credential(+ name=str(data["name"]),+ values={str(k): str(v) for k, v in data["values"].items()},+ allowed_hosts=tuple(str(h) for h in data["allowed_hosts"]),+ )+ except (KeyError, AttributeError, TypeError):+ raise SourceUnavailable("malformed credential") from None+ if len(self._credentials) >= _CACHE_MAX:+ self._credentials.clear()+ self._credentials[key] = (now + _CREDENTIAL_TTL, credential)+ return credential++ async def _call(self, method: str, body: dict):+ try:+ response = await self._client.post(f"{self._base_url}/{method}", json=body)+ response.raise_for_status()+ return response.json()+ except (httpx.HTTPError, ValueError) as e:+ # The exception's text can carry the URL, never a value.+ logger.warning("Backend call %s failed: %s", method, type(e).__name__)+ raise SourceUnavailable(method) from None++ async def aclose(self) -> None:+ await self._client.aclose()diff --git a/autogpt_platform/swap_proxy/swap_proxy/source_test.py b/autogpt_platform/swap_proxy/swap_proxy/source_test.pynew file mode 100644index 0000000000..7caf3875ac--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/source_test.py@@ -0,0 +1,141 @@+import json++import httpx+import pytest++from swap_proxy import source as source_module+from swap_proxy.source import BackendCredentialSource, SourceUnavailable++TOKEN = "ghp_a-real-looking-token"+++def _backend(handler):+ calls: list[tuple[str, dict]] = []++ def transport(request: httpx.Request) -> httpx.Response:+ body = json.loads(request.content or b"{}")+ calls.append((request.url.path, body))+ return handler(request.url.path, body)++ client = httpx.AsyncClient(transport=httpx.MockTransport(transport))+ return BackendCredentialSource("http://backend:8005/", client), calls+++def _ok(path, body):+ if path == "/get_swap_bindings":+ return httpx.Response(200, json={"github": ["github.com", "api.github.com"]})+ if body["user_id"] != "user-a":+ return httpx.Response(200, content=b"null") # what FastAPI sends for None+ return httpx.Response(+ 200,+ json={+ "name": "github",+ "values": {"access_token": TOKEN},+ "allowed_hosts": ["github.com", "api.github.com"],+ },+ )+++async def test_bound_names_come_from_the_bindings_table_asked_once():+ source, calls = _backend(_ok)+ assert await source.bound_names("api.github.com") == {"github"}+ assert await source.bound_names("API.GitHub.com:443") == {"github"}+ assert await source.bound_names("example.com") == set()+ assert [path for path, _ in calls] == ["/get_swap_bindings"]+++async def test_resolve_names_the_user_and_the_host_and_is_cached_briefly():+ source, calls = _backend(_ok)+ credential = None+ for _ in range(3):+ credential = await source.resolve("user-a", "github", "api.github.com")+ assert credential is not None+ assert credential.values == {"access_token": TOKEN}+ assert credential.allowed_hosts == ("github.com", "api.github.com")+ assert calls == [+ (+ "/resolve_swap_credential",+ {"user_id": "user-a", "name": "github", "host": "api.github.com"},+ )+ ]+++async def test_one_users_answer_is_never_anothers():+ source, _ = _backend(_ok)+ assert await source.resolve("user-a", "github", "api.github.com") is not None+ assert await source.resolve("user-b", "github", "api.github.com") is None+++async def test_the_cache_expires(monkeypatch):+ source, calls = _backend(_ok)+ now = [1000.0]+ monkeypatch.setattr(source_module.time, "monotonic", lambda: now[0])+ await source.resolve("user-a", "github", "api.github.com")+ now[0] += source_module._CREDENTIAL_TTL + 1+ await source.resolve("user-a", "github", "api.github.com")+ assert len(calls) == 2+++ "response",+ [+ httpx.Response(500, json={"type": "RuntimeError"}),+ httpx.Response(200, content=b"not json"),+ httpx.Response(200, json={"name": "github"}), # no values+ ],+)+async def test_anything_but_a_clean_answer_is_unavailable_and_not_cached(response):+ source, calls = _backend(lambda path, body: response)+ for _ in range(2):+ with pytest.raises(SourceUnavailable):+ await source.resolve("user-a", "github", "api.github.com")+ assert len(calls) == 2+++async def test_a_failed_bindings_refresh_keeps_the_previous_table(monkeypatch):+ healthy = [True]++ def handler(path, body):+ return _ok(path, body) if healthy[0] else httpx.Response(503)++ source, _ = _backend(handler)+ now = [1000.0]+ monkeypatch.setattr(source_module.time, "monotonic", lambda: now[0])+ assert await source.bound_names("github.com") == {"github"}+ healthy[0] = False+ now[0] += source_module._BINDINGS_TTL + 1+ assert await source.bound_names("github.com") == {"github"}+++async def test_after_a_failed_refresh_the_backend_is_not_asked_on_every_lookup(+ monkeypatch,+):+ """Each attempt can take the whole timeout; during an outage that would+ be added to every request."""+ healthy = [True]++ def handler(path, body):+ return _ok(path, body) if healthy[0] else httpx.Response(503)++ source, calls = _backend(handler)+ now = [1000.0]+ monkeypatch.setattr(source_module.time, "monotonic", lambda: now[0])+ await source.bound_names("github.com")+ healthy[0] = False+ now[0] += source_module._BINDINGS_TTL + 1+ for _ in range(5):+ assert await source.bound_names("github.com") == {"github"}+ assert len(calls) == 2 # the first table, one failed refresh+ # Asked again once the retry interval has passed, and back on a good answer.+ healthy[0] = True+ now[0] += source_module._BINDINGS_RETRY + 1+ assert await source.bound_names("github.com") == {"github"}+ assert len(calls) == 3+ await source.bound_names("github.com")+ assert len(calls) == 3+++async def test_no_table_at_all_is_unavailable():+ source, _ = _backend(lambda path, body: httpx.Response(503))+ with pytest.raises(SourceUnavailable):+ await source.bound_names("github.com")diff --git a/autogpt_platform/swap_proxy/swap_proxy/swap.py b/autogpt_platform/swap_proxy/swap_proxy/swap.pynew file mode 100644index 0000000000..4d99690195--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/swap.py@@ -0,0 +1,497 @@+"""The swap itself: placeholders in a request become real values on the way out.++Ported from ``proxy/swap_addon.py`` in spark-vm, where it went through eight+review rounds; the rules below are that review's, kept as they were. What+changed is only where credentials come from: there a secrets directory and a+registry file, here a set of ``Credential`` objects handed in per request, so+this module is pure and knows nothing of owners, Redis or the backend.++A placeholder is ``hsurr:<name>`` or ``hsurr:<name>:<entry>``; with no entry+it means ``access_token``. It is replaced only when the credential is bound+to the request's host, and within that to its method and path if the+credential limits them. A credential with no host binding never swaps.++Where it swaps. By default in the ``Authorization`` header only, which is+where ``git`` (HTTP Basic, also for a token in the URL: git and curl turn URL+userinfo into that header, it never goes on the wire as part of the URL),+``gh`` (``token ...``) and ``curl -H`` / ``curl -u`` put a token. A+placeholder anywhere else (another header, the path, the query, a body, a+websocket message) goes out literally and is audited as ``refused`` /+``outside-authorization``. The reason is what a provider does with a request+body: a write-capable credential swapped into one can be stored there (a+gist, an issue, a blob) and read back later in any encoding the provider+offers (base64, hex, a git packfile), which no scrub of the response can+match. A value in the ``Authorization`` header is used, not stored.++A credential that sets ``swap_anywhere`` (spark-vm's behaviour, and what the+rules below were written for) is swapped everywhere the swap looks, and how+the value is protected in each place:++- Headers. ``Authorization: Basic`` is base64-decoded first (git and+ ``curl -u`` hide the placeholder inside it). ``Referer`` and ``Origin`` are+ never touched: a swapped one would hand the value to the server's access log+ on every later request. ``Cookie`` only for a credential that says so, and+ then without ``swap_anywhere`` too.+- Query string, per value, re-encoded.+- Path, per segment. A segment whose decoded form did not change stays+ byte-identical, so existing escapes survive and a value cannot leave its+ segment.+- Body, by content type: JSON values are JSON-escaped, form fields are parsed+ and re-encoded (browser-encoded ``hsurr%3A`` included), other text is+ substituted plainly. Binary bodies are left alone.++An entry named ``totp`` holds a base32 seed; the swap inserts the current+RFC 6238 code, never the seed.++Responses from a bound host are scrubbed: a known value in a text body is+replaced by its placeholder, so a page or API that echoes the key cannot hand+it back to the model through a text or screenshot read. Values under eight+characters are never scrubbed (a one-character value would mangle the page);+TOTP codes only as whole tokens. Images and binary bodies are a stated+residual, not a solved one.++Nothing here ever logs or returns a value: events carry names and reasons.++Not reachable in this deployment yet: ``swap_anywhere``, ``allowed_methods``,+``allowed_paths``, ``cookie``, ``no_scrub`` and TOTP entries. The only+producer of a ``Credential`` (``source.py``) fills in a name, its values and+its hosts, so the swap outside ``Authorization``, the method and path limits,+the Cookie rule and the TOTP path keep their defaults. They are ported and tested as they were and start to matter when+bindings become per-user (SECRT-2616, SECRT-2618).+"""++import base64+import binascii+import hashlib+import hmac+import json+import posixpath+import re+import struct+import time+import urllib.parse+from collections.abc import Callable, Iterable, Mapping+from dataclasses import dataclass, field+from typing import Any, Literal, Optional++DEFAULT_ENTRY = "access_token"+TOTP_ENTRY = "totp"+PLACEHOLDER_RE = re.compile(r"hsurr:([A-Za-z0-9_-]+)(?::([A-Za-z0-9_-]+))?")+# As sent in application/x-www-form-urlencoded bodies (browsers encode ':').+ENCODED_PLACEHOLDER_RE = re.compile(+ r"hsurr%3A([A-Za-z0-9_-]+)(?:%3A([A-Za-z0-9_-]+))?", re.IGNORECASE+)+NEVER_SWAP_HEADERS = frozenset({"referer", "origin"})+ECHOING_METHODS = frozenset({"TRACE", "TRACK"})+MIN_SCRUB_LEN = 8+_SCRUBBABLE_TYPES = (+ "text/",+ "application/json",+ "application/javascript",+ "application/xml",+ "application/x-www-form-urlencoded",+)+++@dataclass(frozen=True)+class Credential:+ """One credential of the connection's owner, as the swap needs it.++ *allowed_methods* and *allowed_paths* are static limits within the bound+ hosts: ``None`` means unrestricted, an empty tuple fails closed.+ *swap_anywhere* lets the value go outside the ``Authorization`` header+ (see the module docstring for why that is off); it arrives with the+ binding table (SECRT-2616), and nothing sets it yet.+ """++ name: str+ values: Mapping[str, str]+ allowed_hosts: tuple[str, ...]+ allowed_methods: Optional[tuple[str, ...]] = None+ allowed_paths: Optional[tuple[str, ...]] = None+ cookie: bool = False+ no_scrub: frozenset[str] = frozenset()+ swap_anywhere: bool = False++ def __repr__(self) -> str: # a value must not reach a log through repr+ return f"Credential(name={self.name!r}, entries={sorted(self.values)})"+++@dataclass(frozen=True)+class SwapEvent:+ """One audit fact: a placeholder that was swapped, or refused and why."""++ kind: Literal["swapped", "refused"]+ placeholder: str+ reason: str = ""+++def host_in_list(host: Optional[str], entries: Iterable[str]) -> bool:+ """Exact names, or leading-dot entries for a domain's subdomains."""+ h = (host or "").lower().split(":")[0]+ for entry in entries:+ e = str(entry).lower()+ if h == e or (e.startswith(".") and h.endswith(e)):+ return True+ return False+++def totp_code(seed: str, at: Optional[float] = None) -> str:+ """Current RFC 6238 code for a base32 seed: six digits, 30 s step, SHA-1."""+ s = seed.strip()+ key = base64.b32decode(s.upper() + "=" * (-len(s) % 8))+ counter = struct.pack(">Q", int(time.time() if at is None else at) // 30)+ digest = hmac.new(key, counter, hashlib.sha1).digest()+ offset = digest[-1] & 0x0F+ code = struct.unpack(">I", digest[offset : offset + 4])[0] & 0x7FFFFFFF+ return str(code % 1_000_000).zfill(6)+++def normalize_path(raw: str) -> str:+ """Percent-decode to a fixpoint, then resolve dot segments.++ ``/repos/../admin`` must not pass a ``/repos/`` prefix, ``%2e%2e`` must not+ smuggle dot segments past the check, and ``%252e%252e`` must not survive as+ ``%2e%2e`` for a server that decodes twice.+ """+ try:+ p = urllib.parse.urlsplit(raw).path+ except ValueError:+ p = raw or ""+ prev = None+ while p != prev:+ prev, p = p, urllib.parse.unquote(p)+ if not p.startswith("/"):+ p = "/" + p+ return posixpath.normpath(p) or "/"+++def path_allowed(norm_path: str, prefixes: Iterable[str]) -> bool:+ """Segment-aligned: ``/repos/`` matches ``/repos/x``, not ``/repository``."""+ for prefix in prefixes:+ pp = normalize_path(str(prefix))+ if norm_path == pp or norm_path.startswith(pp.rstrip("/") + "/"):+ return True+ return False+++def basic_decoded(value: str) -> Optional[str]:+ """``user:password`` out of an HTTP Basic header, or ``None`` if it is not one."""+ scheme, _, b64 = value.partition(" ")+ if scheme.lower() != "basic" or not b64.strip():+ return None+ try:+ return base64.b64decode(b64.strip(), validate=True).decode("utf-8")+ except (binascii.Error, ValueError, UnicodeDecodeError):+ return None+++def placeholder_names(+ request: Any, *, head: bool = True, body: bool = True+) -> set[str]:+ """Every credential name a request mentions, wherever a swap would look.++ Run before the swap so that only those credentials are fetched. It looks+ inside Basic auth, the percent-encoded form and the path too: the same+ places the swap does, so nothing it would swap goes unfetched. *head* is+ the request line and the headers, *body* the content.+ """+ chunks: list[str] = []+ if head:+ for key in request.headers.keys():+ for value in request.headers.get_all(key):+ chunks.append(value)+ if key.lower() == "authorization":+ decoded = basic_decoded(value)+ if decoded:+ chunks.append(decoded)+ chunks.append(request.path)+ chunks.append(urllib.parse.unquote(request.path))+ if body and request.content:+ chunks.append(request.content.decode("utf-8", "ignore"))+ blob = "\n".join(chunks)+ names = {m.group(1) for m in PLACEHOLDER_RE.finditer(blob)}+ names |= {m.group(1) for m in ENCODED_PLACEHOLDER_RE.finditer(blob)}+ return names+++@dataclass+class RequestSwap:+ """The swap for one request, against the owner's credentials for it."""++ credentials: Mapping[str, Credential]+ host: str+ method: Optional[str] = None+ path: Optional[str] = None+ events: list[SwapEvent] = field(default_factory=list)+ # ``(swapped, original)`` base64 of every HTTP Basic pair swapped: what a+ # server that echoes the header sends back, which no value matches.+ encoded: list[tuple[str, str]] = field(default_factory=list)++ def allows(self, credential: Credential) -> tuple[bool, str]:+ """Host binding first, then the credential's method and path limits."""+ if not host_in_list(self.host, credential.allowed_hosts):+ return False, "unbound-host"+ method = (self.method or "").upper()+ if method in ECHOING_METHODS:+ # The response is the request, Authorization and all, as+ # ``message/http``, which is not a text type the scrub reads.+ return False, "echoing-method"+ if credential.allowed_methods is not None:+ if method not in {m.upper() for m in credential.allowed_methods}:+ return False, "method-not-allowed"+ if credential.allowed_paths is not None:+ if self.path is None or method == "CONNECT":+ # Nothing to check the path against: inside a tunnel or a+ # websocket message a path-bound credential never swaps.+ return False, "path-not-verifiable"+ norm = normalize_path(self.path)+ if "%" in norm or ";" in norm or "\\" in norm:+ # After fixpoint decoding these are only smuggling shapes for+ # lenient servers: double-decode residue, path parameters,+ # backslash separators.+ return False, "path-not-allowed"+ if not path_allowed(norm, credential.allowed_paths):+ return False, "path-not-allowed"+ return True, ""++ def resolve(+ self, name: str, entry: str, *, outside_authorization: bool = True+ ) -> Optional[str]:+ """The value for a placeholder, or ``None`` to leave it as it is."""+ credential = self.credentials.get(name)+ if credential is None:+ return None+ ok, reason = self.allows(credential)+ if not ok:+ self._refuse(name, reason)+ return None+ if outside_authorization and not credential.swap_anywhere:+ self._refuse(name, "outside-authorization")+ return None+ if entry == TOTP_ENTRY:+ seed = credential.values.get(TOTP_ENTRY)+ if seed is None:+ return None+ try:+ return totp_code(seed)+ except (ValueError, binascii.Error):+ self._refuse(name, "bad-totp-seed")+ return None+ value = credential.values.get(entry)+ if value is None:+ # hsurr:github:8080 keeps its :8080; an unknown entry is not a+ # reason to swap the name alone.+ self._refuse(name, "unknown-entry")+ return value++ def _refuse(self, name: str, reason: str) -> None:+ event = SwapEvent("refused", f"hsurr:{name}", reason)+ if event not in self.events:+ self.events.append(event)++ def text(+ self,+ text: str,+ *,+ encode: Optional[Callable[[str], str]] = None,+ only: Optional[set[str]] = None,+ outside_authorization: bool = True,+ ) -> str:+ """Substitute placeholders; *encode* is applied to each value only,+ *only* limits which credentials may swap (the Cookie rule). Outside+ the ``Authorization`` header (the default) only a credential with+ ``swap_anywhere`` swaps."""++ def repl(m: re.Match[str]) -> str:+ name, entry = m.group(1), m.group(2) or DEFAULT_ENTRY+ if only is not None and name not in only:+ if name in self.credentials:+ self._refuse(name, "cookie-not-allowed")+ return m.group(0)+ value = self.resolve(+ name, entry, outside_authorization=outside_authorization+ )+ if value is None:+ return m.group(0)+ self.events.append(SwapEvent("swapped", m.group(0)))+ return encode(value) if encode else value++ return PLACEHOLDER_RE.sub(repl, text)++ def json_text(self, text: str) -> str:+ """Quotes and backslashes in a value cannot break the document."""+ return self.text(text, encode=lambda v: json.dumps(v)[1:-1])++ def form_body(self, text: str) -> str:+ """Parse the form, swap the values, re-encode: reserved characters in a+ value cannot corrupt the fields."""+ pairs = urllib.parse.parse_qsl(text, keep_blank_values=True)+ new_pairs = [(k, self.text(v)) for k, v in pairs]+ if new_pairs != pairs:+ return urllib.parse.urlencode(new_pairs)+ # Field names are never swapped, in either spelling.+ return text++ def basic_auth(self, value: str) -> str:+ decoded = basic_decoded(value)+ if decoded is None:+ return value+ new_decoded = self.text(decoded, outside_authorization=False)+ if new_decoded == decoded:+ return value+ swapped = base64.b64encode(new_decoded.encode()).decode("ascii")+ self.encoded.append((swapped, value.partition(" ")[2].strip()))+ return "Basic " + swapped++ def headers(self, request: Any) -> None:+ cookie_names = {n for n, c in self.credentials.items() if c.cookie}+ for key in list(request.headers.keys()):+ lowered = key.lower()+ if lowered in NEVER_SWAP_HEADERS:+ continue+ values = request.headers.get_all(key)+ if lowered == "authorization":+ new_values = [self.basic_auth(v) for v in values]+ # Not Basic (e.g. ``Bearer <placeholder>``): plain text.+ new_values = [+ self.text(v, outside_authorization=False) if nv == v else nv+ for v, nv in zip(values, new_values)+ ]+ elif lowered == "cookie":+ # ``cookie`` is an opt-in of its own.+ new_values = [+ self.text(v, only=cookie_names, outside_authorization=False)+ for v in values+ ]+ else:+ new_values = [self.text(v) for v in values]+ if new_values != values:+ request.headers.set_all(key, new_values)++ def request(self, request: Any) -> None:+ """Swap everywhere a request can carry a placeholder."""+ self.head(request)+ self.body(request)++ def head(self, request: Any) -> None:+ """Headers, query and path: everything that leaves before the body."""+ self.headers(request)+ query = list(request.query.items(multi=True))+ new_query = [(k, self.text(v)) for k, v in query]+ raw_path, mark, query_string = request.path.partition("?")+ raw_query = mark + query_string+ new_segments, path_changed = [], False+ for segment in raw_path.split("/"):+ decoded = urllib.parse.unquote(segment)+ swapped = self.text(decoded)+ if swapped != decoded:+ path_changed = True+ new_segments.append(urllib.parse.quote(swapped, safe=""))+ else:+ new_segments.append(segment)+ if path_changed or new_query != query:+ new_path = "/".join(new_segments) if path_changed else raw_path+ if new_query != query:+ new_path += "?" + urllib.parse.urlencode(new_query)+ else:+ # Untouched, so byte-identical: re-encoding it would change a+ # query that carries its own escaping, a signed URL's for one.+ new_path += raw_query+ request.path = new_path++ def body(self, request: Any) -> None:+ if not request.content:+ return+ try:+ body = request.content.decode("utf-8")+ except UnicodeDecodeError:+ return+ media = media_type(request.headers.get("content-type", ""))+ if media == "application/json" or media.endswith("+json"):+ new_body = self.json_text(body)+ elif media == "application/x-www-form-urlencoded":+ new_body = self.form_body(body)+ else:+ new_body = self.text(body)+ if new_body != body:+ request.content = new_body.encode("utf-8")+++def media_type(content_type: Optional[str]) -> str:+ """``Application/JSON; charset=utf-8`` -> ``application/json``."""+ return (content_type or "").split(";")[0].strip().lower()+++def is_scrubbable(content_type: Optional[str]) -> bool:+ c = media_type(content_type)+ if not c:+ return True # unknown: try decoding, skip on failure+ return c.startswith(_SCRUBBABLE_TYPES) or c.endswith(("+json", "+xml"))+++def scrub_replacements(+ credentials: Iterable[Credential],+) -> list[tuple[str, str, bool]]:+ """``(value, placeholder, whole_token)``, longest value first so that+ overlapping values replace correctly.++ A TOTP seed is never in the list; the current code is, because the model+ typed that placeholder into a page which may echo it back. Codes match as+ whole tokens only: six digits collide with prices and ids.+ """+ triples: list[tuple[str, str, bool]] = []+ for credential in credentials:+ for entry, value in credential.values.items():+ suffix = "" if entry == DEFAULT_ENTRY else f":{entry}"+ placeholder = f"hsurr:{credential.name}{suffix}"+ if entry == TOTP_ENTRY:+ try:+ triples.append((totp_code(value), placeholder, True))+ except (ValueError, binascii.Error):+ pass+ continue+ if entry in credential.no_scrub or len(value or "") < MIN_SCRUB_LEN:+ continue+ triples.append((value, placeholder, False))+ triples.sort(key=lambda t: len(t[0]), reverse=True)+ return triples+++def scrub_bytes(+ data: bytes,+ credentials: Iterable[Credential],+ encoded: Iterable[tuple[str, str]] = (),+) -> bytes:+ """``scrub_text`` on bytes, with every value as UTF-8 and as UTF-16 in+ either byte order, whatever charset the body declares. For a body that+ does not decode as declared (one stray byte, an unknown charset name), and+ for one the box may read in another charset than the proxy did."""+ for swapped, original in encoded:+ data = data.replace(swapped.encode(), original.encode())+ for value, placeholder, whole_token in scrub_replacements(credentials):+ if whole_token:+ pattern = rb"(?<!\d)" + re.escape(value.encode()) + rb"(?!\d)"+ data = re.sub(pattern, placeholder.encode(), data)+ continue+ for codec in ("utf-8", "utf-16-le", "utf-16-be"):+ if (raw := value.encode(codec)) in data:+ data = data.replace(raw, placeholder.encode(codec))+ return data+++def scrub_text(+ text: str,+ credentials: Iterable[Credential],+ encoded: Iterable[tuple[str, str]] = (),+) -> str:+ """Replace every known value in *text* with its placeholder, and every+ swapped Basic pair in *encoded* with the one the box sent."""+ for swapped, original in encoded:+ text = text.replace(swapped, original)+ for value, placeholder, whole_token in scrub_replacements(credentials):+ if whole_token:+ text = re.sub(r"(?<!\d)" + re.escape(value) + r"(?!\d)", placeholder, text)+ elif value in text:+ text = text.replace(value, placeholder)+ return textdiff --git a/autogpt_platform/swap_proxy/swap_proxy/swap_test.py b/autogpt_platform/swap_proxy/swap_proxy/swap_test.pynew file mode 100644index 0000000000..44045a8427--- /dev/null+++ b/autogpt_platform/swap_proxy/swap_proxy/swap_test.py@@ -0,0 +1,509 @@+"""The swap rules, ported from spark-vm's conformance tests+(``proxy/test_swap_addon.py``): each guards a finding from its review."""++import base64+import json+import urllib.parse++import pytest+from mitmproxy import http++from swap_proxy.swap import (+ Credential,+ RequestSwap,+ host_in_list,+ normalize_path,+ path_allowed,+ placeholder_names,+ scrub_text,+ totp_code,+)++HOST = "api.github.com"+++def Anywhere(*args, **kwargs) -> Credential:+ """The conformance suite below is spark-vm's, where a value is swapped+ everywhere: its credentials opt in. The default is ``TestAuthorizationOnly``."""+ return Credential(*args, swap_anywhere=True, **kwargs)+++TOKEN = 'ghp_"quoted"\\and&reserved=chars%'+GITHUB = Anywhere("github", {"access_token": TOKEN}, (HOST, ".githubusercontent.com"))+ACME = Anywhere(+ "acme",+ {+ "username": "[email protected]",+ "password": "correct horse battery",+ "totp": "JBSWY3DPEHPK3PXP",+ "pin": "1234",+ },+ ("login.acme.test",),+ no_scrub=frozenset({"username"}),+)+++def make_request(path="/", headers=None, content=b"", method="GET", host=HOST):+ return http.Request.make(+ method, f"https://{host}{path}", content=content, headers=headers or {}+ )+++def swap(request, *credentials, host=HOST):+ s = RequestSwap(+ {c.name: c for c in credentials}, host, request.method, request.path+ )+ s.request(request)+ return s+++class TestHeaders:+ def test_bearer(self):+ r = make_request(headers={"Authorization": "Bearer hsurr:github"})+ s = swap(r, GITHUB)+ assert r.headers["Authorization"] == f"Bearer {TOKEN}"+ assert [(e.kind, e.placeholder) for e in s.events] == [+ ("swapped", "hsurr:github")+ ]++ def test_basic_auth_is_decoded_swapped_and_reencoded(self):+ """git and ``curl -u`` hide the placeholder inside base64."""+ pair = base64.b64encode(b"x-access-token:hsurr:github").decode()+ r = make_request(headers={"Authorization": f"Basic {pair}"})+ swap(r, GITHUB)+ decoded = base64.b64decode(r.headers["Authorization"].split()[1]).decode()+ assert decoded == f"x-access-token:{TOKEN}"++ @pytest.mark.parametrize("header", ["Referer", "Origin"])+ def test_referer_and_origin_are_never_swapped(self, header):+ r = make_request(headers={header: "https://x.test/?k=hsurr:github"})+ swap(r, GITHUB)+ assert r.headers[header] == "https://x.test/?k=hsurr:github"++ def test_cookie_only_for_a_credential_that_says_so(self):+ r = make_request(headers={"Cookie": "session=hsurr:github"})+ swap(r, GITHUB)+ assert r.headers["Cookie"] == "session=hsurr:github"+ cookie = Anywhere("github", {"access_token": "abc"}, (HOST,), cookie=True)+ swap(r, cookie)+ assert r.headers["Cookie"] == "session=abc"++ def test_custom_header(self):+ r = make_request(headers={"X-Api-Key": "hsurr:github"})+ swap(r, GITHUB)+ assert r.headers["X-Api-Key"] == TOKEN+++class TestBinding:+ def test_an_unbound_host_is_refused_and_says_so(self):+ r = make_request(headers={"Authorization": "Bearer hsurr:github"})+ s = swap(r, GITHUB, host="evil.test")+ assert r.headers["Authorization"] == "Bearer hsurr:github"+ assert [(e.kind, e.reason) for e in s.events] == [("refused", "unbound-host")]++ def test_a_credential_with_no_hosts_never_swaps(self):+ r = make_request(headers={"Authorization": "Bearer hsurr:github"})+ swap(r, Anywhere("github", {"access_token": "abc"}, ()))+ assert r.headers["Authorization"] == "Bearer hsurr:github"++ def test_leading_dot_binds_subdomains_only(self):+ for host, swapped in [+ ("raw.githubusercontent.com", True),+ ("githubusercontent.com", False),+ ("evilgithubusercontent.com", False),+ ]:+ r = make_request(headers={"X-K": "hsurr:github"}, host=host)+ swap(r, GITHUB, host=host)+ assert (r.headers["X-K"] == TOKEN) is swapped, host++ def test_an_unknown_name_is_left_alone(self):+ r = make_request(headers={"X-K": "hsurr:gitlab"})+ assert swap(r, GITHUB).events == [] and r.headers["X-K"] == "hsurr:gitlab"++ def test_an_unknown_entry_keeps_the_whole_placeholder(self):+ """``hsurr:github:8080`` must keep its ``:8080``."""+ r = make_request(headers={"X-K": "hsurr:github:8080"})+ s = swap(r, GITHUB)+ assert r.headers["X-K"] == "hsurr:github:8080"+ assert s.events[0].reason == "unknown-entry"+++class TestBodies:+ @pytest.mark.parametrize(+ "content_type",+ [+ "application/vnd.api+json",+ "application/merge-patch+json; charset=utf-8",+ "Application/JSON",+ " application/json ;charset=UTF-8",+ ],+ )+ def test_every_json_media_type_is_escaped_as_json(self, content_type):+ """TOKEN holds ``"`` and ``\\``: substituted plainly they would break+ the document."""+ body = json.dumps({"data": {"password": "hsurr:github"}}).encode()+ r = make_request(+ content=body, method="POST", headers={"Content-Type": content_type}+ )+ swap(r, GITHUB)+ assert json.loads(r.content or b"") == {"data": {"password": TOKEN}}++ @pytest.mark.parametrize(+ "content_type", ["application/x-www-form-urlencoded-not", "text/plain"]+ )+ def test_only_the_form_media_type_is_parsed_as_a_form(self, content_type):+ r = make_request(+ content=b"token=hsurr:github",+ method="POST",+ headers={"Content-Type": content_type},+ )+ swap(r, GITHUB)+ assert r.content == f"token={TOKEN}".encode() # plain substitution++ def test_json_values_are_escaped(self):+ body = json.dumps({"token": "hsurr:github"}).encode()+ r = make_request(+ content=body, method="POST", headers={"Content-Type": "application/json"}+ )+ swap(r, GITHUB)+ assert json.loads(r.content or b"") == {"token": TOKEN}++ @pytest.mark.parametrize("sent", ["hsurr:github", "hsurr%3Agithub"])+ def test_form_fields_are_reencoded(self, sent):+ """curl sends the colon, a browser percent-encodes it; either way a+ value with ``&`` or ``=`` cannot corrupt the fields."""+ r = make_request(+ content=f"user=me&token={sent}&next=1".encode(),+ method="POST",+ headers={"Content-Type": "application/x-www-form-urlencoded"},+ )+ swap(r, GITHUB)+ assert urllib.parse.parse_qsl((r.content or b"").decode()) == [+ ("user", "me"),+ ("token", TOKEN),+ ("next", "1"),+ ]++ @pytest.mark.parametrize("name", ["hsurr:github", "hsurr%3Agithub"])+ def test_form_field_names_are_never_swapped_in_either_spelling(self, name):+ body = f"{name}=1".encode()+ r = make_request(+ content=body,+ method="POST",+ headers={"Content-Type": "application/x-www-form-urlencoded"},+ )+ s = swap(r, GITHUB)+ assert r.content == body and s.events == []++ def test_plain_text(self):+ r = make_request(content=b"key=hsurr:github", method="POST")+ swap(r, GITHUB)+ assert r.content == f"key={TOKEN}".encode()++ def test_binary_bodies_are_left_alone(self):+ body = b"\xff\xfe hsurr:github"+ r = make_request(content=body, method="POST")+ swap(r, GITHUB)+ assert r.content == body+++class TestUrl:+ def test_query_values(self):+ r = make_request(path="/x?access_token=hsurr:github&keep=a%20b")+ swap(r, GITHUB)+ assert dict(r.query) == {"access_token": TOKEN, "keep": "a b"}++ def test_path_segment_cannot_be_escaped_by_the_value(self):+ r = make_request(path="/hooks/hsurr:github/fire")+ swap(r, Anywhere("github", {"access_token": "a/b?c"}, (HOST,)))+ assert r.path == "/hooks/a%2Fb%3Fc/fire"++ def test_unchanged_segments_stay_byte_identical(self):+ r = make_request(path="/a%25b/%2F~:@/hsurr:github")+ swap(r, Anywhere("github", {"access_token": "tok"}, (HOST,)))+ assert r.path == "/a%25b/%2F~:@/tok"++ def test_a_query_no_value_of_which_changed_stays_byte_identical(self):+ """A path swap must not re-encode a query that carries its own+ escaping: ``%20`` would become ``+`` and a signed URL would break."""+ query = "?sig=a%20b%2Fc&exp=1~2&flag&empty="+ r = make_request(path="/hooks/hsurr:github/fire" + query)+ swap(r, Anywhere("github", {"access_token": "tok"}, (HOST,)))+ assert r.path == "/hooks/tok/fire" + query++ def test_a_query_with_a_swapped_value_is_rebuilt(self):+ r = make_request(path="/hsurr:github?t=hsurr:github&keep=a%20b")+ swap(r, Anywhere("github", {"access_token": "t/k"}, (HOST,)))+ assert r.path == "/t%2Fk?t=t%2Fk&keep=a+b"+++class TestEntriesAndTotp:+ def test_named_entries(self):+ r = make_request(+ host="login.acme.test",+ headers={"X-U": "hsurr:acme:username", "X-P": "hsurr:acme:password"},+ )+ swap(r, ACME, host="login.acme.test")+ assert (r.headers["X-U"], r.headers["X-P"]) == (+ "[email protected]",+ "correct horse battery",+ )++ def test_totp_yields_the_code_never_the_seed(self):+ r = make_request(host="login.acme.test", headers={"X-C": "hsurr:acme:totp"})+ swap(r, ACME, host="login.acme.test")+ assert r.headers["X-C"] == totp_code("JBSWY3DPEHPK3PXP")+ assert "JBSWY3DPEHPK3PXP" not in r.headers["X-C"]++ def test_totp_matches_rfc_6238(self):+ seed = base64.b32encode(b"12345678901234567890").decode()+ assert totp_code(seed, at=59) == "287082"+ assert totp_code(seed, at=1111111109) == "081804"++ def test_a_bad_seed_is_refused_not_raised(self):+ bad = Anywhere("acme", {"totp": "not base32!"}, (HOST,))+ r = make_request(headers={"X-C": "hsurr:acme:totp"})+ assert swap(r, bad).events[0].reason == "bad-totp-seed"+++class TestMethodAndPathLimits:+ def limited(self, **limits):+ return Anywhere("github", {"access_token": "tok"}, (HOST,), **limits)++ def attempt(self, credential, method="GET", path="/"):+ r = make_request(path=path, method=method, headers={"X-K": "hsurr:github"})+ s = swap(r, credential)+ return r.headers["X-K"] == "tok", [e.reason for e in s.events if e.reason]++ def test_method_limit(self):+ c = self.limited(allowed_methods=("GET",))+ assert self.attempt(c, "get") == (True, [])+ assert self.attempt(c, "POST") == (False, ["method-not-allowed"])++ def test_path_prefix_is_segment_aligned(self):+ c = self.limited(allowed_paths=("/repos/",))+ assert self.attempt(c, path="/repos/x")[0]+ assert self.attempt(c, path="/repos")[0]+ assert self.attempt(c, path="/repository") == (False, ["path-not-allowed"])++ @pytest.mark.parametrize(+ "path",+ [+ "/repos/../admin",+ "/repos/%2e%2e/admin",+ "/repos/%252e%252e/admin",+ "/repos/x;param",+ "/repos/x%5C..%5Cadmin",+ ],+ )+ def test_smuggling_shapes_are_refused(self, path):+ c = self.limited(allowed_paths=("/repos/",))+ assert self.attempt(c, path=path) == (False, ["path-not-allowed"])++ def test_empty_lists_fail_closed(self):+ assert not self.attempt(self.limited(allowed_methods=()))[0]+ assert not self.attempt(self.limited(allowed_paths=()))[0]++ def test_without_a_path_a_path_bound_credential_never_swaps(self):+ """Websocket messages and tunnels: nothing to check the path against."""+ c = self.limited(allowed_paths=("/repos/",))+ s = RequestSwap({"github": c}, HOST)+ assert s.text("hsurr:github") == "hsurr:github"++ def test_normalize_path(self):+ assert normalize_path("/a/./b/../c?q=1") == "/a/c"+ assert normalize_path("%2Fa%2F%2e%2e%2Fb") == "/b"+ assert path_allowed("/repos/x", ["/repos/"])+ assert not path_allowed("/repository", ["/repos/"])+++class TestPlaceholderNames:+ def test_finds_them_everywhere_the_swap_looks(self):+ pair = base64.b64encode(b"u:hsurr:inbasic").decode()+ r = make_request(+ path="/p/hsurr%3Ainpath?q=hsurr:inquery",+ method="POST",+ headers={"Authorization": f"Basic {pair}", "X-K": "hsurr:inheader"},+ content=b"a=hsurr%3Ainform&b=hsurr:inbody:entry",+ )+ assert placeholder_names(r) == {+ "inbasic",+ "inpath",+ "inquery",+ "inheader",+ "inform",+ "inbody",+ }++ def test_none(self):+ assert placeholder_names(make_request(content=b"\xff\x00")) == set()+++class TestScrub:+ def test_values_go_back_to_placeholders(self):+ page = f'{{"token": "{TOKEN}", "pw": "correct horse battery"}}'+ assert scrub_text(page, [GITHUB, ACME]) == (+ '{"token": "hsurr:github", "pw": "hsurr:acme:password"}'+ )++ def test_short_values_are_never_scrubbed(self):+ """A short value would mangle the page: "Next" with pin "e"."""+ assert scrub_text("pin 1234 and 12345", [ACME]) == "pin 1234 and 12345"++ def test_opted_out_entries_are_left(self):+ assert "[email protected]" in scrub_text("hi [email protected]", [ACME])++ def test_totp_codes_only_as_whole_tokens(self):+ code = totp_code("JBSWY3DPEHPK3PXP")+ text = scrub_text(f"code {code}, order 9{code}9", [ACME])+ assert text == f"code hsurr:acme:totp, order 9{code}9"++ def test_the_longer_of_two_overlapping_values_wins(self):+ a = Anywhere("a", {"access_token": "secretvalue"}, (HOST,))+ b = Anywhere("b", {"access_token": "secretvalue-extended"}, (HOST,))+ assert scrub_text("x secretvalue-extended", [a, b]) == "x hsurr:b"+++def test_a_credential_never_prints_its_values():+ assert TOKEN not in repr(GITHUB) and TOKEN not in str(GITHUB)+ assert "correct horse" not in f"{ACME!r}"+++# Mirrored in backend/backend/copilot/swap_credentials_test.py; keep the two+# identical. The backend checks the binding with its own ``_host_is_bound``+# (the packages cannot import each other), and that suite also loads this+# package's ``host_in_list`` by path to assert the two agree.+HOST_BINDING_TABLE = [+ # (host, bound entries, may the credential go there?)+ ("api.github.com", ["api.github.com"], True),+ ("API.GitHub.com", ["api.github.com"], True),+ ("api.github.com", ["API.GITHUB.COM"], True),+ ("api.github.com:443", ["api.github.com"], True),+ ("github.com", ["api.github.com"], False),+ ("api.github.com.evil.test", ["api.github.com"], False),+ ("evilapi.github.com", ["api.github.com"], False),+ ("notgithub.com", ["github.com"], False),+ ("sub.github.com", ["github.com"], False), # exact names do not cover subdomains+ ("raw.githubusercontent.com", [".githubusercontent.com"], True),+ ("a.b.githubusercontent.com", [".githubusercontent.com"], True),+ ("githubusercontent.com", [".githubusercontent.com"], False),+ ("evilgithubusercontent.com", [".githubusercontent.com"], False),+ ("githubusercontent.com.evil.test", [".githubusercontent.com"], False),+ ("api.github.com", [], False),+ ("", ["api.github.com"], False),+ ("api.github.com", ["github.com", "api.github.com"], True),+]++[email protected]("host, entries, bound", HOST_BINDING_TABLE)+def test_host_binding_is_the_table_the_backend_is_held_to(host, entries, bound):+ assert host_in_list(host, entries) is bound+++class TestAuthorizationOnly:+ """The default: a value goes into the ``Authorization`` header and nowhere+ else. Swapped into a body it could be stored at the provider and read back+ in an encoding no scrub matches (a base64 blob, a packfile)."""++ PLAIN = Credential("github", {"access_token": TOKEN}, (HOST,))++ @pytest.mark.parametrize(+ "header",+ [+ "Bearer hsurr:github", # curl -H, most API clients+ "token hsurr:github", # gh+ ],+ )+ def test_the_authorization_header_is_swapped(self, header):+ r = make_request(headers={"Authorization": header})+ s = swap(r, self.PLAIN)+ assert r.headers["Authorization"] == header.replace("hsurr:github", TOKEN)+ assert [e.kind for e in s.events] == ["swapped"]++ def test_basic_as_git_sends_it_is_swapped(self):+ """git sends Basic, also for a token it was given in the URL: the+ userinfo becomes this header and never goes out in the URL itself."""+ pair = base64.b64encode(b"x-access-token:hsurr:github").decode()+ r = make_request(+ path="/o/r.git/git-receive-pack",+ method="POST",+ headers={+ "Authorization": f"Basic {pair}",+ "Content-Type": "application/x-git-receive-pack-request",+ },+ content=b"PACK\x00hsurr:github",+ )+ swap(r, self.PLAIN)+ decoded = base64.b64decode(r.headers["Authorization"].split()[1]).decode()+ assert decoded == f"x-access-token:{TOKEN}"+ assert r.content == b"PACK\x00hsurr:github"++ @pytest.mark.parametrize(+ "where",+ [+ {"headers": {"X-Api-Key": "hsurr:github"}},+ {"headers": {"Cookie": "s=hsurr:github"}},+ {"path": "/hooks/hsurr:github"},+ {"path": "/x?access_token=hsurr:github"},+ {+ "method": "POST",+ "headers": {"Content-Type": "application/json"},+ "content": b'{"files": {"a": {"content": "hsurr:github"}}}',+ },+ {+ "method": "POST",+ "headers": {"Content-Type": "application/x-www-form-urlencoded"},+ "content": b"token=hsurr%3Agithub",+ },+ {"method": "POST", "content": b"hsurr:github"},+ ],+ ids=["header", "cookie", "path", "query", "json", "form", "text"],+ )+ def test_anywhere_else_it_goes_out_literally_and_says_why(self, where):+ r = make_request(**where)+ before = (dict(r.headers), r.path, r.content)+ s = swap(r, self.PLAIN)+ assert (dict(r.headers), r.path, r.content) == before+ # Cookie has a rule of its own, which says so in its own words.+ reason = (+ "cookie-not-allowed"+ if "Cookie" in where.get("headers", {})+ else ("outside-authorization")+ )+ assert [(e.kind, e.placeholder, e.reason) for e in s.events] == [+ ("refused", "hsurr:github", reason)+ ]++ def test_a_websocket_message_is_not_swapped(self):+ s = RequestSwap({"github": self.PLAIN}, HOST)+ assert s.text('{"auth": "hsurr:github"}') == '{"auth": "hsurr:github"}'+ assert [e.reason for e in s.events] == ["outside-authorization"]++ @pytest.mark.parametrize("method", ["TRACE", "TRACK", "trace"])+ def test_a_method_whose_response_is_the_request_gets_nothing(self, method):+ """TRACE answers with the request itself as ``message/http``, which+ the scrub does not read: the header would come straight back."""+ r = make_request(+ method=method, headers={"Authorization": "Bearer hsurr:github"}+ )+ s = swap(r, self.PLAIN)+ assert r.headers["Authorization"] == "Bearer hsurr:github"+ assert [e.reason for e in s.events] == ["echoing-method"]++ def test_a_binding_refusal_still_names_the_binding(self):+ r = make_request(headers={"X-Api-Key": "hsurr:github"})+ s = swap(r, self.PLAIN, host="evil.test")+ assert [e.reason for e in s.events] == ["unbound-host"]++ def test_an_echoed_basic_header_goes_back_to_what_the_box_sent(self):+ """A server that echoes the header returns the base64 of the real pair,+ which no value matches; the swap remembers exactly that string."""+ original = base64.b64encode(b"x-access-token:hsurr:github").decode()+ r = make_request(headers={"Authorization": f"Basic {original}"})+ s = swap(r, self.PLAIN)+ swapped = r.headers["Authorization"].split()[1]+ assert s.encoded == [(swapped, original)]+ echo = f'{{"authorization": "Basic {swapped}"}}'+ assert scrub_text(echo, [self.PLAIN], s.encoded) == (+ f'{{"authorization": "Basic {original}"}}'+ )