sbe-core 0.4.0

Core library for sbe — cross-platform sandbox executor for supply chain defense
Documentation
# sbe built-in default profiles.
# Embedded into the binary at compile time via include_str!.
#
# Path conventions:
#   ~ expands to home dir, $PWD to working directory
#   Trailing / means directory → SBPL subpath (recursive match)
#   No trailing / means file   → SBPL literal (exact match)

common:
  allowRead:
    - "$PWD/"

  denyRead:
    # SSH / GPG
    - "~/.ssh/"
    - "~/.gnupg/"
    # Cloud credentials
    - "~/.aws/"
    - "~/.azure/"
    - "~/.config/gcloud/"
    - "~/.kube/config"
    # macOS Keychain
    - "~/Library/Keychains/"
    # Container / registry auth
    - "~/.docker/config.json"
    - "~/.netrc"
    # Package manager tokens
    # NOTE: ~/.npmrc is NOT denied — yarn/npm need it for registry config.
    # Token exfiltration is mitigated by proxy domain filtering.
    - "~/.cargo/credentials.toml"
    - "~/.cargo/credentials"
    - "~/.pypirc"
    - "~/.hex/hex_api_key"
    - "~/.config/gh/"
    # Environment secrets
    - "$PWD/.env"
    - "$PWD/.env.local"
    - "$PWD/.env.production"
    # Browser profiles
    - "~/Library/Application Support/Google/Chrome/"
    - "~/Library/Application Support/Firefox/"
    - "~/Library/Application Support/Microsoft Edge/"
    - "~/Library/Application Support/BraveSoftware/Brave-Browser/"
    - "~/Library/Safari/"

  denyExec:
    - "/usr/bin/osascript"
    - "/usr/bin/security"
    - "/usr/sbin/screencapture"
    - "/usr/bin/open"
    - "/usr/bin/pbcopy"
    - "/usr/bin/pbpaste"

  allowExec:
    - "/usr/bin/true"
    # Shells
    - "/bin/sh"
    - "/bin/bash"
    - "/bin/zsh"
    - "/usr/bin/env"
    # Core utilities
    - "/usr/bin/basename"
    - "/usr/bin/dirname"
    - "/usr/bin/cat"
    - "/usr/bin/head"
    - "/usr/bin/tail"
    - "/usr/bin/cut"
    - "/usr/bin/tr"
    - "/usr/bin/sed"
    - "/usr/bin/awk"
    - "/usr/bin/grep"
    - "/usr/bin/sort"
    - "/usr/bin/uniq"
    - "/usr/bin/wc"
    - "/usr/bin/tee"
    - "/usr/bin/xargs"
    - "/usr/bin/find"
    - "/usr/bin/touch"
    - "/usr/bin/mktemp"
    - "/usr/bin/install"
    - "/usr/bin/test"
    - "/usr/bin/expr"
    - "/usr/bin/printf"
    - "/usr/bin/readlink"
    - "/usr/bin/uname"
    - "/bin/cp"
    - "/bin/mv"
    - "/bin/rm"
    - "/bin/mkdir"
    - "/bin/rmdir"
    - "/bin/ln"
    - "/bin/ls"
    - "/bin/cat"
    - "/bin/chmod"
    - "/bin/date"
    - "/bin/echo"
    - "/bin/test"
    - "/bin/expr"
    - "/bin/dd"
    - "/bin/sleep"
    - "/usr/bin/sleep"
    # Git — used by husky, build scripts, mix deps.get, etc.
    # Network access is still proxy-controlled; git over HTTPS goes through proxy.
    - "/usr/bin/git"
    - "/opt/homebrew/bin/git"
    - "/usr/local/bin/git"
    # Archive / compression
    - "/usr/bin/tar"
    - "/usr/bin/gzip"
    - "/usr/bin/bzip2"
    - "/usr/bin/unzip"
    - "/usr/bin/zip"
    # Build toolchain
    - "/usr/bin/make"
    - "/usr/bin/cc"
    - "/usr/bin/ar"
    - "/usr/bin/ranlib"
    - "/usr/bin/strip"
    - "/usr/bin/ld"
    - "/usr/bin/as"
    - "/usr/bin/nm"
    - "/usr/bin/libtool"
    - "/usr/bin/install_name_tool"
    # Zig — pure compiler/linker, no network access
    - "/opt/homebrew/bin/zig"
    - "/usr/local/bin/zig"
    # Xcode / Command Line Tools (directories — contain toolchains)
    - "/Applications/Xcode.app/"
    - "/Library/Developer/CommandLineTools/"
    # cmake / pkg-config
    - "/opt/homebrew/bin/cmake"
    - "/usr/local/bin/cmake"
    - "/opt/homebrew/bin/pkg-config"
    - "/usr/local/bin/pkg-config"
