Repository navigation
refactor: deny unsafe code outside the QuickJS FFI boundary - #639
Merged
Merged
Conversation
Replace the two libc call sites in tests with nix: geteuid uses nix::unistd::geteuid().is_root() and getrusage uses nix::sys::resource::getrusage, keeping the platform-dependent ru_maxrss units (bytes on macOS, kilobytes elsewhere). nix becomes a cfg(unix) dev-dependency and libc is dropped as a direct dependency. Deny unsafe_code and clippy::undocumented_unsafe_blocks in the workspace lints; allow unsafe_code only on the macro_js::engine::quickjs_ng module, whose FFI blocks now each carry a // SAFETY: comment. Closes #637
This was referenced Oct 21, 2026
Merged
Merged
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
Per #637:
unsafenow lives only behind the QuickJS-NG FFI boundary, and the lints say so.unsafe_code = "deny"+clippy::undocumented_unsafe_blocks = "deny"in[workspace.lints];#[allow(unsafe_code)]sits on themod quickjs_ngdeclaration — the tightest scope at the FFI boundary.project.rstest:libc::geteuid→nix::unistd::geteuid().is_root().resource_baseline.rs:libc::getrusage→nix::sys::resource::getrusage+ rawmax_rss()— the macOS-bytes/Linux-KB unit split is preserved (verified against nix 0.31.3 source).libcdropped as a direct dependency (remains transitively via nix — unavoidable).quickjs_ng.rscarry// SAFETY:comments; the 5 unsafe fns keep/// # Safetydocs.Gates
fmt · clippy
--all-targets --all-features -D warnings(stable + 1.88.0) · workspace tests 863 · compat gate 137 match / 15 known-gap / 0 mismatch (output unchanged) · python oracle tests 52 · diff --check — all green.Fixes #637