feat: WebAssembly plugin support with end-to-end host invocation#65
Draft
monshri wants to merge 11 commits into
Draft
feat: WebAssembly plugin support with end-to-end host invocation#65monshri wants to merge 11 commits into
monshri wants to merge 11 commits into
Conversation
* feat: initial revision rust core. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fix: addressed comments in PR. Updated PluginContext to match spec. Signed-off-by: Teryl Taylor <terylt@ibm.com> --------- Signed-off-by: Teryl Taylor <terylt@ibm.com> Co-authored-by: Teryl Taylor <terylt@ibm.com>
* feat: added yaml and routing rule support. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added example code to show how to load manager and plugins. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fixes: updated plugin errors, configs to more match python. Signed-off-by: Teryl Taylor <terylt@ibm.com> --------- Signed-off-by: Teryl Taylor <terylt@ibm.com> Co-authored-by: Teryl Taylor <terylt@ibm.com>
* feat: initial revision rust core. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fix: addressed comments in PR. Updated PluginContext to match spec. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added yaml and routing rule support. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added example code to show how to load manager and plugins. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fixes: updated plugin errors, configs to more match python. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: RUST CMF initial revision. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added invoke named support, added constants, fixed reviewed code. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added owned extensions and did some refactoring. Signed-off-by: Teryl Taylor <terylt@ibm.com> --------- Signed-off-by: Teryl Taylor <terylt@ibm.com> Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> Co-authored-by: Teryl Taylor <terylt@ibm.com> Co-authored-by: Frederico Araujo <frederico.araujo@ibm.com>
* feat: initial revision rust core. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fix: addressed comments in PR. Updated PluginContext to match spec. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added yaml and routing rule support. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added example code to show how to load manager and plugins. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fixes: updated plugin errors, configs to more match python. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: RUST CMF initial revision. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added invoke named support, added constants, fixed reviewed code. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added owned extensions and did some refactoring. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added cgo and golang bindings, examples and readme. Signed-off-by: Teryl Taylor <terylt@ibm.com> * address P0/P1/P2 review findings (except contextforge-org#17) Signed-off-by: Teryl Taylor <terylt@ibm.com> * fix: address remaining P2/P3 review findings + testing gaps Signed-off-by: Teryl Taylor <terylt@ibm.com> * docs: add CPEX Go public API spec Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * docs: renamed document Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * feat(cpex-rust): CGO review passes 1-11 + lint cleanup + Makefile targets Signed-off-by: Teryl Taylor <terylt@ibm.com> * fix: address linting issues, updated makefile to support building examples. Signed-off-by: Teryl Taylor <terylt@ibm.com> * docs: updated the go spec to reflect recent changes. Signed-off-by: Teryl Taylor <terylt@ibm.com> --------- Signed-off-by: Teryl Taylor <terylt@ibm.com> Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> Co-authored-by: Teryl Taylor <terylt@ibm.com> Co-authored-by: Frederico Araujo <frederico.araujo@ibm.com>
Co-authored-by: Teryl Taylor <terylt@ibm.com>
…g#49) Co-authored-by: Teryl Taylor <terylt@ibm.com>
…ontextforge-org#52) Co-authored-by: Teryl Taylor <terylt@ibm.com>
* fix: initial revision APL. * feat: apl-cpex bridge crate + plugin-registry-driven hook dispatch * feat: add support for plugin calling in APL routes. * feat: add more APL plugin support, unified config * feat: added cedar direct PDP. * feat: add identity hook and extensions. * feat: added token delegation hooks and tests. * feat: added plugin for jwt token identity, oauth and biscuit delegation, cedarling PDP. Signed-off-by: Teryl Taylor <terylt@ibm.com> * fix: updated identity and delegation to support keycloak. added delegate() function, and identity sections. * fix: added some sample plugins, added updates to support cedar. Signed-off-by: Teryl Taylor <terylt@ibm.com> * feat: added session support, serialize and parallel and full effects capabilities. * feat: add ffi pre-built .a library Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * chore: add workflow_dispatch target Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * fix: critical and high issues from review. * feat: add APL FFI and go bindings Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * chore: add musl tools to musl runners Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * fix: potential double free after use bug. * chore: update Go module paths after repo rename to cpex * feat: map identity extension into cpex ffi Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * feat: add cpex_invoke_resolved abi Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * fix: has_hook_for handling Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> * chore: update headers Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> --------- Signed-off-by: Teryl Taylor <terylt@ibm.com> Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com> Co-authored-by: Frederico Araujo <frederico.araujo@ibm.com>
Introduces the WASM plugin sandbox system: cpex-wasm-plugin (guest-side cdylib targeting wasm32-wasip2) and cpex-wasm-host (host-side runtime using wasmtime with sandbox policy enforcement, resource limits, and network filtering). Signed-off-by: Shriti Priya <shritip@ibm.com>
…ionality in wasm compilation Signed-off-by: Shriti Priya <shritip@ibm.com>
Signed-off-by: Shriti Priya <shritip@ibm.com>
51aeb57 to
7fde6ca
Compare
Contributor
Author
|
@araujof @terylt Few things to discuss on current implementation: 1. Raw Credentials - Completely Blocked
2. SecurityExtension - TruncatedOnly 4 of 8 fields are available in WASM: Available:
Missing:
Impact: WASM plugins cannot make workload-aware or client-aware authorization decisions 3. Extension Slots - Only 4 of 13 AvailableAvailable in WASM:
Missing from WASM:
To discussFor 1, we can discuss if we want to keep it as-is or not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WASM Plugin End-to-End Support
Resolves #21
Addresses parts of #24
Summary
Adds full WebAssembly plugin support using the WASI Component Model, enabling sandboxed plugin execution with fine-grained capability control over filesystem, HTTP, and environment access.
New crates:
cpex-wasm-plugin: Guest-side plugin crate compiled as acdylibtargetingwasm32-wasip2.Implements the WIT-defined plugin interface (evaluate-hook) with type conversions between WIT representations and Rust domain types.cpex-wasm-host: Host-side runtime using Wasmtime. Includes:sandbox_manager.rs— Resource-limited WASM execution (memory caps, CPU time limits, network allowlists)policy_loader.rs— Loads sandbox policies from YAML configfactory.rs— Instantiates WASM plugin modulesconversions.rs— Marshals types across the host/guest boundarycpex-payload— a stripped-down subset of cpex-core types specifically designed to compile to WASM.cpex-coredepends on heavy crates (async runtimes like tokio, crypto libraries, FFI layers) that don't compile to wasm32-wasip2. This crate extracts the pure data types and trait definitions needed by the plugin guest.cpex-coreexecutor/manager/registry logic, no FFI dependencies.identity_checkerplugin under src/plugins/ as a reference implementation.Cargo.tomlupdated to include the new crate.Architecture
cpex-wasm-plugincompiles plugins into a portableplugin.wasmbinary. The host (cpex-wasm-host) loads and executes the WASM plugin inside a sandboxed wasmtime environment. Enforces resource limits (fuel, memory, execution time) and network/filesystem policies. Provides a bridge to cpex-core'sPluginManagerfor integration into the hook pipeline.cpex-wasm-host— Host RuntimeLoads and executes
.wasmplugins inside a sandboxed wasmtime environment with resource limits (fuel, memory, execution time) and network/filesystem policies.sandbox_policykey). Deny-by-default when absent.cpex-coretypes and WIT types (JSON serialization for complex types at the boundary).cpex-core'sPluginFactorytrait:WasmPluginFactory→WasmBridgePlugin→WasmBridgeHandler.Usage Modes
WasmPluginFactorywith awasm://scheme, load config, invoke hooks through the standard pipeline.Details: Readme
cpex-wasm-plugin— Plugin TemplateCompiles CPEX plugins into a portable
plugin.wasmbinary, loaded and executed in the host sandbox.wit/world.wit) — Defines the host-plugin contract: a single exportedhandle-hookfunction receiving message payload, extensions, and plugin context; returns allow/deny.src/lib.rs— Plugin entry point implementing theGuesttrait; delegates to plugin logic incpex-payload.src/conversions.rs— Bidirectional type mapping between WIT flat types and rich Rust types.Details: Readme
cpex-payload— Plugin TemplateThis crate includes only the files required for plugin compilation. Compiling the entire cpex-core into a WebAssembly component caused issues, so this separation was necessary.
crates/cpex-payload/src/plugins/identity_checker.rsprovides the implementation of the plugin but withfnvsasync fn, since the WebAssembly Component Model does not yet support asynchronous calls.