dart_io_sandbox 1.2.2
dart_io_sandbox: ^1.2.2 copied to clipboard
A Zone-based filesystem and process sandbox for Dart, built on IOOverrides. Confines all dart:io filesystem access to a configured root directory, blocks path-traversal and symlink escapes, enforces r [...]
1.2.2 #
- Upgraded dependencies, most notably
command_shieldto^1.1.0. - Bumped
path(^1.9.1),file(^7.0.1),args(^2.7.0),yaml(^3.1.3),async(^2.13.1) andstream_channel(^2.1.4). - Bumped dev dependencies
lints(^6.1.0) andtest(^1.31.1).
1.2.1 #
- Fix:
dart_io_sandbox testcould not resolvepackage:test(or the project's own libraries) when run against a project that does not itself depend ondart_io_sandbox— e.g. afterdart pub global activate, the documented install path. Each suite isolate was spawned with the CLI's own package config (Isolate.packageConfig), which omitstest(a dev-dependency, stripped from a standalone install) and the project's packages.SandboxVMPlatformnow spawns each isolate with a merged package config: the project-under-test's resolution (itstest,test_coreand own libraries) plus the CLI-only packages the generated bootstrap imports (dart_io_sandbox,command_shieldand their deps), the project winning on collisions. Falls back to the CLI config unchanged when the project has no.dart_tool/package_config.json.
1.2.0 #
- Network gate now covers HTTPS. A new
SandboxHttpOverrides(installed bySandbox.runalongsideSandboxIOOverrides) wraps everyHttpClientcreated inside the sandbox and checks each request againstallowNetwork. Previously the gate relied onIOOverrides, which only seesSocket.connect— sohttp://was gated buthttps://(viaSecureSocket) slipped through. Now both are blocked whenallowNetworkis false. (RawRawSocket/RawDatagramSocket/ UDP still have no override hook and remain uninterceptable.) - Command rewriting for
Sandbox.process.Sandbox.run/SandboxConfiggaincommandRewriters— a list of trustedCommandRewritertransforms applied to every process command after it passes the allowlist andCommandGuard(transparent substitutions, not re-checked). ExposesCommandRewrite,CommandRewriterandapplyRewriters. - Auto-rewires
dart test. A built-in rewriter (rewriteDartTest, defaulttrue) turns an intercepteddart test ...intodart run dart_io_sandbox test <flags> ..., where<flags>reproduce the current sandbox's policy and the serialisable part of itsCommandGuard, so the nested test process is itself confined. The invocation prefix is configurable viadartTestRewritePrefix(e.g.['dart_io_sandbox']for a global binary). - New public helper
sandboxCliArgs(root, policy, {commandGuard})converts a sandbox configuration to the equivalentdart_io_sandboxCLI flags. - CLI: added a clean
nonebase preset and--command-guard/--command-guard-syntax/--command-guard-deny-on-review/--command-guard-never-confirm-criticalflags so a reproduced configuration parses back exactly (covered by a round-trip test).
1.1.0 #
- New
dart_io_sandboxcommand-line tool. Itstestcommand runs a Dart test suite likedart test, but every test isolate executes inside aSandbox.runjail. It overrides the test runner's VM platform (viaregisterPlatformPlugin) so each spawned suite isolate installs the sandbox in its own bootstrap — preservingdart testparallelism (-j), filtering, reporters and exit codes while confining test bodies. Additional commands:config(print the resolved configuration),presets(list built-in presets) andhelp. - Capabilities are configured by a
--preset(safe/paranoid), an optional YAML file (--config), and CLI overrides (--root,--read-only,--allow-network,--allow-process,--allow-exe,--allow-path,--deny-path,--audit), layered preset < YAML < flags. The defaultsafepreset is read-write in the root with network allowed,dart/flutter/pubon the process allowlist, and a bashCommandGuard. All other arguments totestare forwarded verbatim to the test runner. Seeexample/sandbox.yaml. - Adds
args,yaml,async,stream_channel,test_coreandtest_apias dependencies (used by the CLI; library-only consumers get them transitively).
1.0.1 #
- Docs: expanded the README with a dedicated "Add command analysis
(
CommandGuard)" usage section showing how to attach acommand_shield-backed guard viaSandbox.run(commandGuard: ...), configuredenyOnReview/neverConfirmCritical, and use thefilter/confirmhooks. Fixed the stale install snippet (^0.1.0→^1.0.1). - Tests: substantially improved coverage (overall lib line coverage ~85%). Added
unit tests for
SandboxAccessEvent/SandboxAccessType, theSandboxErrorhierarchy and its factories,SandboxConfigdefaults, sandboxedLinkoperations (create/update/target/rename plus escape rejection), and broaderFile/Directorysurface (copy, length, stat, timestamps,readAsLines, append viaopenWrite,createTemp, asynclist,parentclamping). Extended thepackage:fileadapter tests to coverfromConfig,directory/link,stat/type/identicaland the directory accessors. - No runtime/API changes.
1.0.0 #
- Optional
CommandGuard: semantic, execution-free command analysis forSandbox.process, backed bypackage:command_shield. Attach it viaSandbox.run(commandGuard: ...)orSandboxConfig.commandGuardto deny dangerous invocations of allowlisted executables. Off by default; acommand_shieldreviewverdict is treated as a denial (denyOnReview, fail-closed). Addedexample/command_shield_example.dart. CommandGuardpluggable hooks (sync or asyncFutureOr), both receiving aCommandReviewwith the full analysis:filter— runs for every command and can override the verdict (force allow / review / deny, ornullto keepcommand_shield's).confirm— runs when a command would be denied and can override the denial (e.g. an interactive "run anyway?"); overrides are flagged in the audit trail.Sandbox.process.runSyncthrowsUnsupportedErrorif a hook returns aFuture(use the asyncrun/start).neverConfirmCritical(defaulttrue): commandscommand_shieldclassifies as critical-severity denials (e.g.rm -rf /) can never be overridden byconfirm— the callback is not consulted for them. Set tofalseto allow confirming even critical denials.
0.1.0 #
- Initial release.
- Zone-based filesystem sandbox via
IOOverrides: sandboxedFile,Directory, andLinkconfined to a configured root (full sync + async surface). - Path resolution layer with
../absolute-path traversal blocking and access-time symlink-escape protection. SandboxPolicy: read-only mode, allow/deny path lists (deny overrides allow), and an executable allowlist. Pure, deterministic evaluation.Sandbox.process: opt-in, allowlisted, shell-free process execution.- Network gate:
Socket/ServerSocketcreation (and, transitively,HttpClient) blocked unlessallowNetworkis set. Raw sockets and UDP (RawSocket,RawServerSocket,RawDatagramSocket) have noIOOverrideshook and are a documented, non-interceptable gap. onAccesshook emittingSandboxAccessEvents for every allowed/denied access.- Nested sandboxes with policy intersection (never more permissive than parent).
- Optional
package:fileintegration viaSandboxFileSystem. - Error hierarchy:
SandboxViolationError,SandboxPathError,SandboxPolicyError,SandboxProcessDeniedError.