codecalc-exec 0.3.0

Sandboxed multi-language executor core for codecalc (Rust)
[package]
name = "codecalc-exec"
version = "0.3.0"
edition = "2024"
# Declared, not merely implied. rust-toolchain.toml pins 1.97.1 for anyone
# building IN this repo, but it is not Cargo metadata and does not reach a
# crate that depends on this one — that needs `rust-version`, which was absent.
# A crates.io consumer on an older toolchain therefore got no MSRV signal at
# all and would have hit a raw compile error instead of Cargo's named one.
# 1.97 matches what README.md already tells people to install; edition 2024
# itself only needs 1.85, so this floor is set by the repo, not by the edition.
rust-version = "1.97"
description = "Sandboxed multi-language executor core for codecalc (Rust)"
# Must match pyproject.toml and LICENSE — scripts/check_claims.py gates this.
# Was "MIT" while the repo LICENSE and pyproject disagreed: the crate
# compiles into bin/codecalc-exec, which is distributed, so the two cannot differ.
license = "Apache-2.0"
# crates.io warns without these, and the warning is worth heeding for THIS
# crate specifically: it compiles into the binary that runs untrusted code, so
# the first thing anyone evaluating it should be able to do is find the source
# and the audit. A crates.io page with no repository link makes that harder
# than it needs to be.
repository = "https://github.com/The-40-Thieves/codecalc"
homepage = "https://github.com/The-40-Thieves/codecalc"
keywords = ["sandbox", "executor", "mcp", "rlimit", "seccomp"]
categories = ["command-line-utilities", "development-tools"]

[dependencies]
serde_json = "1"

# Platform sandboxing is genuinely different per OS, so the bindings are scoped
# rather than pulled in everywhere: rlimits + wait4 + killpg on Unix, Job Objects
# on Windows. See src/platform/.
[target.'cfg(unix)'.dependencies]
libc = "0.2"

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = [
    "Win32_Foundation",
    # CreateJobObjectW takes a SECURITY_ATTRIBUTES pointer, so it is gated behind
    # this feature even though we pass null. Also carries SECURITY_CAPABILITIES,
    # SID_AND_ATTRIBUTES, PSID/ACL and FreeSid for the THE-829 AppContainer path.
    "Win32_Security",
    # THE-829 (OFF by default, UNVERIFIED on real Windows 11): least-privilege
    # AppContainer profile create/derive/delete lives here...
    "Win32_Security_Isolation",
    # ...and the explicit-ACL grant (SetNamedSecurityInfoW / SetEntriesInAclW,
    # EXPLICIT_ACCESS_W, TRUSTEE_W) that hands only the workdir to the AC SID.
    "Win32_Security_Authorization",
    "Win32_System_JobObjects",
    "Win32_System_Threading",
    # Thread32First/Next. The child is created suspended and assigned to the job
    # before its first instruction, but `std::process::Command` does not expose
    # the initial thread handle, so the thread to resume is found by snapshotting
    # and filtering on the owning PID. See platform/windows.rs::resume_process.
    "Win32_System_Diagnostics_ToolHelp",
    # FILE_ATTRIBUTE_REPARSE_POINT — the zero-length-stub fallback in
    # resolve_command_program refuses a Store app-execution alias reached by a
    # path form the Microsoft\WindowsApps name match misses (THE-818).
    "Win32_Storage_FileSystem",
] }

# ── Older-computer optimizations ──────────────────────────────────────────
# - target-cpu=generic: no modern instruction-set requirements (runs on any
#   x86_64/aarch64 CPU from the last ~15 years). Rust's default is already
#   generic, but pinned explicitly via .cargo/config.toml so a host-specific
#   -C flag can't leak in.
# - opt-level="z": prioritize binary size over speed — this binary spawns
#   children and does no hot loops, so size is what matters.
# - lto + codegen-units=1 + panic=abort: maximize cross-crate inlining and
#   drop unwind machinery, shrinking the binary further.
# - strip=true: no debug symbols.
# - overflow-checks=false: release-mode arithmetic without panics (matches
#   the Python fallback's behavior; nothing here trusts user integers).
[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
strip = true
overflow-checks = false