wasmoon icon indicating copy to clipboard operation
wasmoon copied to clipboard

General Questions / File Access

Open dannysmc95 opened this issue 8 months ago • 3 comments

Hi there!

I might be being a little dumb, but I have a use case for some scripting related tasks within a Bun.sh framework I am working on, and I see that Wasmoon seems to be a maintained and looking like a pretty solid project, but I am struggling with some ideas that I don't see is covered.

If there is documentation, feel free to point that out to me.

At the moment, I am writing files, but as of now, I don't know where those files actually go, (writing the files from within the the Lua engine using io. I can see options for like loadFile but entirely unsure how these work, as they aren't typed, so I can't see what they actually return/do. I can see that writing a file like test.txt and then loading the file just returns null, so unsure how that works as the code doesn't error either.

What kind of security does this have? for example if a user was to write a script, what can they access from within the engine that I don't specifically give them?

And then generally, like what features are available? other than running Lua scripts, what else can I do within this framework? like I see there are environment variables you can give the LuaFactory, but I don't see any documentation.

Also how do I open files from within my own file system, can I pass references? or?

Any pointers would be great as to where to look to get answers would be heavily appreciated.

Thanks,

dannysmc95 avatar Apr 29 '25 15:04 dannysmc95

Wasmoon is a purist distribution without any tricks from Lua Puc Rio. Since it runs on WebAssembly, it is isolated on a virtual machine. IO exists, but if you don't mount a folder, the data won't persist. I don't know how to interact this on the host machine.

But if you're interested in sandboxing and other things, I maintain a framework/CLI that interacts with machine files written in Lua and running with Wasmoon. I used another project by @ceifa called Demoon.

RodrigoDornelles avatar Apr 29 '25 21:04 RodrigoDornelles

@RodrigoDornelles hey, thanks for the response, I'm absolutely fine with doing it all myself, the sandbox by default is what I'm after.

I was just hoping for some documentation, i.e. how do I mount files/access the underlying file system etc, it's more about documentation I'm after.

I just am struggling to find any relevant docs that show me the features that it has, i.e. how to mount files, and use the filesystem, for example where does io.write actually go to? Can I access that data, etc

dannysmc95 avatar Apr 29 '25 22:04 dannysmc95

Hey @dannysmc95. As @RodrigoDornelles said, everything in wasmoon is sandboxed by default, so io.write will actually go to the process memory, not the file system. If you want to interact with the file system you would probably have to mount files and overwrite the io methods.

I'm working on a 2.0, where it will be easier to switch from the mem sandbox to the actual FS.

I see that the lack of documentation it's a problem, I also want to improve that (PRs welcome). But for now, I think people are just installing wasmoon and checking the typescript declarations to see what it can do. Some methods have a JSDoc but in overall the names are kind of self-explanatory too.

ceifa avatar May 21 '25 11:05 ceifa