kobako 0.30.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.githooks/linux-tests.sh +29 -0
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +460 -0
- data/Cargo.lock +868 -447
- data/README.md +43 -4
- data/ROADMAP.md +1 -2
- data/crates/kobako-runtime/CHANGELOG.md +309 -0
- data/crates/kobako-runtime/Cargo.toml +58 -11
- data/crates/kobako-runtime/README.md +7 -4
- data/crates/kobako-runtime/src/cred.rs +136 -0
- data/crates/kobako-runtime/src/dispatch.rs +4 -5
- data/crates/kobako-runtime/src/endpoint/buffer.rs +153 -44
- data/crates/kobako-runtime/src/endpoint/dispatch.rs +80 -41
- data/crates/kobako-runtime/src/endpoint/invoke.rs +23 -36
- data/crates/kobako-runtime/src/endpoint.rs +137 -36
- data/crates/kobako-runtime/src/errno.rs +391 -0
- data/crates/kobako-runtime/src/error.rs +31 -10
- data/crates/kobako-runtime/src/filesystem/anon_inodes.rs +52 -0
- data/crates/kobako-runtime/src/filesystem/bind/fid.rs +300 -22
- data/crates/kobako-runtime/src/filesystem/bind/lookup.rs +101 -29
- data/crates/kobako-runtime/src/filesystem/bind/unicode.rs +109 -0
- data/crates/kobako-runtime/src/filesystem/bind/walk.rs +52 -34
- data/crates/kobako-runtime/src/filesystem/bind.rs +812 -447
- data/crates/kobako-runtime/src/filesystem/overlay/file.rs +6 -6
- data/crates/kobako-runtime/src/filesystem/overlay/path.rs +43 -65
- data/crates/kobako-runtime/src/filesystem/overlay/stack/copy_up.rs +11 -16
- data/crates/kobako-runtime/src/filesystem/overlay/stack/dir.rs +47 -72
- data/crates/kobako-runtime/src/filesystem/overlay/stack/namei.rs +12 -12
- data/crates/kobako-runtime/src/filesystem/overlay/stack/readdir.rs +4 -7
- data/crates/kobako-runtime/src/filesystem/overlay/stack.rs +120 -37
- data/crates/kobako-runtime/src/filesystem/overlay.rs +578 -388
- data/crates/kobako-runtime/src/filesystem/pipe.rs +12 -9
- data/crates/kobako-runtime/src/filesystem/rdir.rs +14 -50
- data/crates/kobako-runtime/src/filesystem/testing.rs +31 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/seed.rs +32 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/tmpfile.rs +3 -3
- data/crates/kobako-runtime/src/filesystem/tmpfs/whiteout.rs +57 -35
- data/crates/kobako-runtime/src/filesystem/tmpfs/xattr.rs +2 -2
- data/crates/kobako-runtime/src/filesystem/tmpfs.rs +219 -173
- data/crates/kobako-runtime/src/filesystem/wrap.rs +36 -52
- data/crates/kobako-runtime/src/filesystem.rs +8 -3
- data/crates/kobako-runtime/src/fork.rs +319 -0
- data/crates/kobako-runtime/src/grant.rs +3 -0
- data/crates/kobako-runtime/src/hashtable.rs +4 -2
- data/crates/kobako-runtime/src/lib.rs +18 -7
- data/crates/kobako-runtime/src/limits.rs +171 -0
- data/crates/kobako-runtime/src/locking/seqlock.rs +29 -3
- data/crates/kobako-runtime/src/locking.rs +518 -113
- data/crates/kobako-runtime/src/memcg.rs +306 -0
- data/crates/kobako-runtime/src/mount.rs +37 -9
- data/crates/kobako-runtime/src/net/backends.rs +43 -0
- data/crates/kobako-runtime/src/net/connections.rs +219 -0
- data/crates/kobako-runtime/src/net/credential.rs +125 -0
- data/crates/kobako-runtime/src/net/egress.rs +180 -0
- data/crates/kobako-runtime/src/net/family.rs +181 -0
- data/crates/kobako-runtime/src/net/http.rs +3165 -0
- data/crates/kobako-runtime/src/net/lookup.rs +385 -0
- data/crates/kobako-runtime/src/net/mock.rs +251 -0
- data/crates/kobako-runtime/src/net/namespace.rs +1368 -0
- data/crates/kobako-runtime/src/net/reactor.rs +626 -0
- data/crates/kobako-runtime/src/net/resolv/darwin.rs +280 -0
- data/crates/kobako-runtime/src/net/resolv/stub/tests.rs +519 -0
- data/crates/kobako-runtime/src/net/resolv/stub.rs +542 -0
- data/crates/kobako-runtime/src/net/resolv/windows.rs +218 -0
- data/crates/kobako-runtime/src/net/resolv.rs +251 -0
- data/crates/kobako-runtime/src/net/skbuff.rs +109 -0
- data/crates/kobako-runtime/src/net/socket.rs +869 -0
- data/crates/kobako-runtime/src/net/task.rs +223 -0
- data/crates/kobako-runtime/src/net/tcp.rs +1840 -0
- data/crates/kobako-runtime/src/net/tls.rs +120 -0
- data/crates/kobako-runtime/src/net/transport.rs +304 -0
- data/crates/kobako-runtime/src/net/udp.rs +1105 -0
- data/crates/kobako-runtime/src/net.rs +45 -0
- data/crates/kobako-runtime/src/network/builder.rs +177 -0
- data/crates/kobako-runtime/src/network/ruleset.rs +777 -0
- data/crates/kobako-runtime/src/network.rs +551 -0
- data/crates/kobako-runtime/src/policy.rs +16 -0
- data/crates/kobako-runtime/src/profile.rs +29 -144
- data/crates/kobako-runtime/src/runtime.rs +3 -5
- data/crates/kobako-runtime/src/sched.rs +338 -51
- data/crates/kobako-runtime/src/security/entry_policy.rs +22 -0
- data/crates/kobako-runtime/src/{vfs/cred.rs → security/hooks.rs} +52 -144
- data/crates/kobako-runtime/src/security/mount_policy.rs +158 -0
- data/crates/kobako-runtime/src/security.rs +125 -209
- data/crates/kobako-runtime/src/snapshot.rs +121 -2
- data/crates/kobako-runtime/src/vfs/attr.rs +5 -5
- data/crates/kobako-runtime/src/vfs/dentry.rs +210 -117
- data/crates/kobako-runtime/src/vfs/file.rs +243 -248
- data/crates/kobako-runtime/src/vfs/inode.rs +41 -45
- data/crates/kobako-runtime/src/vfs/kern_path.rs +62 -53
- data/crates/kobako-runtime/src/vfs/mount.rs +10 -9
- data/crates/kobako-runtime/src/vfs/namei.rs +1162 -818
- data/crates/kobako-runtime/src/vfs/namespace.rs +245 -0
- data/crates/kobako-runtime/src/vfs/open_files.rs +69 -0
- data/crates/kobako-runtime/src/vfs/openat2.rs +3 -3
- data/crates/kobako-runtime/src/vfs/path.rs +6 -6
- data/crates/kobako-runtime/src/vfs/readdir.rs +6 -6
- data/crates/kobako-runtime/src/vfs/stat.rs +248 -23
- data/crates/kobako-runtime/src/vfs/super_block.rs +18 -14
- data/crates/kobako-runtime/src/vfs/utimes.rs +37 -27
- data/crates/kobako-runtime/src/vfs.rs +10 -6
- data/crates/kobako-runtime/src/wait.rs +381 -0
- data/crates/kobako-transport/CHANGELOG.md +38 -0
- data/crates/kobako-transport/Cargo.toml +1 -1
- data/crates/kobako-transport/README.md +3 -4
- data/crates/kobako-transport/src/abi.rs +78 -72
- data/crates/kobako-transport/src/envelope/bytes.rs +17 -6
- data/crates/kobako-transport/src/envelope/call.rs +32 -4
- data/crates/kobako-transport/src/envelope/error_record.rs +21 -0
- data/crates/kobako-transport/src/envelope/name.rs +99 -0
- data/crates/kobako-transport/src/envelope/outcome.rs +9 -9
- data/crates/kobako-transport/src/envelope/preamble.rs +24 -21
- data/crates/kobako-transport/src/envelope/reply.rs +27 -27
- data/crates/kobako-transport/src/envelope/unsupported.rs +10 -10
- data/crates/kobako-transport/src/envelope.rs +13 -8
- data/crates/kobako-wasmtime/CHANGELOG.md +208 -0
- data/crates/kobako-wasmtime/Cargo.toml +47 -7
- data/crates/kobako-wasmtime/README.md +4 -3
- data/crates/kobako-wasmtime/build/preview2.rs +1339 -0
- data/crates/kobako-wasmtime/build.rs +16 -0
- data/crates/kobako-wasmtime/src/abi.rs +18 -37
- data/crates/kobako-wasmtime/src/ambient.rs +43 -19
- data/crates/kobako-wasmtime/src/cache/unix.rs +95 -0
- data/crates/kobako-wasmtime/src/cache/windows.rs +359 -0
- data/crates/kobako-wasmtime/src/cache.rs +106 -113
- data/crates/kobako-wasmtime/src/config.rs +52 -68
- data/crates/kobako-wasmtime/src/driver.rs +80 -82
- data/crates/kobako-wasmtime/src/exports.rs +143 -17
- data/crates/kobako-wasmtime/src/guest.rs +12 -6
- data/crates/kobako-wasmtime/src/guest_binary.rs +14 -0
- data/crates/kobako-wasmtime/src/imports.rs +42 -18
- data/crates/kobako-wasmtime/src/instance_pre.rs +4 -4
- data/crates/kobako-wasmtime/src/invocation.rs +91 -15
- data/crates/kobako-wasmtime/src/lib.rs +7 -3
- data/crates/kobako-wasmtime/src/limiter.rs +130 -12
- data/crates/kobako-wasmtime/src/preview1/descriptors.rs +305 -0
- data/crates/kobako-wasmtime/src/preview1/differential/mount.rs +9 -20
- data/crates/kobako-wasmtime/src/preview1/differential.rs +27 -31
- data/crates/kobako-wasmtime/src/preview1/errno.rs +55 -66
- data/crates/kobako-wasmtime/src/preview1/fd.rs +347 -312
- data/crates/kobako-wasmtime/src/preview1/memory.rs +21 -12
- data/crates/kobako-wasmtime/src/preview1/mount_view/wrap.rs +34 -53
- data/crates/kobako-wasmtime/src/preview1/mount_view.rs +335 -388
- data/crates/kobako-wasmtime/src/preview1/path.rs +56 -121
- data/crates/kobako-wasmtime/src/preview1/poll.rs +255 -125
- data/crates/kobako-wasmtime/src/preview1/random.rs +125 -0
- data/crates/kobako-wasmtime/src/preview1/sock.rs +10 -8
- data/crates/kobako-wasmtime/src/preview1/testing.rs +31 -0
- data/crates/kobako-wasmtime/src/preview1/testsuite.rs +5 -15
- data/crates/kobako-wasmtime/src/preview1.rs +131 -51
- data/crates/kobako-wasmtime/src/preview2/abi.rs +227 -0
- data/crates/kobako-wasmtime/src/preview2/error.rs +118 -0
- data/crates/kobako-wasmtime/src/preview2/filesystem.rs +122 -0
- data/crates/kobako-wasmtime/src/preview2/host.rs +4319 -0
- data/crates/kobako-wasmtime/src/preview2/http.rs +1587 -0
- data/crates/kobako-wasmtime/src/preview2/io.rs +328 -0
- data/crates/kobako-wasmtime/src/preview2/sockets.rs +379 -0
- data/crates/kobako-wasmtime/src/preview2/table.rs +257 -0
- data/crates/kobako-wasmtime/src/preview2.rs +57 -0
- data/crates/kobako-wasmtime/src/trap.rs +88 -28
- data/crates/kobako-wasmtime/src/waits.rs +59 -0
- data/crates/kobako-wasmtime/src/wasi.rs +291 -81
- data/crates/kobako-wasmtime/wit/deps/cli.wit +233 -0
- data/crates/kobako-wasmtime/wit/deps/clocks.wit +162 -0
- data/crates/kobako-wasmtime/wit/deps/filesystem.wit +589 -0
- data/crates/kobako-wasmtime/wit/deps/http.wit +733 -0
- data/crates/kobako-wasmtime/wit/deps/io.wit +299 -0
- data/crates/kobako-wasmtime/wit/deps/random.wit +92 -0
- data/crates/kobako-wasmtime/wit/deps/sockets.wit +949 -0
- data/crates/kobako-wasmtime/witx/wasi_snapshot_preview1.witx +13 -0
- data/data/kobako.wasm +0 -0
- data/ext/kobako/Cargo.toml +6 -2
- data/ext/kobako/src/{runtime/errors.rs → errors.rs} +34 -26
- data/ext/kobako/src/escape.rs +404 -0
- data/ext/kobako/src/{runtime/filesystem → filesystem}/grants.rs +34 -32
- data/ext/kobako/src/{runtime/filesystem → filesystem}/ruby.rs +158 -170
- data/ext/kobako/src/{runtime/filesystem.rs → filesystem.rs} +71 -23
- data/ext/kobako/src/fork.rs +72 -0
- data/ext/kobako/src/gvl.rs +729 -0
- data/ext/kobako/src/handoff.rs +490 -0
- data/ext/kobako/src/lib.rs +74 -3
- data/ext/kobako/src/network/mock.rs +187 -0
- data/ext/kobako/src/network.rs +593 -0
- data/ext/kobako/src/pinned_value.rs +44 -0
- data/ext/kobako/src/runtime/bridge.rs +58 -50
- data/ext/kobako/src/runtime/snapshot.rs +4 -4
- data/ext/kobako/src/runtime.rs +272 -163
- data/ext/kobako/src/wire.rs +42 -0
- data/lib/kobako/catalog/extensions.rb +14 -2
- data/lib/kobako/catalog/flags.rb +3 -5
- data/lib/kobako/catalog/grants.rb +5 -4
- data/lib/kobako/catalog/handles.rb +14 -32
- data/lib/kobako/catalog/mount.rb +11 -3
- data/lib/kobako/catalog/network.rb +35 -0
- data/lib/kobako/catalog/replacements.rb +28 -0
- data/lib/kobako/catalog/services.rb +5 -19
- data/lib/kobako/catalog/snippets.rb +3 -18
- data/lib/kobako/catalog.rb +3 -0
- data/lib/kobako/codec/{utils.rb → boundary.rb} +4 -2
- data/lib/kobako/codec/decoder.rb +5 -5
- data/lib/kobako/codec/ext_types.rb +3 -3
- data/lib/kobako/codec/handle_walk.rb +3 -43
- data/lib/kobako/codec/state.rb +2 -18
- data/lib/kobako/codec/value_budget.rb +133 -41
- data/lib/kobako/codec.rb +6 -7
- data/lib/kobako/context.rb +24 -11
- data/lib/kobako/errors.rb +18 -18
- data/lib/kobako/extension.rb +3 -2
- data/lib/kobako/filesystem.rb +10 -3
- data/lib/kobako/fork.rb +42 -0
- data/lib/kobako/handle.rb +2 -3
- data/lib/kobako/names.rb +28 -0
- data/lib/kobako/network.rb +210 -0
- data/lib/kobako/outcome.rb +7 -7
- data/lib/kobako/runtime.rb +3 -2
- data/lib/kobako/sandbox.rb +73 -35
- data/lib/kobako/sandbox_options.rb +42 -109
- data/lib/kobako/transport/argument_wrap.rb +64 -0
- data/lib/kobako/transport/block_failure.rb +1 -1
- data/lib/kobako/transport/dispatcher.rb +6 -6
- data/lib/kobako/transport/exposure.rb +26 -15
- data/lib/kobako/transport/reflection.rb +21 -4
- data/lib/kobako/transport/run.rb +8 -23
- data/lib/kobako/transport/yielder.rb +2 -9
- data/lib/kobako/transport.rb +1 -0
- data/lib/kobako/usage.rb +4 -2
- data/lib/kobako/version.rb +1 -1
- data/lib/kobako.rb +8 -4
- data/release-please-config.json +15 -0
- data/sig/kobako/catalog/extensions.rbs +2 -0
- data/sig/kobako/catalog/grants.rbs +7 -4
- data/sig/kobako/catalog/handles.rbs +2 -2
- data/sig/kobako/catalog/mount.rbs +3 -1
- data/sig/kobako/catalog/network.rbs +20 -0
- data/sig/kobako/catalog/replacements.rbs +14 -0
- data/sig/kobako/catalog/services.rbs +0 -4
- data/sig/kobako/catalog/snippets.rbs +0 -2
- data/sig/kobako/codec/{utils.rbs → boundary.rbs} +2 -2
- data/sig/kobako/codec/handle_walk.rbs +0 -6
- data/sig/kobako/codec/state.rbs +0 -4
- data/sig/kobako/codec/value_budget.rbs +48 -5
- data/sig/kobako/codec.rbs +2 -2
- data/sig/kobako/context.rbs +3 -1
- data/sig/kobako/errors.rbs +4 -7
- data/sig/kobako/filesystem.rbs +21 -3
- data/sig/kobako/fork.rbs +17 -0
- data/sig/kobako/network.rbs +115 -0
- data/sig/kobako/outcome.rbs +1 -1
- data/sig/kobako/runtime.rbs +32 -3
- data/sig/kobako/sandbox.rbs +10 -2
- data/sig/kobako/sandbox_options.rbs +29 -40
- data/sig/kobako/transport/argument_wrap.rbs +15 -0
- data/sig/kobako/transport/error.rbs +1 -1
- data/sig/kobako/transport/exposure.rbs +2 -4
- data/sig/kobako/transport/reflection.rbs +10 -0
- data/sig/kobako/transport/run.rbs +0 -2
- data/sig/kobako/transport/yielder.rbs +0 -3
- data/sig/kobako/transport.rbs +1 -1
- data/sig/kobako.rbs +13 -0
- metadata +97 -37
- data/crates/kobako-runtime/src/endpoint/capture.rs +0 -115
- data/crates/kobako-runtime/src/endpoint/memory_cap.rs +0 -238
- data/crates/kobako-runtime/src/filesystem/path.rs +0 -21
- data/crates/kobako-runtime/src/vfs/errno.rs +0 -153
- data/crates/kobako-runtime/tests/linux_baseline/calls.rs +0 -171
- data/crates/kobako-runtime/tests/linux_baseline/concurrent.rs +0 -276
- data/crates/kobako-runtime/tests/linux_baseline/kobako.rs +0 -323
- data/crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt +0 -16
- data/crates/kobako-runtime/tests/linux_baseline/linux.rs +0 -449
- data/crates/kobako-runtime/tests/linux_baseline/main.rs +0 -611
- data/crates/kobako-runtime/tests/linux_baseline/permissions.rs +0 -236
- data/crates/kobako-wasmtime/src/descriptors.rs +0 -200
- data/crates/kobako-wasmtime/tests/integration/compile_posture.rs +0 -43
- data/crates/kobako-wasmtime/tests/integration/guest_file.rs +0 -1085
- data/crates/kobako-wasmtime/tests/integration/main.rs +0 -29
- data/crates/kobako-wasmtime/tests/integration/preamble_flags.rs +0 -70
- data/crates/kobako-wasmtime/tests/integration/snippet_compile.rs +0 -95
- data/crates/kobako-wasmtime/tests/integration/support/mod.rs +0 -30
- data/crates/kobako-wasmtime/tests/integration/unanswered_call.rs +0 -86
- data/crates/kobako-wasmtime/tests/integration/unsupported_call.rs +0 -51
- data/ext/kobako/src/runtime/escape.rs +0 -67
- data/ext/kobako/src/runtime/gvl.rs +0 -147
- data/ext/kobako/src/runtime/pinned_value.rs +0 -31
- data/lib/kobako/constant_name.rb +0 -8
- data/lib/kobako/pool.rb +0 -140
- data/sig/kobako/constant_name.rbs +0 -3
- data/sig/kobako/pool.rbs +0 -42
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kobako
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.32.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aotokitsuruya
|
|
@@ -15,7 +15,7 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 1.8.
|
|
18
|
+
version: 1.8.6
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '2'
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 1.8.
|
|
28
|
+
version: 1.8.6
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '2'
|
|
@@ -53,6 +53,7 @@ extensions:
|
|
|
53
53
|
- ext/kobako/extconf.rb
|
|
54
54
|
extra_rdoc_files: []
|
|
55
55
|
files:
|
|
56
|
+
- ".githooks/linux-tests.sh"
|
|
56
57
|
- ".release-please-manifest.json"
|
|
57
58
|
- CHANGELOG.md
|
|
58
59
|
- Cargo.lock
|
|
@@ -64,18 +65,20 @@ files:
|
|
|
64
65
|
- crates/kobako-runtime/CHANGELOG.md
|
|
65
66
|
- crates/kobako-runtime/Cargo.toml
|
|
66
67
|
- crates/kobako-runtime/README.md
|
|
68
|
+
- crates/kobako-runtime/src/cred.rs
|
|
67
69
|
- crates/kobako-runtime/src/dispatch.rs
|
|
68
70
|
- crates/kobako-runtime/src/endpoint.rs
|
|
69
71
|
- crates/kobako-runtime/src/endpoint/buffer.rs
|
|
70
|
-
- crates/kobako-runtime/src/endpoint/capture.rs
|
|
71
72
|
- crates/kobako-runtime/src/endpoint/dispatch.rs
|
|
72
73
|
- crates/kobako-runtime/src/endpoint/invoke.rs
|
|
73
|
-
- crates/kobako-runtime/src/
|
|
74
|
+
- crates/kobako-runtime/src/errno.rs
|
|
74
75
|
- crates/kobako-runtime/src/error.rs
|
|
75
76
|
- crates/kobako-runtime/src/filesystem.rs
|
|
77
|
+
- crates/kobako-runtime/src/filesystem/anon_inodes.rs
|
|
76
78
|
- crates/kobako-runtime/src/filesystem/bind.rs
|
|
77
79
|
- crates/kobako-runtime/src/filesystem/bind/fid.rs
|
|
78
80
|
- crates/kobako-runtime/src/filesystem/bind/lookup.rs
|
|
81
|
+
- crates/kobako-runtime/src/filesystem/bind/unicode.rs
|
|
79
82
|
- crates/kobako-runtime/src/filesystem/bind/walk.rs
|
|
80
83
|
- crates/kobako-runtime/src/filesystem/overlay.rs
|
|
81
84
|
- crates/kobako-runtime/src/filesystem/overlay/file.rs
|
|
@@ -86,49 +89,77 @@ files:
|
|
|
86
89
|
- crates/kobako-runtime/src/filesystem/overlay/stack/dir.rs
|
|
87
90
|
- crates/kobako-runtime/src/filesystem/overlay/stack/namei.rs
|
|
88
91
|
- crates/kobako-runtime/src/filesystem/overlay/stack/readdir.rs
|
|
89
|
-
- crates/kobako-runtime/src/filesystem/path.rs
|
|
90
92
|
- crates/kobako-runtime/src/filesystem/pipe.rs
|
|
91
93
|
- crates/kobako-runtime/src/filesystem/rdir.rs
|
|
94
|
+
- crates/kobako-runtime/src/filesystem/testing.rs
|
|
92
95
|
- crates/kobako-runtime/src/filesystem/tmpfs.rs
|
|
96
|
+
- crates/kobako-runtime/src/filesystem/tmpfs/seed.rs
|
|
93
97
|
- crates/kobako-runtime/src/filesystem/tmpfs/tmpfile.rs
|
|
94
98
|
- crates/kobako-runtime/src/filesystem/tmpfs/whiteout.rs
|
|
95
99
|
- crates/kobako-runtime/src/filesystem/tmpfs/xattr.rs
|
|
96
100
|
- crates/kobako-runtime/src/filesystem/wrap.rs
|
|
101
|
+
- crates/kobako-runtime/src/fork.rs
|
|
97
102
|
- crates/kobako-runtime/src/grant.rs
|
|
98
103
|
- crates/kobako-runtime/src/hashtable.rs
|
|
99
104
|
- crates/kobako-runtime/src/lib.rs
|
|
105
|
+
- crates/kobako-runtime/src/limits.rs
|
|
100
106
|
- crates/kobako-runtime/src/locking.rs
|
|
101
107
|
- crates/kobako-runtime/src/locking/seqlock.rs
|
|
108
|
+
- crates/kobako-runtime/src/memcg.rs
|
|
102
109
|
- crates/kobako-runtime/src/mount.rs
|
|
110
|
+
- crates/kobako-runtime/src/net.rs
|
|
111
|
+
- crates/kobako-runtime/src/net/backends.rs
|
|
112
|
+
- crates/kobako-runtime/src/net/connections.rs
|
|
113
|
+
- crates/kobako-runtime/src/net/credential.rs
|
|
114
|
+
- crates/kobako-runtime/src/net/egress.rs
|
|
115
|
+
- crates/kobako-runtime/src/net/family.rs
|
|
116
|
+
- crates/kobako-runtime/src/net/http.rs
|
|
117
|
+
- crates/kobako-runtime/src/net/lookup.rs
|
|
118
|
+
- crates/kobako-runtime/src/net/mock.rs
|
|
119
|
+
- crates/kobako-runtime/src/net/namespace.rs
|
|
120
|
+
- crates/kobako-runtime/src/net/reactor.rs
|
|
121
|
+
- crates/kobako-runtime/src/net/resolv.rs
|
|
122
|
+
- crates/kobako-runtime/src/net/resolv/darwin.rs
|
|
123
|
+
- crates/kobako-runtime/src/net/resolv/stub.rs
|
|
124
|
+
- crates/kobako-runtime/src/net/resolv/stub/tests.rs
|
|
125
|
+
- crates/kobako-runtime/src/net/resolv/windows.rs
|
|
126
|
+
- crates/kobako-runtime/src/net/skbuff.rs
|
|
127
|
+
- crates/kobako-runtime/src/net/socket.rs
|
|
128
|
+
- crates/kobako-runtime/src/net/task.rs
|
|
129
|
+
- crates/kobako-runtime/src/net/tcp.rs
|
|
130
|
+
- crates/kobako-runtime/src/net/tls.rs
|
|
131
|
+
- crates/kobako-runtime/src/net/transport.rs
|
|
132
|
+
- crates/kobako-runtime/src/net/udp.rs
|
|
133
|
+
- crates/kobako-runtime/src/network.rs
|
|
134
|
+
- crates/kobako-runtime/src/network/builder.rs
|
|
135
|
+
- crates/kobako-runtime/src/network/ruleset.rs
|
|
136
|
+
- crates/kobako-runtime/src/policy.rs
|
|
103
137
|
- crates/kobako-runtime/src/profile.rs
|
|
104
138
|
- crates/kobako-runtime/src/runtime.rs
|
|
105
139
|
- crates/kobako-runtime/src/sched.rs
|
|
106
140
|
- crates/kobako-runtime/src/security.rs
|
|
141
|
+
- crates/kobako-runtime/src/security/entry_policy.rs
|
|
142
|
+
- crates/kobako-runtime/src/security/hooks.rs
|
|
143
|
+
- crates/kobako-runtime/src/security/mount_policy.rs
|
|
107
144
|
- crates/kobako-runtime/src/snapshot.rs
|
|
108
145
|
- crates/kobako-runtime/src/vfs.rs
|
|
109
146
|
- crates/kobako-runtime/src/vfs/attr.rs
|
|
110
|
-
- crates/kobako-runtime/src/vfs/cred.rs
|
|
111
147
|
- crates/kobako-runtime/src/vfs/dentry.rs
|
|
112
|
-
- crates/kobako-runtime/src/vfs/errno.rs
|
|
113
148
|
- crates/kobako-runtime/src/vfs/file.rs
|
|
114
149
|
- crates/kobako-runtime/src/vfs/inode.rs
|
|
115
150
|
- crates/kobako-runtime/src/vfs/kern_path.rs
|
|
116
151
|
- crates/kobako-runtime/src/vfs/mount.rs
|
|
117
152
|
- crates/kobako-runtime/src/vfs/namei.rs
|
|
153
|
+
- crates/kobako-runtime/src/vfs/namespace.rs
|
|
154
|
+
- crates/kobako-runtime/src/vfs/open_files.rs
|
|
118
155
|
- crates/kobako-runtime/src/vfs/openat2.rs
|
|
119
156
|
- crates/kobako-runtime/src/vfs/path.rs
|
|
120
157
|
- crates/kobako-runtime/src/vfs/readdir.rs
|
|
121
158
|
- crates/kobako-runtime/src/vfs/stat.rs
|
|
122
159
|
- crates/kobako-runtime/src/vfs/super_block.rs
|
|
123
160
|
- crates/kobako-runtime/src/vfs/utimes.rs
|
|
161
|
+
- crates/kobako-runtime/src/wait.rs
|
|
124
162
|
- crates/kobako-runtime/src/yielder.rs
|
|
125
|
-
- crates/kobako-runtime/tests/linux_baseline/calls.rs
|
|
126
|
-
- crates/kobako-runtime/tests/linux_baseline/concurrent.rs
|
|
127
|
-
- crates/kobako-runtime/tests/linux_baseline/kobako.rs
|
|
128
|
-
- crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt
|
|
129
|
-
- crates/kobako-runtime/tests/linux_baseline/linux.rs
|
|
130
|
-
- crates/kobako-runtime/tests/linux_baseline/main.rs
|
|
131
|
-
- crates/kobako-runtime/tests/linux_baseline/permissions.rs
|
|
132
163
|
- crates/kobako-transport/CHANGELOG.md
|
|
133
164
|
- crates/kobako-transport/Cargo.toml
|
|
134
165
|
- crates/kobako-transport/README.md
|
|
@@ -139,6 +170,7 @@ files:
|
|
|
139
170
|
- crates/kobako-transport/src/envelope/compile_reply.rs
|
|
140
171
|
- crates/kobako-transport/src/envelope/error_record.rs
|
|
141
172
|
- crates/kobako-transport/src/envelope/fault.rs
|
|
173
|
+
- crates/kobako-transport/src/envelope/name.rs
|
|
142
174
|
- crates/kobako-transport/src/envelope/outcome.rs
|
|
143
175
|
- crates/kobako-transport/src/envelope/preamble.rs
|
|
144
176
|
- crates/kobako-transport/src/envelope/reply.rs
|
|
@@ -150,20 +182,25 @@ files:
|
|
|
150
182
|
- crates/kobako-wasmtime/CHANGELOG.md
|
|
151
183
|
- crates/kobako-wasmtime/Cargo.toml
|
|
152
184
|
- crates/kobako-wasmtime/README.md
|
|
185
|
+
- crates/kobako-wasmtime/build.rs
|
|
186
|
+
- crates/kobako-wasmtime/build/preview2.rs
|
|
153
187
|
- crates/kobako-wasmtime/src/abi.rs
|
|
154
188
|
- crates/kobako-wasmtime/src/ambient.rs
|
|
155
189
|
- crates/kobako-wasmtime/src/cache.rs
|
|
190
|
+
- crates/kobako-wasmtime/src/cache/unix.rs
|
|
191
|
+
- crates/kobako-wasmtime/src/cache/windows.rs
|
|
156
192
|
- crates/kobako-wasmtime/src/config.rs
|
|
157
|
-
- crates/kobako-wasmtime/src/descriptors.rs
|
|
158
193
|
- crates/kobako-wasmtime/src/driver.rs
|
|
159
194
|
- crates/kobako-wasmtime/src/exports.rs
|
|
160
195
|
- crates/kobako-wasmtime/src/guest.rs
|
|
196
|
+
- crates/kobako-wasmtime/src/guest_binary.rs
|
|
161
197
|
- crates/kobako-wasmtime/src/imports.rs
|
|
162
198
|
- crates/kobako-wasmtime/src/instance_pre.rs
|
|
163
199
|
- crates/kobako-wasmtime/src/invocation.rs
|
|
164
200
|
- crates/kobako-wasmtime/src/lib.rs
|
|
165
201
|
- crates/kobako-wasmtime/src/limiter.rs
|
|
166
202
|
- crates/kobako-wasmtime/src/preview1.rs
|
|
203
|
+
- crates/kobako-wasmtime/src/preview1/descriptors.rs
|
|
167
204
|
- crates/kobako-wasmtime/src/preview1/differential.rs
|
|
168
205
|
- crates/kobako-wasmtime/src/preview1/differential/mount.rs
|
|
169
206
|
- crates/kobako-wasmtime/src/preview1/errno.rs
|
|
@@ -173,35 +210,51 @@ files:
|
|
|
173
210
|
- crates/kobako-wasmtime/src/preview1/mount_view/wrap.rs
|
|
174
211
|
- crates/kobako-wasmtime/src/preview1/path.rs
|
|
175
212
|
- crates/kobako-wasmtime/src/preview1/poll.rs
|
|
213
|
+
- crates/kobako-wasmtime/src/preview1/random.rs
|
|
176
214
|
- crates/kobako-wasmtime/src/preview1/sock.rs
|
|
215
|
+
- crates/kobako-wasmtime/src/preview1/testing.rs
|
|
177
216
|
- crates/kobako-wasmtime/src/preview1/testsuite-expected.txt
|
|
178
217
|
- crates/kobako-wasmtime/src/preview1/testsuite.rs
|
|
218
|
+
- crates/kobako-wasmtime/src/preview2.rs
|
|
219
|
+
- crates/kobako-wasmtime/src/preview2/abi.rs
|
|
220
|
+
- crates/kobako-wasmtime/src/preview2/error.rs
|
|
221
|
+
- crates/kobako-wasmtime/src/preview2/filesystem.rs
|
|
222
|
+
- crates/kobako-wasmtime/src/preview2/host.rs
|
|
223
|
+
- crates/kobako-wasmtime/src/preview2/http.rs
|
|
224
|
+
- crates/kobako-wasmtime/src/preview2/io.rs
|
|
225
|
+
- crates/kobako-wasmtime/src/preview2/sockets.rs
|
|
226
|
+
- crates/kobako-wasmtime/src/preview2/table.rs
|
|
179
227
|
- crates/kobako-wasmtime/src/trap.rs
|
|
228
|
+
- crates/kobako-wasmtime/src/waits.rs
|
|
180
229
|
- crates/kobako-wasmtime/src/wasi.rs
|
|
181
|
-
- crates/kobako-wasmtime/
|
|
182
|
-
- crates/kobako-wasmtime/
|
|
183
|
-
- crates/kobako-wasmtime/
|
|
184
|
-
- crates/kobako-wasmtime/
|
|
185
|
-
- crates/kobako-wasmtime/
|
|
186
|
-
- crates/kobako-wasmtime/
|
|
187
|
-
- crates/kobako-wasmtime/
|
|
188
|
-
- crates/kobako-wasmtime/tests/integration/unsupported_call.rs
|
|
230
|
+
- crates/kobako-wasmtime/wit/deps/cli.wit
|
|
231
|
+
- crates/kobako-wasmtime/wit/deps/clocks.wit
|
|
232
|
+
- crates/kobako-wasmtime/wit/deps/filesystem.wit
|
|
233
|
+
- crates/kobako-wasmtime/wit/deps/http.wit
|
|
234
|
+
- crates/kobako-wasmtime/wit/deps/io.wit
|
|
235
|
+
- crates/kobako-wasmtime/wit/deps/random.wit
|
|
236
|
+
- crates/kobako-wasmtime/wit/deps/sockets.wit
|
|
189
237
|
- crates/kobako-wasmtime/witx/typenames.witx
|
|
190
238
|
- crates/kobako-wasmtime/witx/wasi_snapshot_preview1.witx
|
|
191
239
|
- data/kobako.wasm
|
|
192
240
|
- ext/kobako/Cargo.toml
|
|
193
241
|
- ext/kobako/extconf.rb
|
|
242
|
+
- ext/kobako/src/errors.rs
|
|
243
|
+
- ext/kobako/src/escape.rs
|
|
244
|
+
- ext/kobako/src/filesystem.rs
|
|
245
|
+
- ext/kobako/src/filesystem/grants.rs
|
|
246
|
+
- ext/kobako/src/filesystem/ruby.rs
|
|
247
|
+
- ext/kobako/src/fork.rs
|
|
248
|
+
- ext/kobako/src/gvl.rs
|
|
249
|
+
- ext/kobako/src/handoff.rs
|
|
194
250
|
- ext/kobako/src/lib.rs
|
|
251
|
+
- ext/kobako/src/network.rs
|
|
252
|
+
- ext/kobako/src/network/mock.rs
|
|
253
|
+
- ext/kobako/src/pinned_value.rs
|
|
195
254
|
- ext/kobako/src/runtime.rs
|
|
196
255
|
- ext/kobako/src/runtime/bridge.rs
|
|
197
|
-
- ext/kobako/src/runtime/errors.rs
|
|
198
|
-
- ext/kobako/src/runtime/escape.rs
|
|
199
|
-
- ext/kobako/src/runtime/filesystem.rs
|
|
200
|
-
- ext/kobako/src/runtime/filesystem/grants.rs
|
|
201
|
-
- ext/kobako/src/runtime/filesystem/ruby.rs
|
|
202
|
-
- ext/kobako/src/runtime/gvl.rs
|
|
203
|
-
- ext/kobako/src/runtime/pinned_value.rs
|
|
204
256
|
- ext/kobako/src/runtime/snapshot.rs
|
|
257
|
+
- ext/kobako/src/wire.rs
|
|
205
258
|
- lib/kobako.rb
|
|
206
259
|
- lib/kobako/capture.rb
|
|
207
260
|
- lib/kobako/catalog.rb
|
|
@@ -210,9 +263,12 @@ files:
|
|
|
210
263
|
- lib/kobako/catalog/grants.rb
|
|
211
264
|
- lib/kobako/catalog/handles.rb
|
|
212
265
|
- lib/kobako/catalog/mount.rb
|
|
266
|
+
- lib/kobako/catalog/network.rb
|
|
267
|
+
- lib/kobako/catalog/replacements.rb
|
|
213
268
|
- lib/kobako/catalog/services.rb
|
|
214
269
|
- lib/kobako/catalog/snippets.rb
|
|
215
270
|
- lib/kobako/codec.rb
|
|
271
|
+
- lib/kobako/codec/boundary.rb
|
|
216
272
|
- lib/kobako/codec/decoder.rb
|
|
217
273
|
- lib/kobako/codec/encoder.rb
|
|
218
274
|
- lib/kobako/codec/error.rb
|
|
@@ -220,19 +276,19 @@ files:
|
|
|
220
276
|
- lib/kobako/codec/handle_walk.rb
|
|
221
277
|
- lib/kobako/codec/nesting.rb
|
|
222
278
|
- lib/kobako/codec/state.rb
|
|
223
|
-
- lib/kobako/codec/utils.rb
|
|
224
279
|
- lib/kobako/codec/value_budget.rb
|
|
225
|
-
- lib/kobako/constant_name.rb
|
|
226
280
|
- lib/kobako/context.rb
|
|
227
281
|
- lib/kobako/errors.rb
|
|
228
282
|
- lib/kobako/execution.rb
|
|
229
283
|
- lib/kobako/extension.rb
|
|
230
284
|
- lib/kobako/filesystem.rb
|
|
285
|
+
- lib/kobako/fork.rb
|
|
231
286
|
- lib/kobako/handle.rb
|
|
287
|
+
- lib/kobako/names.rb
|
|
288
|
+
- lib/kobako/network.rb
|
|
232
289
|
- lib/kobako/outcome.rb
|
|
233
290
|
- lib/kobako/payload.rb
|
|
234
291
|
- lib/kobako/payload/arguments.rb
|
|
235
|
-
- lib/kobako/pool.rb
|
|
236
292
|
- lib/kobako/runtime.rb
|
|
237
293
|
- lib/kobako/sandbox.rb
|
|
238
294
|
- lib/kobako/sandbox_options.rb
|
|
@@ -240,6 +296,7 @@ files:
|
|
|
240
296
|
- lib/kobako/snippet/bytecode.rb
|
|
241
297
|
- lib/kobako/snippet/source.rb
|
|
242
298
|
- lib/kobako/transport.rb
|
|
299
|
+
- lib/kobako/transport/argument_wrap.rb
|
|
243
300
|
- lib/kobako/transport/block_failure.rb
|
|
244
301
|
- lib/kobako/transport/call.rb
|
|
245
302
|
- lib/kobako/transport/dispatcher.rb
|
|
@@ -260,9 +317,12 @@ files:
|
|
|
260
317
|
- sig/kobako/catalog/grants.rbs
|
|
261
318
|
- sig/kobako/catalog/handles.rbs
|
|
262
319
|
- sig/kobako/catalog/mount.rbs
|
|
320
|
+
- sig/kobako/catalog/network.rbs
|
|
321
|
+
- sig/kobako/catalog/replacements.rbs
|
|
263
322
|
- sig/kobako/catalog/services.rbs
|
|
264
323
|
- sig/kobako/catalog/snippets.rbs
|
|
265
324
|
- sig/kobako/codec.rbs
|
|
325
|
+
- sig/kobako/codec/boundary.rbs
|
|
266
326
|
- sig/kobako/codec/decoder.rbs
|
|
267
327
|
- sig/kobako/codec/encoder.rbs
|
|
268
328
|
- sig/kobako/codec/error.rbs
|
|
@@ -270,20 +330,19 @@ files:
|
|
|
270
330
|
- sig/kobako/codec/handle_walk.rbs
|
|
271
331
|
- sig/kobako/codec/nesting.rbs
|
|
272
332
|
- sig/kobako/codec/state.rbs
|
|
273
|
-
- sig/kobako/codec/utils.rbs
|
|
274
333
|
- sig/kobako/codec/value_budget.rbs
|
|
275
|
-
- sig/kobako/constant_name.rbs
|
|
276
334
|
- sig/kobako/context.rbs
|
|
277
335
|
- sig/kobako/errors.rbs
|
|
278
336
|
- sig/kobako/execution.rbs
|
|
279
337
|
- sig/kobako/extension.rbs
|
|
280
338
|
- sig/kobako/filesystem.rbs
|
|
339
|
+
- sig/kobako/fork.rbs
|
|
281
340
|
- sig/kobako/guest_yielder.rbs
|
|
282
341
|
- sig/kobako/handle.rbs
|
|
342
|
+
- sig/kobako/network.rbs
|
|
283
343
|
- sig/kobako/outcome.rbs
|
|
284
344
|
- sig/kobako/payload.rbs
|
|
285
345
|
- sig/kobako/payload/arguments.rbs
|
|
286
|
-
- sig/kobako/pool.rbs
|
|
287
346
|
- sig/kobako/runtime.rbs
|
|
288
347
|
- sig/kobako/sandbox.rbs
|
|
289
348
|
- sig/kobako/sandbox_options.rbs
|
|
@@ -292,6 +351,7 @@ files:
|
|
|
292
351
|
- sig/kobako/snippet/bytecode.rbs
|
|
293
352
|
- sig/kobako/snippet/source.rbs
|
|
294
353
|
- sig/kobako/transport.rbs
|
|
354
|
+
- sig/kobako/transport/argument_wrap.rbs
|
|
295
355
|
- sig/kobako/transport/block_failure.rbs
|
|
296
356
|
- sig/kobako/transport/call.rbs
|
|
297
357
|
- sig/kobako/transport/dispatcher.rbs
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
//! Per-channel stdout / stderr capture sizing and clipping.
|
|
2
|
-
//!
|
|
3
|
-
//! Two pure helpers shared by the run path: one sizes the per-run pipe, the
|
|
4
|
-
//! other clips a captured snapshot back to the configured limit and reports
|
|
5
|
-
//! whether the limit was passed. Kept channel-agnostic (a function of `limit`,
|
|
6
|
-
//! not of which channel) so a regression that only breaks one channel cannot
|
|
7
|
-
//! sneak through the test that pins them.
|
|
8
|
-
|
|
9
|
-
/// One byte past the limit, so "wrote exactly the limit" and "passed the
|
|
10
|
-
/// limit" stay distinguishable.
|
|
11
|
-
pub fn pipe_capacity(limit: Option<usize>) -> usize {
|
|
12
|
-
match limit {
|
|
13
|
-
Some(limit) => limit.saturating_add(1),
|
|
14
|
-
None => usize::MAX,
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/// Takes the snapshot by value and truncates in place, so the readback
|
|
19
|
-
/// costs one copy out of the pipe rather than two.
|
|
20
|
-
pub fn clip_capture(mut raw: Vec<u8>, limit: Option<usize>) -> (Vec<u8>, bool) {
|
|
21
|
-
match limit {
|
|
22
|
-
Some(limit) if raw.len() > limit => {
|
|
23
|
-
raw.truncate(limit);
|
|
24
|
-
(raw, true)
|
|
25
|
-
}
|
|
26
|
-
_ => (raw, false),
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
#[cfg(test)]
|
|
31
|
-
mod tests {
|
|
32
|
-
use super::{clip_capture, pipe_capacity};
|
|
33
|
-
|
|
34
|
-
// @behavior S-108
|
|
35
|
-
#[test]
|
|
36
|
-
fn a_pipe_holds_one_byte_past_its_limit() {
|
|
37
|
-
assert_eq!(
|
|
38
|
-
(pipe_capacity(Some(5)), pipe_capacity(Some(0))),
|
|
39
|
-
(6, 1),
|
|
40
|
-
"a limit of 5 and of 0 through pipe_capacity must size the pipe 6 and 1"
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// @behavior S-109
|
|
45
|
-
#[test]
|
|
46
|
-
fn a_pipe_without_a_limit_holds_usize_max() {
|
|
47
|
-
assert_eq!(
|
|
48
|
-
pipe_capacity(None),
|
|
49
|
-
usize::MAX,
|
|
50
|
-
"no limit through pipe_capacity must size the pipe usize::MAX"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// @behavior S-110
|
|
55
|
-
#[test]
|
|
56
|
-
fn a_pipe_past_usize_max_saturates() {
|
|
57
|
-
assert_eq!(
|
|
58
|
-
pipe_capacity(Some(usize::MAX)),
|
|
59
|
-
usize::MAX,
|
|
60
|
-
"a limit of usize::MAX through pipe_capacity must saturate at usize::MAX"
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// @behavior S-111
|
|
65
|
-
#[test]
|
|
66
|
-
fn a_capture_under_its_limit_stays_whole() {
|
|
67
|
-
assert_eq!(
|
|
68
|
-
clip_capture(b"abc".to_vec(), Some(5)),
|
|
69
|
-
(b"abc".to_vec(), false),
|
|
70
|
-
"3 bytes under a limit of 5 through clip_capture must stay whole and untruncated"
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// @behavior S-112
|
|
75
|
-
#[test]
|
|
76
|
-
fn a_capture_at_its_limit_is_not_truncated() {
|
|
77
|
-
assert_eq!(
|
|
78
|
-
clip_capture(b"abcde".to_vec(), Some(5)),
|
|
79
|
-
(b"abcde".to_vec(), false),
|
|
80
|
-
"5 bytes at a limit of 5 through clip_capture must stay whole and untruncated"
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// @behavior S-024
|
|
85
|
-
#[test]
|
|
86
|
-
fn a_capture_past_its_limit_is_clipped_and_truncated() {
|
|
87
|
-
// The pipe holds one byte past the limit, so 6 bytes is the most a
|
|
88
|
-
// limit of 5 can capture.
|
|
89
|
-
assert_eq!(
|
|
90
|
-
clip_capture(b"abcdef".to_vec(), Some(5)),
|
|
91
|
-
(b"abcde".to_vec(), true),
|
|
92
|
-
"6 bytes past a limit of 5 through clip_capture must clip to 5 and flag truncation"
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// @behavior S-033
|
|
97
|
-
#[test]
|
|
98
|
-
fn a_capture_without_a_limit_stays_whole() {
|
|
99
|
-
assert_eq!(
|
|
100
|
-
clip_capture(b"abcdef".to_vec(), None),
|
|
101
|
-
(b"abcdef".to_vec(), false),
|
|
102
|
-
"6 bytes with no limit through clip_capture must stay whole and untruncated"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// @behavior S-100 S-101
|
|
107
|
-
#[test]
|
|
108
|
-
fn an_empty_capture_stays_empty() {
|
|
109
|
-
assert_eq!(
|
|
110
|
-
clip_capture(Vec::new(), Some(5)),
|
|
111
|
-
(Vec::new(), false),
|
|
112
|
-
"no bytes under a limit of 5 through clip_capture must stay empty and untruncated"
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
//! The per-invocation memory cap: only the growth past the linear-memory size
|
|
2
|
-
//! captured at invocation entry is charged, so the image's initial allocation
|
|
3
|
-
//! is outside the budget.
|
|
4
|
-
|
|
5
|
-
/// The budget one invocation's memory grows against.
|
|
6
|
-
///
|
|
7
|
-
/// `memory_limit` bounds per-invocation growth (`None` disables it).
|
|
8
|
-
/// `baseline` is the linear-memory size captured at invocation entry by
|
|
9
|
-
/// `MemoryCap::activate`; only the growth past `baseline` is charged against
|
|
10
|
-
/// `memory_limit`, so the mruby image's initial allocation and any high-water
|
|
11
|
-
/// mark left by prior invocations on the same Sandbox do not consume the
|
|
12
|
-
/// budget. An Engine also asks about the module's declared initial allocation
|
|
13
|
-
/// at instantiation time, so the cap stays dormant until `MemoryCap::activate`
|
|
14
|
-
/// arms it for one invocation.
|
|
15
|
-
#[derive(Debug, Clone, Copy)]
|
|
16
|
-
pub struct MemoryCap {
|
|
17
|
-
memory_limit: Option<usize>,
|
|
18
|
-
baseline: usize,
|
|
19
|
-
cap_active: bool,
|
|
20
|
-
peak: usize,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
impl MemoryCap {
|
|
24
|
-
pub fn new(memory_limit: Option<usize>) -> Self {
|
|
25
|
-
Self {
|
|
26
|
-
memory_limit,
|
|
27
|
-
baseline: 0,
|
|
28
|
-
cap_active: false,
|
|
29
|
-
peak: 0,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/// The cap stays dormant until armed, because the module's declared
|
|
34
|
-
/// initial memory is allocated during instantiation and must pass.
|
|
35
|
-
pub fn activate(&mut self, baseline: usize) {
|
|
36
|
-
self.baseline = baseline;
|
|
37
|
-
self.cap_active = true;
|
|
38
|
-
self.peak = 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
pub fn deactivate(&mut self) {
|
|
42
|
-
self.cap_active = false;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/// A grow the cap rejects never updates the peak, so the reported value
|
|
46
|
-
/// never exceeds `memory_limit`.
|
|
47
|
-
pub fn peak(&self) -> usize {
|
|
48
|
-
self.peak
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/// Charge a growth to `desired` bytes, refusing one past `memory_limit`.
|
|
52
|
-
pub fn charge(&mut self, desired: usize) -> Result<(), MemoryLimitExceeded> {
|
|
53
|
-
if !self.cap_active {
|
|
54
|
-
return Ok(());
|
|
55
|
-
}
|
|
56
|
-
let delta = desired.saturating_sub(self.baseline);
|
|
57
|
-
if let Some(limit) = self.memory_limit {
|
|
58
|
-
if delta > limit {
|
|
59
|
-
return Err(MemoryLimitExceeded::new(desired, limit));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if delta > self.peak {
|
|
63
|
-
self.peak = delta;
|
|
64
|
-
}
|
|
65
|
-
Ok(())
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/// A growth past the per-invocation memory cap. An Engine ends the invocation
|
|
70
|
-
/// with it, and a Wasm Driver finds it again to classify the failure as a
|
|
71
|
-
/// memory-limit `Trap`. Callers use the `Display` impl below — no field is
|
|
72
|
-
/// read directly — so the inner state stays private.
|
|
73
|
-
#[derive(Debug)]
|
|
74
|
-
pub struct MemoryLimitExceeded {
|
|
75
|
-
desired: usize,
|
|
76
|
-
limit: usize,
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
impl MemoryLimitExceeded {
|
|
80
|
-
pub fn new(desired: usize, limit: usize) -> Self {
|
|
81
|
-
Self { desired, limit }
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
impl std::fmt::Display for MemoryLimitExceeded {
|
|
86
|
-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
87
|
-
write!(
|
|
88
|
-
f,
|
|
89
|
-
"memory usage exceeded memory_limit: \
|
|
90
|
-
requested={} bytes, limit={} bytes",
|
|
91
|
-
self.desired, self.limit
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
impl std::error::Error for MemoryLimitExceeded {}
|
|
97
|
-
|
|
98
|
-
#[cfg(test)]
|
|
99
|
-
mod tests {
|
|
100
|
-
//! The pure delta arithmetic, so a regression that breaks the baseline
|
|
101
|
-
//! accounting (dropping the `baseline` subtraction, or letting `activate`
|
|
102
|
-
//! carry stale state across invocations) is caught without an Engine.
|
|
103
|
-
use super::MemoryCap;
|
|
104
|
-
|
|
105
|
-
fn assert_charged(cap: &mut MemoryCap, desired: usize, what: &str) {
|
|
106
|
-
assert!(
|
|
107
|
-
cap.charge(desired).is_ok(),
|
|
108
|
-
"{what} through MemoryCap::charge must be allowed"
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
fn assert_refused(cap: &mut MemoryCap, desired: usize, what: &str) {
|
|
113
|
-
assert!(
|
|
114
|
-
cap.charge(desired).is_err(),
|
|
115
|
-
"{what} through MemoryCap::charge must be refused"
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// @behavior S-113
|
|
120
|
-
#[test]
|
|
121
|
-
fn a_growth_before_the_cap_is_armed_is_not_bounded() {
|
|
122
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
123
|
-
assert_charged(&mut cap, 100 << 20, "a 100 MiB growth before activate");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// @behavior S-114
|
|
127
|
-
#[test]
|
|
128
|
-
fn a_growth_within_the_limit_is_allowed() {
|
|
129
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
130
|
-
cap.activate(2 << 20);
|
|
131
|
-
assert_charged(
|
|
132
|
-
&mut cap,
|
|
133
|
-
(2 << 20) + (1 << 19),
|
|
134
|
-
"a 512 KiB growth past a 2 MiB baseline under a 1 MiB limit",
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// @behavior S-121
|
|
139
|
-
#[test]
|
|
140
|
-
fn a_growth_past_the_limit_is_refused() {
|
|
141
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
142
|
-
cap.activate(2 << 20);
|
|
143
|
-
assert_refused(
|
|
144
|
-
&mut cap,
|
|
145
|
-
4 << 20,
|
|
146
|
-
"a 2 MiB growth past a 2 MiB baseline under a 1 MiB limit",
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// @behavior S-008
|
|
151
|
-
#[test]
|
|
152
|
-
fn each_activation_charges_from_its_own_baseline() {
|
|
153
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
154
|
-
cap.activate(2 << 20);
|
|
155
|
-
assert_charged(&mut cap, 3 << 20, "a 1 MiB growth in the first invocation");
|
|
156
|
-
cap.activate(3 << 20);
|
|
157
|
-
assert_charged(
|
|
158
|
-
&mut cap,
|
|
159
|
-
4 << 20,
|
|
160
|
-
"a 1 MiB growth in the second invocation, past the first one's residue",
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// @behavior S-009
|
|
165
|
-
#[test]
|
|
166
|
-
fn a_cap_without_a_limit_allows_any_growth() {
|
|
167
|
-
let mut cap = MemoryCap::new(None);
|
|
168
|
-
cap.activate(0);
|
|
169
|
-
assert_charged(&mut cap, 100 << 20, "a 100 MiB growth with no limit");
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// @behavior S-116
|
|
173
|
-
#[test]
|
|
174
|
-
fn the_peak_is_zero_before_any_growth() {
|
|
175
|
-
let cap = MemoryCap::new(Some(1 << 20));
|
|
176
|
-
assert_eq!(
|
|
177
|
-
cap.peak(),
|
|
178
|
-
0,
|
|
179
|
-
"a new cap through MemoryCap::peak must report 0"
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// @behavior S-115
|
|
184
|
-
#[test]
|
|
185
|
-
fn the_peak_is_the_highest_growth_past_the_baseline() {
|
|
186
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
187
|
-
cap.activate(2 << 20);
|
|
188
|
-
assert_charged(&mut cap, (2 << 20) + (1 << 18), "a 256 KiB growth");
|
|
189
|
-
assert_charged(&mut cap, (2 << 20) + (1 << 19), "a 512 KiB growth");
|
|
190
|
-
assert_charged(&mut cap, (2 << 20) + (1 << 17), "a 128 KiB growth");
|
|
191
|
-
assert_eq!(
|
|
192
|
-
cap.peak(),
|
|
193
|
-
1 << 19,
|
|
194
|
-
"growths of 256, 512, and 128 KiB through MemoryCap::peak must report 512 KiB"
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// @behavior S-062
|
|
199
|
-
#[test]
|
|
200
|
-
fn a_refused_growth_leaves_the_peak_alone() {
|
|
201
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
202
|
-
cap.activate(2 << 20);
|
|
203
|
-
assert_charged(&mut cap, (2 << 20) + (1 << 19), "a 512 KiB growth");
|
|
204
|
-
assert_refused(&mut cap, 4 << 20, "a 2 MiB growth under a 1 MiB limit");
|
|
205
|
-
assert_eq!(
|
|
206
|
-
cap.peak(),
|
|
207
|
-
1 << 19,
|
|
208
|
-
"a refused 2 MiB growth through MemoryCap::peak must leave 512 KiB reported"
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// @behavior S-117
|
|
213
|
-
#[test]
|
|
214
|
-
fn each_activation_resets_the_peak() {
|
|
215
|
-
let mut cap = MemoryCap::new(Some(1 << 20));
|
|
216
|
-
cap.activate(2 << 20);
|
|
217
|
-
assert_charged(&mut cap, (2 << 20) + (1 << 19), "a 512 KiB growth");
|
|
218
|
-
cap.activate(3 << 20);
|
|
219
|
-
assert_eq!(
|
|
220
|
-
cap.peak(),
|
|
221
|
-
0,
|
|
222
|
-
"a second activate through MemoryCap::peak must report 0"
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// @behavior S-118
|
|
227
|
-
#[test]
|
|
228
|
-
fn a_cap_without_a_limit_still_reports_its_peak() {
|
|
229
|
-
let mut cap = MemoryCap::new(None);
|
|
230
|
-
cap.activate(1 << 20);
|
|
231
|
-
assert_charged(&mut cap, 5 << 20, "a 4 MiB growth with no limit");
|
|
232
|
-
assert_eq!(
|
|
233
|
-
cap.peak(),
|
|
234
|
-
4 << 20,
|
|
235
|
-
"a 4 MiB growth with no limit through MemoryCap::peak must report 4 MiB"
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
}
|