fix(ets): route ETS-specific functions through sandbox adapter#37
Merged
MikaAK merged 2 commits intoMikaAK:mainfrom Mar 16, 2026
Merged
fix(ets): route ETS-specific functions through sandbox adapter#37MikaAK merged 2 commits intoMikaAK:mainfrom
MikaAK merged 2 commits intoMikaAK:mainfrom
Conversation
f201b7c to
5688897
Compare
Owner
|
I think this is a fundamental problem with the ets adapter, it probably should be calling something the module attribute to allow the sandbox switchover 🤔 |
Collaborator
I am open to feedback. If you want this to work differently let me know. I was optimistically trying to use the new ETS functionality you added, and found out that these functions don't play nice with the sandbox, so i whipped something up to cover the gap. |
ETS-specific functions in the __using__ macro were calling :ets directly, bypassing sandbox isolation. Move all calls through @cache_adapter so the sandbox adapter is used when sandbox?: true is configured. Add corresponding module-level functions to Cache.ETS that delegate to :ets, matching the signatures already present in Cache.Sandbox.
5688897 to
857efbf
Compare
…hing Without this clause, nested tuples in sandbox data were compared with strict equality instead of recursive pattern matching via match_pattern?.
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.
Summary
update_counter/2,update_counter/3,insert_raw/1,match_object/1,match_object/2) were bypassing sandbox isolation by calling:etsdirectly instead of routing through@cache_adapterdefoverridablewrappers in the__using__macro (lib/cache.ex) that prefix keys viamaybe_sandbox_keyand dispatch through@cache_adapterwhensandbox?: trueandadapter: Cache.ETSCache.Sandbox) already had implementations for these functions — they just were never called from the generated moduleTest plan
test/cache/ets_sandbox_test.exswith 11 tests verifying sandbox isolation for all affected functionsredis_json_test.exsis pre-existing and unrelated)