Skip to content

✨ feat(mq-lang,mq-run): add --allow-env sandbox flag - #2091

Merged
harehare merged 3 commits into
mainfrom
feat/allow-env-sandbox
Jul 27, 2026
Merged

✨ feat(mq-lang,mq-run): add --allow-env sandbox flag#2091
harehare merged 3 commits into
mainfrom
feat/allow-env-sandbox

Conversation

@harehare

Copy link
Copy Markdown
Owner

Summary

$VAR/${$VAR} interpolation and debugger logpoints previously read any host environment variable regardless of --allow-read/write/net/run, letting an untrusted query exfiltrate secrets into its output. Gate env_var behind SandboxedIo the same way, fail-safe deny by default, with --allow-env / --allow-env=NAME,... to opt in (mirrors --allow-read/ --allow-write's PathAccess shape via a new EnvAccess type).

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation
  • ⚡ Performance
  • ✅ Test
  • 📦 Build / dependencies
  • 👷 CI

Checklist

  • I ran cargo fmt and cargo clippy and addressed any warnings
  • I ran just test-all and all tests pass
  • I added or updated tests covering this change
  • I updated relevant documentation (/docs, crate README.md) if needed
  • I added a changelog entry if this is a user-facing change

Additional Context

harehare added 3 commits July 27, 2026 21:19
$VAR/${$VAR} interpolation and debugger logpoints previously read any
host environment variable regardless of --allow-read/write/net/run,
letting an untrusted query exfiltrate secrets into its output. Gate
env_var behind SandboxedIo the same way, fail-safe deny by default,
with --allow-env / --allow-env=NAME,... to opt in (mirrors --allow-read/
--allow-write's PathAccess shape via a new EnvAccess type).

Distinguishes "not permitted" from "not found" via a new
SyntaxError::EnvNotAllowed for parse-time $VAR, and the existing
generic RuntimeError::Runtime for the interpolation/logpoint paths.
…bmodules

PathAccess and EnvAccess were both defined inline in sandboxed.rs
alongside SandboxedIo itself. Move each into its own file under
io/sandboxed/ (path_access.rs, env_access.rs) so the module mirrors
the type it groups, keeping sandboxed.rs focused on SandboxedIo.
README.md and docs/books/src/reference/cli.md's CLI option listing is
regenerated from the released mq binary's --help output via
scripts/update_doc.sh, not the in-development one. Adding these two
flags' entries by hand ahead of release would just get reverted (and
diverge from) the next real docs sync, and can fail CI in the
meantime. They'll appear automatically once mq itself is released
with --allow-run/--allow-env.
@codspeed-hq

codspeed-hq Bot commented Jul 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing feat/allow-env-sandbox (d2cfe58) with main (9b94443)

Open in CodSpeed

@harehare
harehare merged commit fee808f into main Jul 27, 2026
11 checks passed
@harehare
harehare deleted the feat/allow-env-sandbox branch July 27, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant