add a pyodide-based "sandbox" flavor #437
Merged
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.
This adds a new
GRIST_SANDBOX_FLAVOR=pyodide
option where the version of Python used for the data engine is compiled to wasm, and so can be run by node like the rest of the back end. It still runs as a separate process.There are a few small version changes made to packages to avoid various awkwardness present in the current versions.
This is very experimental. To use, you'll need something with a bash shell and make. First do:
Then running Grist as:
should work. Adding a formula with content:
should return a different Python version than other sandboxes.
I haven't done much in the way of benchmarking. The sandbox has an extra startup time somewhat comparable to runsc. It feels usable on moderate sized docs on my Linux machine. Felt maybe a little sluggish on an older Mac?
The motivation for this work is to have a form of sandboxing that will work on Windows for Grist Electron (for Linux we have gvisor/runsc, for Mac we have sandbox-exec, but I haven't found anything comparable for Windows). Pyodide doesn't actually make any security promises I've found when running on node so I'm not making any claims either at this time.
It also brings a back-end-free version of Grist a bit closer, for use-cases where that would make sense - such as serving a report (in the form of a Grist document) on a static site.
The Pyodide version I used currently offers Python 3.10, which is different from our current standard of 3.9. I haven't added any automated tests for this sandbox flavor yet.