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 ofexec 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
hostslist 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 incurl/gh api, and withgit -c http.extraHeader=....
Note: embedding credentials in a URL such asgit clone https://user:[email protected]/...does not work with Secret — git Base64-encodes the credentials intoAuthorization: Basic ..., and once encoded the placeholder can no longer be matched verbatim for substitution. For git, usehttp.extraHeaderto 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-levelBox.exec(...)returns anExecution(a streaming handle); callawait execution.wait()to get the exit code. If you only need the three fieldsexit_code/stdout/stderrand want something simpler, preferSimpleBox(as in the Quick Example), whoseexecreturns anExecResultdirectly. The low-levelBoxis 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). Ifghis not pre-installed, usecurl, 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:

