Skip to content

Commit 541fb3f

Browse files
feat: Support egress allowlists on browser pools
Stainless-Generated-From: 5799c8ad59001401cd999d6117d0a5733f3686a8
1 parent d387aab commit 541fb3f

6 files changed

Lines changed: 59 additions & 35 deletions

‎src/kernel/resources/browser_pools.py‎

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def create(
123123
124124
name: Optional name for the browser pool. Must be unique within the project.
125125
126-
network: Network configuration applied to browsers in this pool. Proxy routes require
127-
proxy-v3; the pool will not provision browsers through Envoy if proxy-v3 is
128-
unavailable.
126+
network: Network configuration applied to browsers in this pool. Egress allowlists and
127+
proxy routes require proxy-v3; the pool will not provision browsers through
128+
Envoy if proxy-v3 is unavailable.
129129
130130
profile: Profile configuration for browsers in a pool. Provide either id or name.
131131
Profiles must be created beforehand. Unlike single browser sessions, pools load
@@ -296,9 +296,11 @@ def update(
296296
discard_all_idle: Whether to discard all idle browsers and rebuild them immediately with the new
297297
configuration. Defaults to false. Only browsers that are idle when the update
298298
runs are rebuilt. A browser that is in use during the update keeps its original
299-
configuration, and if it is later released with `reuse: true` it returns to the
300-
pool with that stale configuration until it is discarded (by this flag on a
301-
later update, or by flushing the pool).
299+
configuration, except that its allowlist is reset to the current pool baseline
300+
on release or the browser is replaced. For other configuration fields, if it is
301+
later released with `reuse: true` it returns to the pool with that stale
302+
configuration until it is discarded (by this flag on a later update, or by
303+
flushing the pool).
302304
303305
extensions: If provided, replaces the extension list. Empty array clears all
304306
previously-selected extensions. Omit this field to leave extensions unchanged.
@@ -321,10 +323,14 @@ def update(
321323
network: If provided, replaces the pool's network configuration. Omit to leave the
322324
existing configuration unchanged; an empty object ({}) removes it, while
323325
network: {private_hosts: []} or network: {proxy_routes: []} sets an explicit
324-
empty list. Proxy routes require proxy-v3; the pool will not provision browsers
325-
through Envoy if proxy-v3 is unavailable. Only applied to browsers created in
326-
the pool after the update; browsers already in the pool keep their configuration
327-
until discarded (see discard_all_idle).
326+
empty list; allowed_hosts must be non-empty when supplied. Egress allowlists and
327+
proxy routes require proxy-v3; the pool will not provision browsers through
328+
Envoy if proxy-v3 is unavailable. Changing allowed_hosts automatically replaces
329+
idle browsers. Leased browsers retain their allowlist until release, when it is
330+
reset to the current pool baseline or the browser is replaced if it cannot
331+
safely receive that baseline. Stale browsers cannot be acquired. Other network
332+
fields only apply to browsers created after the update; existing browsers keep
333+
those fields until discarded (see discard_all_idle).
328334
329335
profile: Profile configuration for browsers in a pool. Provide either id or name.
330336
Profiles must be created beforehand. Unlike single browser sessions, pools load
@@ -774,9 +780,9 @@ async def create(
774780
775781
name: Optional name for the browser pool. Must be unique within the project.
776782
777-
network: Network configuration applied to browsers in this pool. Proxy routes require
778-
proxy-v3; the pool will not provision browsers through Envoy if proxy-v3 is
779-
unavailable.
783+
network: Network configuration applied to browsers in this pool. Egress allowlists and
784+
proxy routes require proxy-v3; the pool will not provision browsers through
785+
Envoy if proxy-v3 is unavailable.
780786
781787
profile: Profile configuration for browsers in a pool. Provide either id or name.
782788
Profiles must be created beforehand. Unlike single browser sessions, pools load
@@ -947,9 +953,11 @@ async def update(
947953
discard_all_idle: Whether to discard all idle browsers and rebuild them immediately with the new
948954
configuration. Defaults to false. Only browsers that are idle when the update
949955
runs are rebuilt. A browser that is in use during the update keeps its original
950-
configuration, and if it is later released with `reuse: true` it returns to the
951-
pool with that stale configuration until it is discarded (by this flag on a
952-
later update, or by flushing the pool).
956+
configuration, except that its allowlist is reset to the current pool baseline
957+
on release or the browser is replaced. For other configuration fields, if it is
958+
later released with `reuse: true` it returns to the pool with that stale
959+
configuration until it is discarded (by this flag on a later update, or by
960+
flushing the pool).
953961
954962
extensions: If provided, replaces the extension list. Empty array clears all
955963
previously-selected extensions. Omit this field to leave extensions unchanged.
@@ -972,10 +980,14 @@ async def update(
972980
network: If provided, replaces the pool's network configuration. Omit to leave the
973981
existing configuration unchanged; an empty object ({}) removes it, while
974982
network: {private_hosts: []} or network: {proxy_routes: []} sets an explicit
975-
empty list. Proxy routes require proxy-v3; the pool will not provision browsers
976-
through Envoy if proxy-v3 is unavailable. Only applied to browsers created in
977-
the pool after the update; browsers already in the pool keep their configuration
978-
until discarded (see discard_all_idle).
983+
empty list; allowed_hosts must be non-empty when supplied. Egress allowlists and
984+
proxy routes require proxy-v3; the pool will not provision browsers through
985+
Envoy if proxy-v3 is unavailable. Changing allowed_hosts automatically replaces
986+
idle browsers. Leased browsers retain their allowlist until release, when it is
987+
reset to the current pool baseline or the browser is replaced if it cannot
988+
safely receive that baseline. Stale browsers cannot be acquired. Other network
989+
fields only apply to browsers created after the update; existing browsers keep
990+
those fields until discarded (see discard_all_idle).
979991
980992
profile: Profile configuration for browsers in a pool. Provide either id or name.
981993
Profiles must be created beforehand. Unlike single browser sessions, pools load

‎src/kernel/types/browser_network_config.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ class BrowserNetworkConfig(BaseModel):
5252
processes in the browser VM that do not use the browser's proxy, are not
5353
filtered, and Kernel's own control traffic is always allowed. Can be replaced or
5454
removed while the session runs with PATCH /browsers/{id_or_name}, but not added
55-
to a browser created without one. Requires proxy v3. Not supported on browser
56-
pools.
55+
to a browser created without one. Supported on browser pools and their leased
56+
browsers. Per-lease changes are reset to the pool's allowlist on release. If a
57+
lessee removes the allowlist and the pool still requires one, the browser is
58+
replaced on release rather than given an allowlist again. Requires proxy v3.
5759
"""
5860

5961
private_hosts: Optional[List[str]] = None

‎src/kernel/types/browser_network_config_param.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ class BrowserNetworkConfigParam(TypedDict, total=False):
5555
processes in the browser VM that do not use the browser's proxy, are not
5656
filtered, and Kernel's own control traffic is always allowed. Can be replaced or
5757
removed while the session runs with PATCH /browsers/{id_or_name}, but not added
58-
to a browser created without one. Requires proxy v3. Not supported on browser
59-
pools.
58+
to a browser created without one. Supported on browser pools and their leased
59+
browsers. Per-lease changes are reset to the pool's allowlist on release. If a
60+
lessee removes the allowlist and the pool still requires one, the browser is
61+
replaced on release rather than given an allowlist again. Requires proxy v3.
6062
"""
6163

6264
private_hosts: SequenceNotStr[str]

‎src/kernel/types/browser_network_update_param.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class BrowserNetworkUpdateParam(TypedDict, total=False):
2929
minutes during a Kernel deploy. Connections to destinations it still allows,
3030
such as WebSockets, stay open. A start_url in the same request must be allowed
3131
by the updated list, and is loaded only after the list takes effect. Requires a
32-
browser created with proxy v3, and not supported on pooled browsers. If the
33-
request fails, retry it: the new list may already apply to some requests.
32+
browser created with proxy v3. Supported on leased pooled browsers; the pool's
33+
allowlist is restored before reuse, or the browser is destroyed if it cannot be
34+
safely restored. If the request fails, retry it: the new list may already apply
35+
to some requests.
3436
"""

‎src/kernel/types/browser_pool_create_params.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class BrowserPoolCreateParams(TypedDict, total=False):
7070
network: BrowserNetworkConfigParam
7171
"""Network configuration applied to browsers in this pool.
7272
73-
Proxy routes require proxy-v3; the pool will not provision browsers through
74-
Envoy if proxy-v3 is unavailable.
73+
Egress allowlists and proxy routes require proxy-v3; the pool will not provision
74+
browsers through Envoy if proxy-v3 is unavailable.
7575
"""
7676

7777
profile: Profile

‎src/kernel/types/browser_pool_update_params.py‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
3737
Whether to discard all idle browsers and rebuild them immediately with the new
3838
configuration. Defaults to false. Only browsers that are idle when the update
3939
runs are rebuilt. A browser that is in use during the update keeps its original
40-
configuration, and if it is later released with `reuse: true` it returns to the
41-
pool with that stale configuration until it is discarded (by this flag on a
42-
later update, or by flushing the pool).
40+
configuration, except that its allowlist is reset to the current pool baseline
41+
on release or the browser is replaced. For other configuration fields, if it is
42+
later released with `reuse: true` it returns to the pool with that stale
43+
configuration until it is discarded (by this flag on a later update, or by
44+
flushing the pool).
4345
"""
4446

4547
extensions: Iterable[BrowserExtension]
@@ -81,10 +83,14 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
8183
8284
Omit to leave the existing configuration unchanged; an empty object ({}) removes
8385
it, while network: {private_hosts: []} or network: {proxy_routes: []} sets an
84-
explicit empty list. Proxy routes require proxy-v3; the pool will not provision
85-
browsers through Envoy if proxy-v3 is unavailable. Only applied to browsers
86-
created in the pool after the update; browsers already in the pool keep their
87-
configuration until discarded (see discard_all_idle).
86+
explicit empty list; allowed_hosts must be non-empty when supplied. Egress
87+
allowlists and proxy routes require proxy-v3; the pool will not provision
88+
browsers through Envoy if proxy-v3 is unavailable. Changing allowed_hosts
89+
automatically replaces idle browsers. Leased browsers retain their allowlist
90+
until release, when it is reset to the current pool baseline or the browser is
91+
replaced if it cannot safely receive that baseline. Stale browsers cannot be
92+
acquired. Other network fields only apply to browsers created after the update;
93+
existing browsers keep those fields until discarded (see discard_all_idle).
8894
"""
8995

9096
profile: Profile

0 commit comments

Comments
 (0)