Skip to content

xtask: close the rule 10 and 11 gaps found in the #277 audit - #279

Open
atiernan wants to merge 3 commits into
claude/sys-code-regions-followupsfrom
claude/sys-rules-tighten
Open

atiernan wants to merge 3 commits into
claude/sys-code-regions-followupsfrom
claude/sys-rules-tighten

Conversation

@atiernan

Copy link
Copy Markdown
Member

Closes the two gaps the auditor found in the #277 checker rules. Only xtask changes; crates/clazel-sys is untouched (hash still f31e300b..., its audit step passes).

Rule 11 (only clazel-codecheck and clazel-jit reach the code-region API)

Refused now, in every crate not on the allowlist:

  • Raw identifiers: r#clazel_sys is compared as clazel_sys everywhere (mention test, aliases, paths, type names).
  • Names unique to clazel-sys (CodeWriter, CodeRegion, SharedCode, CodeError, RemoteView, CODE_START, CONTEXT_BYTES, CONTEXT_WORDS, EXIT_CODE_WORD) in every file, whether or not it names clazel_sys. A second file using the API through a re-export is judged.
  • Validated and enter stay judged only in files that name clazel_sys: other crates legitimately have their own (Validated in clazel-x509 and clazel-crypto, enter in clazel-layout and clazel_renderer::sandbox::enter), so flagging them everywhere would be a false positive. Closing every alias route (below) is what makes this sufficient.
  • Hiding the crate: clazel_sys anywhere but the first segment of a use path (use {clazel_sys::{self as s}}, pub use {clazel_sys};), pub extern crate clazel_sys, use $c in a macro, clazel_sys passed to a macro as a bare name (m!(clazel_sys)).
  • Submodules: any path from clazel_sys or an alias through a code module, macos::code/linux::code/windows::code anywhere, and a pub re-export of a platform module (macos, linux, windows), including pub use ...::macos::{self as p}.

Still allowed: clazel_sys::macos::window::{self as sys} (clazel-window), and a private alias of a platform module (use clazel_sys::macos as os;, clazel-renderer). The alias is followed: os::code::x and os::enter are refused.

Rule 10 (the single code-entry call)

In crates/clazel-sys/src/enter.rs: exactly one fn enter, at module level (a second one in a nested module or an impl, or an enter that is only a method, is refused). Its parameters are pinned to region: &CodeRegion, entry: Validated, ctx: &mut Context. Its body must contain exactly the four let statements (offset, stub = region.base(), entry = stub.checked_add(offset).ok_or(..)?, raw from ctx) and no other let, loop, match or closure that could rebind them. The single call of run must have the arguments stub, raw, entry, region.len(). The existing "run named only in enter, called once" check is kept.

Tests

  • rule_11_refuses_the_evasions_found_in_the_277_audit: every evasion from the audit plus further variants (raw identifiers, macros, brace wrappers, pub extern crate, submodule aliases and re-exports, unique names in a file that never names the crate).
  • rule_11_still_allows_the_legitimate_uses: clazel-window and clazel-renderer forms, macro uses of clazel_sys:: paths, other crates' enter and Validated.
  • rule_10_pins_enter_and_its_arguments_to_run: a second enter at module level, nested, or a method; no enter; other signature; other arguments to run; changed or extra bindings; loop, closure and match around the call.
  • The existing rule 10 tests now use an enter shaped like the real one.

Results

  • cargo fmt: clean
  • cargo clippy -p xtask --all-targets -- -D warnings: clean
  • cargo test -p xtask: 148 passed
  • cargo xtask check: STATIC CHECKS PASSED on the real tree, clazel-sys audit PASS, no false positives

cargo xtask verify --changed was not run; CI's full verification has not run on this PR, so it is not done by that standard. Nothing in clazel-sys changed, so no new audit row is needed.

🤖 Generated with Claude Code

Rule 11: raw identifiers compare as the plain name; names unique to the
code-region API are refused in every file; brace-wrapped, macro-passed, pub
extern crate and re-exported platform-module forms are refused; the code
submodules cannot be named. Rule 10: exactly one module-level fn enter, with
the arguments to run and their bindings pinned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The maintainer's decision E1 of 2026-11-16 adds one allowed shape of
unsafe to rule 1: the single code entry in clazel-sys's enter.rs, which
xtask rules 10 and 11 already enforce.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@atiernan

Copy link
Copy Markdown
Member Author

Added the CLAUDE.md rule 1 code-entry wording (abf156f), as the maintainer asked; this completes J.0(a)'s 'rule 1 gains the code-entry category in the same change as J.7'. A separate reviewer session checked it against jit.md E1, xtask rules 10 and 11, and enter.rs's SAFETY comments; its two corrections (Validated is only meant to be built by clazel-codecheck, since the checker bars only other crates from naming it; and the SAFETY comment cites the W^X man page and the ABI document, not a libc declaration) are in. cargo xtask check: STATIC CHECKS PASSED.

🤖 Generated with Claude Code

…s it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@atiernan
atiernan deployed to full-verification November 22, 2026 18:28 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
full-verification — 9776efb6 Deployed Nov 22, 2026 by atiernan via Approve the proofs #772
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.

1 participant