Skip to content

refactor: deny unsafe code outside the QuickJS FFI boundary - #639

Merged
e54-bot merged 1 commit into
mainfrom
feat/no-unsafe-637
Oct 21, 2026
Merged

e54-bot merged 1 commit into
mainfrom
feat/no-unsafe-637

Conversation

@e54-bot

@e54-bot e54-bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Per #637: unsafe now 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 the mod quickjs_ng declaration — the tightest scope at the FFI boundary.
  • project.rs test: libc::geteuid → nix::unistd::geteuid().is_root().
  • resource_baseline.rs: libc::getrusage → nix::sys::resource::getrusage + raw max_rss() — the macOS-bytes/Linux-KB unit split is preserved (verified against nix 0.31.3 source).
  • libc dropped as a direct dependency (remains transitively via nix — unavoidable).
  • All 18 unsafe blocks in quickjs_ng.rs carry // SAFETY: comments; the 5 unsafe fns keep /// # Safety docs.

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

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
@e54-bot
e54-bot merged commit 4ba61d2 into main Oct 21, 2026
7 checks passed
@e54-bot
e54-bot deleted the feat/no-unsafe-637 branch October 21, 2026 22:11
This was referenced Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unsafe outside the QuickJS FFI boundary

2 participants