extism / extism

The framework for building with WebAssembly (wasm). Easily load wasm modules, move data, call functions, and build extensible apps.

Home Page:https://extism.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getting a list of a plugin’s exported functions

Somfic opened this issue · comments

Hi.

I was wondering if it’d be possible to, given a Plugin, figure out which functions are exported by it?

Hey - we don't officially support this via Extism, but you can use another tool we make, Modsurfer. Either statically, via the web0 or CLI1, or dynamically in a program using it as an Extism plugin2.

For 2, via an Extism plugin, you would call the export parse_module, passing it the bytes of your wasm plugin, and in return, the plugin will provide a Module protobuf.

We provide Go and Rust libraries, but you can also generate your own protobuf library in any language they support using the api.proto as the definition. See the files here: https://github.com/dylibso/modsurfer/tree/main/proto/v1

Awesome thanks for the quick help!

For sure! If you have any issues with these approaches, please let us know. I might also add another export to this plugin (would be a new .wasm) which would just list the exports by name in a JSON list ["count_vowels", "etc"] so you don't need to deal with the protobuf types... would that help?

@Somfic -- ok, the Extism plugin0 (new version to download) has an export called list_extism_funcs, which just returns the exports that you can call from Extism specifically.

The usage is like:

cat plugin.wasm | extism call modsurfer.wasm list_extism_funcs --stdin | jq 
["export_1", "export_2", ...]

I'd love to see this exposed via the Plugin API. It would be a great way to verify that the module you've been given adheres to a certain contract.

I’ll reopen the issue as per slyons’ suggestion

I agree it would be convenient, but would recommend using the modsurfer plugin approach for now. Mainly since it could be some time until we decide to implement this especially across all the runtimes and SDKs.

Will use the modsurfer plugin for now then! :)