profiles:
  node:
    allowWrite:
      - "$PWD/node_modules/"
      - "$PWD/package-lock.json"
      - "$PWD/yarn.lock"
      - "$PWD/pnpm-lock.yaml"
      - "$PWD/bun.lock"
      - "$PWD/.yarn/"
      - "$PWD/.pnp.cjs"
      - "$PWD/.pnp.loader.mjs"
      - "~/.npm/"
      - "~/.cache/yarn/"
      - "~/Library/Caches/Yarn/"
      - "~/.yarn/"
      - "~/.local/share/pnpm/"
      - "~/.bun/"
      - "~/.cache/bun/"
    allowDomains:
      - "registry.npmjs.org"
      - "registry.yarnpkg.com"
      - "registry.npmmirror.com"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "/usr/local/bin/node"
      - "/opt/homebrew/bin/node"
      # actions/setup-node installs into this non-system toolcache on hosted runners.
      - "/Users/runner/hostedtoolcache/node/"
      - "~/.nvm/"
      - "~/.volta/"
      - "~/.fnm/"
      - "~/.local/share/fnm/"
      - "~/.local/state/fnm_multishells/"
      # mise (polyglot version manager)
      - "~/.local/share/mise/"
      - "/usr/bin/xcodebuild"
      - "/usr/bin/xcrun"

  rust:
    allowWrite:
      - "$PWD/target/"
      - "$PWD/Cargo.lock"
      - "~/.cargo/registry/"
      - "~/.cargo/git/"
      # NOTE: ~/.cargo/bin/ is NOT writable — prevents trojaning cargo binaries
      - "~/.cache/zig/"
    allowDomains:
      - "crates.io"
      - "static.crates.io"
      - "index.crates.io"
      - "static.rust-lang.org"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "~/.cargo/bin/"
      - "~/.rustup/toolchains/"
      - "/usr/bin/xcrun"
      - "/usr/bin/xcodebuild"
      - "~/Library/Caches/cargo-zigbuild/"
      # Homebrew-managed rustup (`brew install rustup` — used by GH
      # macos-latest runners). ~/.cargo/bin/cargo is a relative symlink
      # to `rustup` → /opt/homebrew/bin/rustup-init →
      # /opt/homebrew/Cellar/rustup/<ver>/bin/rustup-init. macOS
      # sandbox-exec resolves symlinks before matching process-exec, so
      # the real Cellar path must be covered. resolve_symlinks() in
      # profile/mod.rs canonicalises each listed binary at runtime and
      # adds the Cellar package directory automatically.
      - "/opt/homebrew/bin/rustup"
      - "/opt/homebrew/bin/rustup-init"
      - "/opt/homebrew/Cellar/rustup/"
      - "/opt/homebrew/Cellar/rustup-init/"
      - "/opt/homebrew/opt/rustup/"
      - "/opt/homebrew/opt/rustup-init/"
      - "/usr/local/bin/rustup"
      - "/usr/local/bin/rustup-init"
      - "/usr/local/Cellar/rustup/"
      - "/usr/local/Cellar/rustup-init/"
      - "/usr/local/opt/rustup/"
      - "/usr/local/opt/rustup-init/"

  python:
    allowWrite:
      - "$PWD/uv.lock"
      - "$PWD/poetry.lock"
      - "$PWD/pdm.lock"
      - "~/.cache/pip/"
      - "~/.cache/uv/"
      - "~/.local/lib/"
      # NOTE: ~/.local/bin/ is NOT writable — prevents trojaning user binaries
      - "$PWD/.venv/"
      - "$PWD/venv/"
      # Poetry cache
      - "~/Library/Caches/pypoetry/"
      - "~/.cache/pypoetry/"
      # PDM cache
      - "~/.local/share/pdm/"
      - "~/Library/Caches/pdm/"
    allowDomains:
      - "pypi.org"
      - "files.pythonhosted.org"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      - "/usr/bin/python3"
      - "/opt/homebrew/bin/python3"
      - "/opt/homebrew/bin/pip3"
      - "/opt/homebrew/bin/uv"
      - "/usr/local/bin/python3"
      - "/usr/local/bin/pip3"
      - "/usr/local/bin/uv"
      # actions/setup-python uses a fixed, non-relocatable macOS toolcache.
      - "/Users/runner/hostedtoolcache/Python/"
      # Toolcache launchers resolve into this fixed framework installation.
      - "/Library/Frameworks/Python.framework/Versions/"
      # Version managers
      - "~/.pyenv/"
      - "~/.local/bin/"
      # uv-managed Python installations
      - "~/.local/share/uv/"
      # Rye-managed Python
      - "~/.rye/"
      # mise (polyglot version manager)
      - "~/.local/share/mise/"

  elixir:
    allowWrite:
      - "$PWD/deps/"
      - "$PWD/_build/"
      - "$PWD/mix.lock"
      - "~/.hex/"
      - "~/.mix/"
      - "~/.cache/rebar3/"
    allowDomains:
      - "hex.pm"
      - "repo.hex.pm"
      - "builds.hex.pm"
      - "cdn.hex.pm"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
    allowExec:
      # Homebrew / system shim wrappers
      - "/usr/local/bin/elixir"
      - "/usr/local/bin/mix"
      - "/usr/local/bin/iex"
      - "/usr/local/bin/erl"
      - "/usr/local/bin/epmd"
      - "/opt/homebrew/bin/elixir"
      - "/opt/homebrew/bin/mix"
      - "/opt/homebrew/bin/iex"
      - "/opt/homebrew/bin/erl"
      - "/opt/homebrew/bin/epmd"
      # Real binaries the wrappers exec into (versioned Cellar paths)
      - "/opt/homebrew/Cellar/elixir/"
      - "/opt/homebrew/Cellar/erlang/"
      - "/opt/homebrew/opt/elixir/"
      - "/opt/homebrew/opt/erlang/"
      - "/usr/local/Cellar/elixir/"
      - "/usr/local/Cellar/erlang/"
      - "/usr/local/opt/elixir/"
      - "/usr/local/opt/erlang/"
      # Version managers
      - "~/.asdf/"
      - "~/.kiex/"
      - "~/.local/share/mise/"

  java:
    # SBE injects authenticated JVM proxy properties after allocating the
    # per-run proxy port, so Maven/sbt HTTPS stays on the exact proxy route.
    enableProxy: true
    allowWrite:
      - "~/.m2/repository/"
      - "$PWD/.gradle/"
      - "$PWD/build/"
      - "$PWD/target/"
      # Scala / sbt
      # Coursier (Scala dependency manager)
    allowDomains:
      - "repo1.maven.org"
      - "repo.maven.apache.org"
      - "plugins.gradle.org"
      - "services.gradle.org"
      - "downloads.gradle.org"
      - "downloads.gradle-dn.com"
      - "jcenter.bintray.com"
      - "github.com"
      - "codeload.github.com"
      - "objects.githubusercontent.com"
      # Scala
      - "repo.scala-sbt.org"
      - "repo1.scala-sbt.org"
      - "scala-ci.typesafe.com"
      - "downloads.lightbend.com"
    allowExec:
      - "/usr/bin/java"
      - "/usr/libexec/java_home"
      - "/opt/homebrew/opt/openjdk/"
      - "/Library/Java/JavaVirtualMachines/"
      # actions/setup-java installs Temurin distributions here on hosted runners.
      - "/Users/runner/hostedtoolcache/Java_Temurin-Hotspot_jdk/"
      - "~/.sdkman/"
      # Gradle wrapper and daemon
      - "~/.gradle/"
      # Coursier downloads launchers here
      - "~/.cache/coursier/"
      - "~/Library/Caches/Coursier/"
      # Scala / sbt tools
      - "/opt/homebrew/bin/sbt"
      - "/opt/homebrew/bin/scala"
      - "/opt/homebrew/bin/scalac"
      - "/usr/local/bin/sbt"
      - "/usr/local/bin/scala"
      - "/usr/local/bin/scalac"
      # Project-local wrappers
      - "$PWD/gradlew"
      - "$PWD/mvnw"
      # Version managers
      - "~/.local/share/mise/"
      - "~/.asdf/"
      - "~/.jenv/"