Skip to content

Harden load/compile pipeline, generated bindings, and eq install - #1

Open
undivisible wants to merge 1 commit into
mainfrom
fix/burn-audit-hardening
Open

Harden load/compile pipeline, generated bindings, and eq install#1
undivisible wants to merge 1 commit into
mainfrom
fix/burn-audit-hardening

Conversation

@undivisible

@undivisible undivisible commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the high-severity SAFE subset from the burn audit:

  1. Honest load() / compile_to_c

    • C compiles to a PIC object (-c -fPIC), not preprocessor output.
    • Output path uses the language-correct artifact (.o / .a / .c).
    • Compiler success requires the artifact to exist; sibling .h is copied for bindings.
    • LoadOptions.compile / link are honored. Binding errors surface as LoadError::BindingFailed.
    • Extra compile_args / link_args are validated (no -fplugin, @response, output overrides, -Wl).
    • demo-app and full-demo now use cc + generate_bindings + include! and actually link.
  2. Polyglot TUI

    • Removed the dead constellation animation (~190 lines) that referenced undefined types, so polyglot.rs typechecks.
  3. Compiler argv / find_compiler

    • Zig: -fPIC -OReleaseFast. Nim: nimcache under the output dir, --app:staticlib --noMain --mm:none --passC:-fPIC. Odin: -file -reloc-mode:pic. C/C++/D: PIC.
    • Per-language version_args (version vs --version). Resolved compiler_path is stored. C# also probes dotnet.
    • compile_batch maps thread panics to CompileError instead of unwrap.
  4. Generated Rust hardening

    • Identifiers must match ^[A-Za-z_][A-Za-z0-9_]*$; enum discriminants are integer literals only.
    • Unknown C types are not interpolated raw. Pointers require a known pointee for ABI-safe imports.
  5. eq install

    • Exact match on id/bin (plus explicit C# aliases). eq install c no longer installs C#.
    • Sudo requires TTY confirmation (EQ_INSTALL_YES=1 to opt in; EQ_INSTALL_NO_SUDO=1 still skips system PMs).
    • Installs run sequentially. Windows uses Command.current_dir(TEMP) instead of process-global set_current_dir. Winget gets non-interactive accept flags.

Follow-ups (not in this PR)

  • Replace the line C parser with bindgen/libclang.
  • Helper-crate {.ffi.} / @ffi honesty and rust-ffi null checks.
  • Docs/CI hygiene (bindings.code, fmt gate, lockfile, dashboard.html).
  • Polyglot TUI still path-depends on sibling crepuscularity-tui (clone-alone).
  • Compiler timeout / scan_directory symlink cycles.

Test plan

  • cargo test --all-features
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt -- --check
  • cargo build demo-app and full-demo; ran both binaries

Note

Medium Risk
Touches compile invocation, code generation from untrusted headers, and privileged package installs—important for security and build correctness, though guarded by validation and confirmations.

Overview
Hardens the FFI load/compile path and generated Rust bindings, and tightens eq install behavior.

Load & compile: C now builds PIC objects (not preprocessor output), expects the correct artifact extension, copies sibling .h files, and honors LoadOptions.compile / link. Extra compile/link args are validated; binding failures become LoadError::BindingFailed. Demo build.rs files use cc + generate_bindings + include! instead of load().

Bindings & imports: Generated code validates C identifiers, enum discriminants (integer literals only), and types via c_type_to_rust_checked—unsupported or malicious header content is skipped with warnings instead of pasted into Rust.

Compiler detection & argv: Stores resolved compiler_path, per-language version_args, and PIC-oriented flags for Zig/Nim/Odin/C/C++/D. Batch compile maps worker panics to errors.

eq install: Exact compiler name matching (fixes eq install c vs C#), interactive sudo confirmation (EQ_INSTALL_YES), sequential installs, winget non-interactive flags, and Windows UNC cwd handled per-subprocess.

Polyglot GUI: Removes dead constellation animation code so polyglot.rs typechecks.

Reviewed by Cursor Bugbot for commit d238dfd. Configure here.

Compile C to PIC objects instead of preprocessing, honor LoadOptions
compile/link, and make demo-app/full-demo actually compile and link.
Align compiler argv and version probing with the working polyglot
build, reject dangerous extra compile args, and sanitize identifiers
in generated Rust. eq install now requires sudo confirmation, matches
compiler names exactly, and no longer treats "c" as C#.
@cursor

cursor Bot commented Sep 11, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_dd5e858c-9db1-4008-b2cc-92d497687118)

@mergify

mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

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