Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting a list of a plugin’s exported functions #714

Closed
Somfic opened this issue May 15, 2024 · 8 comments
Closed

getting a list of a plugin’s exported functions #714

Somfic opened this issue May 15, 2024 · 8 comments

Comments

@Somfic
Copy link

Somfic commented May 15, 2024

Hi.

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

@nilslice
Copy link
Member

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

@Somfic
Copy link
Author

Somfic commented May 15, 2024

Awesome thanks for the quick help!

@Somfic Somfic closed this as completed May 15, 2024
@nilslice
Copy link
Member

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?

@nilslice
Copy link
Member

nilslice commented May 15, 2024

@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", ...]

@slyons
Copy link

slyons commented May 15, 2024

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.

@Somfic
Copy link
Author

Somfic commented May 15, 2024

I’ll reopen the issue as per slyons’ suggestion

@Somfic Somfic reopened this May 15, 2024
@Somfic Somfic changed the title question: get a list of exported functions by a plugin getting a list of a plugin’s exported functions May 15, 2024
@nilslice
Copy link
Member

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.

@Somfic
Copy link
Author

Somfic commented May 24, 2024

Will use the modsurfer plugin for now then! :)

@Somfic Somfic closed this as completed May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants