Harden load/compile pipeline, generated bindings, and eq install - #1
Conversation
Bugbot couldn't run - usage limit reachedBugbot 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) |
|
Tick the box to add this pull request to the merge queue (same as
|
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#. Co-authored-by: Max Carter <undivisible@vk.com>
Clang targeting x86_64-pc-windows-msvc rejects -fPIC. Keep PIC flags on Unix; skip them (and Nim/D/Odin PIC equivalents) on Windows. Amp-Thread-ID: https://ampcode.com/threads/T-01a0a631-cbad-764e-a59c-662f4c6e0902 Co-authored-by: Max Carter <undivisible@vk.com>
|
Rebased onto current `main` and omitted `-fPIC` (and Nim/D/Odin PIC equivalents) on Windows so MSVC clang can compile C objects. Unix still passes PIC flags. Local: `cargo test --all-features`, clippy `-D warnings`, demo-app and full-demo binaries ran successfully. |
d238dfd to
97c6553
Compare
Bugbot couldn't run - usage limit reachedBugbot 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_b7b45ae4-3909-49ef-8e99-7d4d3fa41e59) |
Summary
Implements the high-severity SAFE subset from the burn audit:
Honest
load()/compile_to_c-c -fPIC), not preprocessor output..o/.a/.c)..his copied for bindings.LoadOptions.compile/linkare honored. Binding errors surface asLoadError::BindingFailed.compile_args/link_argsare validated (no-fplugin,@response, output overrides,-Wl).demo-appandfull-demonow usecc+generate_bindings+include!and actually link.Polyglot TUI
polyglot.rstypechecks.Compiler argv /
find_compiler-fPIC -OReleaseFast. Nim: nimcache under the output dir,--app:staticlib --noMain --mm:none --passC:-fPIC. Odin:-file -reloc-mode:pic. C/C++/D: PIC.version_args(versionvs--version). Resolvedcompiler_pathis stored. C# also probesdotnet.compile_batchmaps thread panics toCompileErrorinstead ofunwrap.Generated Rust hardening
^[A-Za-z_][A-Za-z0-9_]*$; enum discriminants are integer literals only.eq installeq install cno longer installs C#.EQ_INSTALL_YES=1to opt in;EQ_INSTALL_NO_SUDO=1still skips system PMs).Command.current_dir(TEMP)instead of process-globalset_current_dir. Winget gets non-interactive accept flags.Follow-ups (not in this PR)
{.ffi.}/@ffihonesty and rust-ffi null checks.bindings.code, fmt gate, lockfile, dashboard.html).crepuscularity-tui(clone-alone).Test plan
cargo test --all-featurescargo clippy --all-targets --all-features -- -D warningscargo fmt -- --checkcargo builddemo-app and full-demo; ran both binariesNote
Medium Risk
Changes compiler invocation, generated code emission, and privileged package installs; mistakes could break builds or block installs, but the intent is to reduce injection and unsafe FFI generation.
Overview
Hardens the FFI toolchain after a security audit: compile/load now emits real PIC objects (not C preprocessor output), picks language-appropriate artifacts, requires outputs to exist, copies sibling headers for bindings, honors
LoadOptions.compile/link, validates extra compile/link flags, and emits Cargo link instructions when appropriate. Binding generation failures propagate as errors instead of being swallowed.Generated Rust from headers is stricter: valid C identifiers only, integer-only enum discriminants (blocks injection like
include!in discriminants), checked type mapping (no raw passthrough of unknown types), and tighter ABI-safe import rules.eq installgains exact compiler matching (including C# aliases, hint whencis mistaken for C#), interactive confirmation before sudo (withEQ_INSTALL_YES/ non-TTY refusal), sequential installs, non-interactive winget flags, and Windows UNC cwd handling viaCommand.current_dirinstead of mutating the process cwd.Examples (
demo-app,full-demo) compile C withcc, callgenerate_bindings, andinclude!generated bindings so demos actually link. Polyglot GUI drops ~190 lines of broken constellation animation sopolyglot.rstypechecks. Compiler detection stores resolvedcompiler_path, uses per-language version argv, and updates Zig/Nim/Odin/C compile invocations (PIC, nimcache, staticlib, etc.).Reviewed by Cursor Bugbot for commit 97c6553. Configure here.