This repo introduces a very alpha pattern which adds plugin support to gdg.
There will eventually be several different types of plugins that can be incorporated. This also opens the door to allow the community to create their own plugins using their favorite language of choice.
Supported Types:
- cipher: simple plugin that takes in a string as input and return a string as output. The plugin can define any additional
configuration that will be passed on by GDG that the plugin will use. i.e. a
passphrasefor example. - lookup: resolves a
lookup:<provider>:<key>[.<json_field>]reference (configured underplugins.lookupingdg.yml) to a secret value from an external store, e.g. Google Secret Manager. Like cipher plugins, the plugin's own instance is loaded once and cached in memory for the life of the process; unlike cipher plugins, a resolved lookup value is also cached in memory so the same reference is never re-resolved twice in one run. Any credentials the plugin needs (a GCP service account, for example) are resolved host-side using the sameenv:/file:convention as every other plugin's config, and — where the backing API needs a short-lived credential such as an OAuth2 access token — minted fresh by the host and handed to the guest via a host function on every call, rather than baked into the plugin's static config.
The plugins in this repo are not intended to be a full comprehensive list. Feel free to implement your own. If you would like your work linked please add a PR and I will link to it in the README or create a .md doc for community contributions.
A few notes.
- Plugin system is built on top of extism. It supports a wide variety of languages to write your plugins in. As long as the output is a .wasm file it should work, but you should use their SDK. There are several languages listed here that you can choose from.
- If using golang, it should be highlighted that tinygo is needed to build the wasm file. Taskfile.yml has the flags I had to use to get the generated output to work, but your experience may vary. Once GDG 0.9.0 is out you can write your plugin and integrate it into GDG to test it out.
current plug-ins:
- ansible-vault wasm bin, source code
- aes-256-gcm wasm bin, source code
- gsm (Google Secret Manager, lookup) wasm bin, source code
CI (.github/workflows/ci.yml) builds every guest plugin and runs the full Go test suite on every push and pull request to main — it installs Go (from go.mod's go directive), TinyGo, and Task, then runs task build_all followed by go test -v ./..., so it exercises exactly the same commands described below.
This repo uses Task (Taskfile.yml) to drive tinygo builds. Install both, then:
# build every plugin's .wasm into ./plugins/
task build_all
# build just the GSM lookup plugin
task lookup_gsm
# build one of the cipher plugins
task cipher_ansible
task cipher_aes
# build everything, then run the Go test suite (host-side tests load the
# freshly built .wasm files from ./plugins/, so build_all always runs first)
task run_testsEach guest plugin's source lives in its own directory (cipher/ansible, cipher/aes-256-gcm, lookup/gsm) and is built
with the flags in Taskfile.yml's TINY_FLAGS var (-target wasi -no-debug -tags=purego -scheduler=none) — tinygo's WASI target
is what makes the extism host functions (HTTP requests, config, and any custom host functions like GSM's
get_gcp_access_token) available to the guest. If you don't have Task installed, the equivalent raw command for any plugin is:
tinygo build -o plugins/<output-name>.wasm -target wasi -no-debug -tags=purego -scheduler=none <path>/plugin.goEach plugin directory that needs host-side verification also has a _test.go file tagged !tinygo (so it's excluded from the
tinygo build itself and only compiles under the normal go toolchain). These load the compiled .wasm from ../../plugins/
with github.com/extism/go-sdk and call the guest's exported functions directly — see cipher/ansible/ansible_plugin_test.go
for the simplest example, or lookup/gsm/gsm_plugin_test.go for one that also registers a fake host function (GSM's guest
calls back into the host for a GCP access token, so its tests must supply get_gcp_access_token themselves — real GDG supplies
the real one). One of the GSM tests reaches the real Secret Manager API (with an intentionally invalid token, to verify error
handling) and is skipped under go test -short.