Comments (8)
@nilslice Thanks, works now!
from extism.
@Simonl9l you can give the plugins access to the file system, you just have to specify it in the manifest explicitly.
Docs: https://extism.github.io/dotnet-sdk/api/Extism.Sdk.Manifest.html#Extism_Sdk_Manifest_AllowedPaths
Example: https://github.com/extism/dotnet-sdk/blob/main/test/Extism.Sdk/BasicTests.cs#L87
from extism.
@henriklundgren - since you’re using your own host function read
, the Manifest configuration does not apply. In the way you have it, your host function goes around the protections / limitations defined in the Manifest - which is fine, just be sure you are ok with a plugin having access to any path on the host.
Using the Manifest, you can map the paths like you have, but compile using —-target wasm32-wasi
, and then you can use normal std
library code to read from the /Target
path which through WASI would map to the hosts /home/NAME/Target
path.
from extism.
thanks for the link to the docs, for some reason they are not obviously visible from elsewhere!
from extism.
Ah - please can you help interpret the difference betwen source and destination for Allowed Paths - https://extism.github.io/dotnet-sdk/api/Extism.Sdk.Manifest.html#Extism_Sdk_Manifest_AllowedPaths
if relative is that relative to the manifest file, or the host process?
from extism.
@Simonl9l source
is the path on the host side. For example, lets say you want to create a folder for each plugin like so:
D:/plugins/123/
and then destination
is the path that will be available for the plugin. For example /mnt
(WASI has a UNIX-style file system)
So the plugin thinks all of the files in D:/plugins/123
are in the /mnt
folder. Basically you're creating a virtual file system for the plugin. This is the folder the test reads from: https://github.com/extism/dotnet-sdk/tree/main/test/Extism.Sdk/data
if relative is that relative to the manifest file, or the host process?
The source path is relative to the host process (but you can provide an absolute path too)
from extism.
I am struggling to get allowed_paths
to work but without success.
If I inline the path in the host_fn
it works as expected.
I am using Rust (v1.78) both as host language and plugin language.
I tried both absolute path and relative (still unclear what it is relative to).
Any help appreciated, thanks.
hostfn!(read(path: String) {
fs::read_dir(path);
});
Manifest {
wasm: vec![url],
allowed_paths: Some(BTreeMap::from([
(
// PathBufs
"/home/NAME/Target",
"/Target"
)
])),
}
// ---- Plugin ----
#[host_fn]
extern "ExtismHost" {
fn read(path: String);
}
#[plugin_fn]
fn get(path: String) {
unsafe { read(path) }
}
Edit: added code
from extism.
@henriklundgren, glad to hear it! we could improve the docs on this, sorry for the confusion.
from extism.
Related Issues (20)
- discord link in readme is expired HOT 6
- Add support for multiple arguments
- Pass plug-in ID into `set_log_callback` callback function
- Error: http: request body too large (recovered by wazero) HOT 5
- option for a WASM instr limit per call HOT 1
- look into calling `_initialize` on all linked plugins when initializing the guest runtime, not just the main module HOT 1
- Question about plugin return types HOT 3
- Cost of the function call throught host/guest boundary HOT 8
- Synchronizing the content of `wasm` folder HOT 2
- feat: add manifest field to limit the size of Extism vars HOT 1
- Extism gem fails to load on Ruby 3.3.0 on macOS HOT 6
- Async / Await / Generators / Coroutines in Plugins HOT 3
- How to unload a plugin? HOT 3
- Could we get access to the `id` on `CurrentPlugin`
- add a feature to control which wasm backend is enabled? HOT 4
- wasm files are very slow to load (C# PDK, Rust SDK) HOT 7
- getting a list of a plugin’s exported functions HOT 8
- ZMQ with Extism Plugins HOT 6
- allowlist WASI features/interfaces HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extism.