Repository navigation
Conversation
WalkthroughChangesWASI now validates supported versions, selects version-specific import namespaces, and fills guest memory with chunked cryptographic randomness. Tests cover namespace selection, invalid versions, WASM instantiation, bounds handling, chunking, and sentinel preservation. WASI runtime behavior
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/js/bun/wasm/wasi.test.js`:
- Around line 27-53: Strengthen the random_get test around wasiImport.random_get
by stubbing or spying on the RNG to produce deterministic bytes, then assert it
is invoked with the expected chunk sizes covering all 70000 bytes. Replace the
partial some(...) checks with verification that every byte in the requested
buffer matches the deterministic output, while preserving the guard-byte
assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 79aca729-b82f-4dc5-b231-bfe46d54fcec
📒 Files selected for processing (2)
src/js/node/wasi.tstest/js/bun/wasm/wasi.test.js
a86adbf to
abeded2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/js/node/wasi.ts`:
- Around line 1854-1861: Update random_get to validate bufPtr and bufLen against
this.memory.buffer.byteLength before constructing the Uint8Array, returning the
appropriate WASI errno for invalid or out-of-bounds guest memory instead of
allowing RangeError to escape. Preserve the existing chunked
crypto.getRandomValues behavior for valid ranges.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: c602003e-f4e7-4d2a-8791-4afca48e4034
📒 Files selected for processing (2)
src/js/node/wasi.tstest/js/bun/wasm/wasi.test.js
random_get called crypto.getRandomValues(this.memory.buffer, bufPtr, bufLen), but getRandomValues takes a single integer-typed TypedArray, so the ArrayBuffer + extra args never filled the buffer. It also returned bufLen instead of WASI_ESUCCESS, which the guest reads as an errno, and would throw QuotaExceededError for requests over 65536 bytes. Fill a Uint8Array view over [bufPtr, bufPtr+bufLen) in 64 KiB chunks and return WASI_ESUCCESS.
Adds Node's getImportObject(), which returns the import object keyed by
the WASI namespace for the configured version:
{ wasi_snapshot_preview1: this.wasiImport } by default, or
{ wasi_unstable: this.wasiImport } for version: 'unstable'.
Track the previously-ignored version constructor option and validate it
via $ERR_INVALID_ARG_VALUE.
Fixes oven-sh#28534
abeded2 to
3ba0c89
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/js/node/wasi.ts`:
- Around line 1856-1859: Update the validation immediately before the Uint8Array
construction in the WASI buffer path to reject bufPtr and bufLen unless both are
finite safe integers and non-negative. Include these integer checks in the
existing bounds validation so invalid values return WASI_EINVAL before creating
the view, while preserving valid boundary handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 1d06bc14-ae3e-4bf0-9143-0108d3d4cf48
📒 Files selected for processing (2)
src/js/node/wasi.tstest/js/bun/wasm/wasi.test.js
|
Thank you for this! The core The |
What does this PR do?
This fixes several bugs in WASI function random_get and implements WASI#getImportObject
How did you verify your code works?
Some tests have been added. I have also run actual WASI programs that where failing previously (but working with ofher Wasm engine).