cozy / cozy-stack

Simple, Versatile, Yours
https://docs.cozy.io/en/cozy-stack/
GNU Affero General Public License v3.0
1.14k stars 138 forks source link

nsjail Versus wasm #3670

Open gedw99 opened 1 year ago

gedw99 commented 1 year ago

Wazero is a no cgo wasm runner and could replace nsjail

nono commented 1 year ago

Hi @gedw99, I'd like to know more about that. We are using nsjail for running imagemagick and nodejs scripts.

For imagemagick, there is a wasm port (https://github.com/dlemstra/magick-wasm), but it didn't support reading PDF (https://github.com/dlemstra/magick-wasm/discussions/51), which is mandatory for us. Same for SVG: https://github.com/dlemstra/magick-wasm/discussions/19. Do you have another way to suggest?

For nodejs scripts, do you have any resource or link on how to compile JS to wasm?

codefromthecrypt commented 1 year ago

apologies for random thoughts but https://github.com/ncruces/dcraw https://github.com/jerbob92/go-pdfium-wasm might be cookie crumbs to find folks in similar situations about images and pdf support for their tools. in most cases there are ports to do. I don't have insight into compiling JS to wasm, but someone else may

gedw99 commented 1 year ago

Will chime here …

sometimes it’s useful to step back and see the best path forward ..

Image transforms can be done in pure go compiled to wasm. Sure you might loose some speed but it’s really clean. There are plenty of golang packages that pretty much do what image magic does.

pdf. As @codefromthecrypt suggested. It works great. There is also pdfcpu which is pure golang .

Wazero is so simple to use and there are sone great golang systems built on top to make it very easy .

capsule is one on GitHub ..