Repository navigation
feat(python): add network= constructor kwarg (phase 1 of #1348) - #1489
Merged
Merged
Conversation
Expose `NetworkAllowlist` through `Bash(network=...)` and `BashTool(network=...)`. Accepts a dict with `allow`, `allow_all`, and `block_private_ips`; omitting `network=` keeps outbound HTTP disabled (unchanged secure default). Config is preserved across `reset()` and `from_snapshot()`. Enables `http_client` in the bashkit-python crate so `reqwest` is built unconditionally; gating happens at the Python API layer. Phase 2-4 of the issue (credential injection, before/after/handler callbacks, bot-auth) ship in follow-ups. Part of #1348
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 3b6b15d | Commit Preview URL Branch Preview URL |
Apr 30 2026, 09:27 AM |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Apr 30, 2026
chaliy
added a commit
that referenced
this pull request
May 30, 2026
## Summary Phase 1 of #1348. Exposes the existing Rust `NetworkAllowlist` through Python: - `Bash(network=...)` and `BashTool(network=...)` accept `{"allow": [...], "block_private_ips": True}` or `{"allow_all": True}` - Omitting `network=` keeps outbound HTTP disabled (unchanged secure default) - Empty `{"allow": []}` still blocks every URL but is distinct from omitted `network=` - Config persists across `reset()` and `from_snapshot()` - `bashkit-python` now compiles bashkit with the `http_client` feature so `reqwest` is built unconditionally; gating happens at the Python API layer - `block_private_ips` defaults to `True` (Rust parity) ## Why `bashkit-python` previously had no surface for outbound HTTP and the crate compiled without `http_client`, even though the Rust core has shipped `NetworkAllowlist`, credential injection, callbacks, and bot-auth for some time. This PR closes the easiest part of that gap (allowlist) so Python users can actually call `curl`/`wget`/`http` against allowlisted hosts. ## Out of scope (later phases of #1348) - Credential injection (`credentials`, `credential_placeholders`) - Request/response callbacks (`http_handler`, `before_http`, `after_http`) - `bot_auth` ## Tests `crates/bashkit-python/tests/test_network_config.py` (15 tests, all green): - Default-deny on `Bash` and `BashTool` - Allowlist still blocks unlisted hosts - `allow_all` removes allowlist-block stderr - Empty allow blocks everything - Validation: unknown key, missing `allow`/`allow_all`, mutually exclusive, wrong type - `reset()` preserves both allowlist and `allow_all` - `from_snapshot()` accepts `network=` for both `Bash` and `BashTool` - `block_private_ips` default-true blocks loopback even when allowlisted; `block_private_ips=False` is accepted ## Test plan - [x] `cargo fmt --check` - [x] `cargo clippy --all-targets -- -D warnings` - [x] `cargo test --features http_client` (full workspace, all green) - [x] `pytest crates/bashkit-python/tests/` (623 pass, 2 skipped) - [x] `ruff check && ruff format --check` (all green) - [x] Manual smoke test of allowlist + reset + allow_all Part of #1348 --- _Generated by [Claude Code](https://claude.ai/code/session_015E4TFL6EEnsG2GeLKbRYkJ)_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 of #1348. Exposes the existing Rust
NetworkAllowlistthrough Python:Bash(network=...)andBashTool(network=...)accept{"allow": [...], "block_private_ips": True}or{"allow_all": True}network=keeps outbound HTTP disabled (unchanged secure default){"allow": []}still blocks every URL but is distinct from omittednetwork=reset()andfrom_snapshot()bashkit-pythonnow compiles bashkit with thehttp_clientfeature soreqwestis built unconditionally; gating happens at the Python API layerblock_private_ipsdefaults toTrue(Rust parity)Why
bashkit-pythonpreviously had no surface for outbound HTTP and the crate compiled withouthttp_client, even though the Rust core has shippedNetworkAllowlist, credential injection, callbacks, and bot-auth for some time. This PR closes the easiest part of that gap (allowlist) so Python users can actually callcurl/wget/httpagainst allowlisted hosts.Out of scope (later phases of #1348)
credentials,credential_placeholders)http_handler,before_http,after_http)bot_authTests
crates/bashkit-python/tests/test_network_config.py(15 tests, all green):BashandBashToolallow_allremoves allowlist-block stderrallow/allow_all, mutually exclusive, wrong typereset()preserves both allowlist andallow_allfrom_snapshot()acceptsnetwork=for bothBashandBashToolblock_private_ipsdefault-true blocks loopback even when allowlisted;block_private_ips=Falseis acceptedTest plan
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test --features http_client(full workspace, all green)pytest crates/bashkit-python/tests/(623 pass, 2 skipped)ruff check && ruff format --check(all green)Part of #1348
Generated by Claude Code