Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@olblak
Copy link
Member

@olblak olblak commented Dec 4, 2025

Related to #5730

Add support for custom autodiscovery plugin using WASM.

This feature leverage the WASM framework Extism which allows writing plugin using Rust, JS, Go, C#, F#, C, Haskell, and Zig

I also created this repository https://github.com/updatecli/plugins to host a plugin example.

A simple Updatecli manifest looks like
Where the autodiscovery crawler kind can be a file with the ".wasm" extension
At the moment it supports local files but we can envision supporting OCI artifacts in order to push/push plugins similar to Updatecli shared policies.

name: Test Custom autodiscovery plugin

autodiscovery:
  crawlers:
    "pkg/plugins/autodiscovery/plugin/testdata/demo.wasm":
      # The source code for this plugin is available autodiscovery
      # https://github.com/updatecli/plugins/tree/main/autodiscovery/demo
      spec:
        files:
          - pkg/plugins/autodiscovery/plugin/testdata/demo/data.txt

Please note that WASM comes with its own set of limitations.

  • A WASM binary is executed within its own container so we need to mount any files that we need to manipulate from the host to the WASM container
  • Depending on the programming language, we may have some limitations.

Test

To test this pull request, you can run the following commands:

cd pkg/plugins/autodiscovery/plugin/
go test .

go build -o bin/updatecli .
./bin/updatecli diff --config e2e/updatecli.d/success.d/autodiscovery/plugin/

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

By default, a WASM container doesn't have access to the host local files. For that we need to allow list some path such as

  crawlers:
    "pkg/plugins/autodiscovery/plugin/testdata/demo.wasm":
      # The source code for this plugin is available autodiscovery
      # https://github.com/updatecli/plugins/tree/main/autodiscovery/demo
      spec:
        allowedpaths:
          - ".:/mnt"

If allowedpaths is unset, then I made the decision to automatically load the local directory or the scm directory if a scm configuration is specified, to reduce the amount of configuration needed in the Updatecli manifest.

By default, a WASM binary is executed from the directory /mnt

Potential improvement

  • Right now the plugin must remain local to the Updatecli manifest file, it would be nice to also support fetching plugins from an OCI registry.

@olblak olblak added enhancement New feature or request experimental Experimental feaure autodiscovery All things related to the autodiscovery feature labels Dec 4, 2025
@olblak olblak requested a review from Copilot December 4, 2025 14:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for custom autodiscovery plugins using WebAssembly (WASM) via the Extism framework. The feature enables users to write custom autodiscovery logic in multiple languages (Rust, JS, Go, C#, F#, C, Haskell, and Zig) that can be executed in a secure sandboxed environment.

Key Changes:

  • Introduces a new WASM-based plugin system for autodiscovery with configurable allowed paths, hosts, and timeouts
  • Integrates plugin support into the existing autodiscovery framework with experimental feature flag protection
  • Provides host functions for plugins to interact with Updatecli's Docker image source spec generation

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
pkg/plugins/autodiscovery/plugin/main.go Core plugin implementation with WASM initialization and manifest discovery logic
pkg/plugins/autodiscovery/plugin/spec.go Plugin specification structure defining allowed paths, hosts, and timeout configuration
pkg/plugins/autodiscovery/plugin/utils.go Utility function for processing and normalizing allowed paths for WASM sandbox
pkg/plugins/autodiscovery/plugin/hostFunction.go Host function exposing Docker source spec generation to WASM plugins
pkg/plugins/autodiscovery/plugin/main_test.go Test suite validating plugin execution with demo WASM binary
pkg/core/pipeline/autodiscovery/main.go Integration point adding plugin crawler support with .wasm file detection
pkg/plugins/autodiscovery/plugin/testdata/demo/data.txt Test data for demo plugin validation
e2e/updatecli.d/success.d/autodiscovery/plugin/updatecli.yaml End-to-end test configuration demonstrating plugin usage
go.mod Added Extism and Wazero dependencies for WASM runtime
go.sum Dependency checksums for new WASM-related packages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autodiscovery All things related to the autodiscovery feature enhancement New feature or request experimental Experimental feaure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant