feat(compat): version compatibility profiles for the Lua sandbox#25
Merged
Conversation
Emulate the Lua sandbox behavior of a chosen Redis/Valkey version. Only
three behaviors actually differ across Redis 6.2-8.x and Valkey:
- `print` global -> present only in Redis 6.2
- `os` library -> Redis 7.4+ / Valkey 8.0+
- `server` alias -> Valkey 8.0+ only (Redis keeps `redis`)
Modeled as three orthogonal flags (COMPAT_PRINT/OS/SERVER_ALIAS) passed as
a u8 bitmask via a new `set_compat()` WASM export, consumed by a shared
`setup_state()` (init/reset deduped). TS exposes `load({ profile, compat })`
where `profile` is a named preset over the version matrix and `compat`
overrides individual flags. Default (no profile) preserves prior behavior
(os + server alias, no print; ~ valkey 8.0).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop valkey-7.2 and valkey-8.1; add valkey-9.0. Profile set is now redis-6.2, redis-7.0, redis-7.2, redis-7.4, redis-8.0, valkey-8.0, valkey-9.0. valkey-9.0 mirrors valkey-8.0 (no known Lua sandbox delta). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make the engine emulate the Lua sandbox behavior of a chosen Redis/Valkey version via a
profileoption.Researched the sandbox setup (
script_lua.c; 6.2 =scripting.c) across redis 6.2/7.0/7.2/7.4/8.0 and valkey 7.2/8.0/8.1. Only three behaviors actually differ — everything else (cjson/cmsgpack/struct/bit/math/table/string, deny of dofile/loadfile, globals protection, setresp/RESP3) is constant since 6.2:printglobaldeny_listat 7.0)oslibraryserver.*aliasHow
Three orthogonal flags (
COMPAT_PRINT/OS/SERVER_ALIAS) as a u8 bitmask, passed via a newset_compat()WASM export and consumed by a sharedsetup_state()(dedupes the near-identicalinit/reset). No per-version build fork — one binary, per-engine choice.profileis a named preset over the version matrix;compatoverrides individual flags. Default (no profile) preserves prior behavior, so this is non-breaking.Test
compat ...tests intest/engine.test.tscovering each profile + override + default.🤖 Generated with Claude Code