Skip to main content
A sandbox is a networked Linux machine, so git and gh work as they always do through SimpleBox.exec(...). What BoxLite adds is the safety layer around them: the token stays on the host, and outbound access narrows to GitHub.

Quick Example

Install git inside an Ubuntu sandbox, clone a public repository, and read the most recent commit. The whole snippet is ready to copy and run (cloning a public repo needs no token).

Injecting GITHUB_TOKEN with Secret (push / private repos)

The command-line arguments and logs of exec may be recorded, so do not embed the token in a URL or on the command line. Secret provides stronger isolation: the real token never enters the sandbox. How Secret works (note how it differs from “injecting an environment variable”):
  • Inside the sandbox, only a placeholder environment variable appears: BOXLITE_SECRET_<UPPERCASE_NAME>, whose value is the placeholder string <BOXLITE_SECRET:<name>> (not the real token).
  • When a program inside the sandbox makes an HTTP(S) request to a host in the hosts list and the placeholder appears in a request header, the URL query string, or the request body (the URL path is not substituted), BoxLite’s MITM proxy substitutes the placeholder with the real value on the outbound path before forwarding. The real value exists only in the host proxy and never lands inside the sandbox.
  • So the usage is: put the placeholder in headers such as Authorization. This fits naturally with Bearer auth in curl / gh api, and with git -c http.extraHeader=....
Note: embedding credentials in a URL such as git clone https://user:[email protected]/... does not work with Secret — git Base64-encodes the credentials into Authorization: Basic ..., and once encoded the placeholder can no longer be matched verbatim for substitution. For git, use http.extraHeader to place the placeholder in plaintext in a request header (see the example below).
SimpleBox(..., secrets=[...]) works too — it forwards the list to BoxOptions. The example below uses the low-level Boxlite + Box only to make the runtime lifecycle explicit.
Tip: the low-level Box.exec(...) returns an Execution (a streaming handle); call await execution.wait() to get the exit code. If you only need the three fields exit_code / stdout / stderr and want something simpler, prefer SimpleBox (as in the Quick Example), whose exec returns an ExecResult directly. The low-level Box is used here only to make the runtime lifecycle explicit. Likewise, when calling the GitHub REST API, put the placeholder in the Bearer header (the proxy substitutes the real value). If gh is not pre-installed, use curl, for example: curl -H "Authorization: Bearer <BOXLITE_SECRET:github_token>" https://api.github.com/user.

Parameters & Returns

This page introduces no new API; it only reuses existing capabilities. The tables below list the real parameters relevant to “running Git inside a sandbox”.

SimpleBox.exec(cmd, *args, ...) key parameters

Returns ExecResult:

Secret(...) (credential injection entry point)

NetworkSpec(...) (outbound narrowing)

Troubleshooting