Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tilsor/ModSecIntl_wace_lib/llms.txt

Use this file to discover all available pages before exploring further.

WACElib loads model plugins as Go shared objects (.so files) at startup. The PluginManager uses Go’s plugin package to look up exported symbols by name. A model plugin must export either the sync or async entry points depending on its configured mode. The correct interface is determined by the mode and remote fields in the plugin configuration: sync non-remote plugins export InitPlugin and Process; async plugins and remote-sync plugins export InitPluginAsync.

Entry points by mode

Sync plugins are called directly in-process. The PluginManager calls InitPlugin once at startup and then calls Process for every transaction that targets this plugin.

InitPlugin

func InitPlugin(params map[string]string, meter metric.Meter) error
Called once when the plugin is loaded. Use this function to load model weights, open connections, or perform any one-time initialisation. Return a non-nil error to signal a fatal initialisation failure; the PluginManager logs a warning and skips the plugin.
ParameterTypeDescription
paramsmap[string]stringKey-value pairs from the plugin’s params block in the configuration YAML.
metermetric.MeterOpenTelemetry meter for recording plugin-level metrics.

Process

func Process(input pluginmanager.ModelInput) (pluginmanager.ModelResults, error)
Called once per transaction for each call to wace.Analyze that names this plugin. Runs in its own goroutine; the PluginManager waits on a channel for the result.
ParameterTypeDescription
inputpluginmanager.ModelInputContains the TransactionId and the HTTPPayload to score.
Returns a ModelResults with ProbAttack in [0.0, 1.0] and optional Data. Return a non-nil error if the plugin cannot process the input; the error is logged and the transaction continues without this plugin’s result.

Minimal sync plugin

package main

import (
    "github.com/tilsor/ModSecIntl_wace_lib/pluginmanager"
    "go.opentelemetry.io/otel/metric"
)

// InitPlugin initialises the model.
func InitPlugin(params map[string]string, meter metric.Meter) error {
    // Load model, open files, etc.
    return nil
}

// Process scores a single HTTP transaction.
func Process(input pluginmanager.ModelInput) (pluginmanager.ModelResults, error) {
    // Run inference on input.Payload
    score := runModel(input.Payload)
    return pluginmanager.ModelResults{
        ProbAttack: score,
        Data:       map[string]interface{}{"source": "sync-model"},
    }, nil
}

func runModel(payload pluginmanager.HTTPPayload) float64 {
    // Replace with real inference logic
    return 0.0
}
Build command:
go build -buildmode=plugin -o mymodel.so ./mymodel

Configuration reference

modelplugins:
  - id: "my-sync-model"
    path: "/usr/lib/wace/plugins/my_sync_model.so"
    plugintype: "RequestHeaders"
    weight: 1.0
    mode: sync          # sync (default) — uses InitPlugin + Process
    params:
      model_path: "/models/weights.bin"

  - id: "my-async-model"
    path: "/usr/lib/wace/plugins/my_async_model.so"
    plugintype: "Everything"
    weight: 0.5
    mode: async         # async — uses InitPluginAsync
    params:
      batch_size: "32"

  - id: "my-remote-model"
    path: "/usr/lib/wace/plugins/my_remote_model.so"
    plugintype: "AllRequest"
    weight: 0.8
    mode: sync
    remote: true        # remote sync — uses InitPluginAsync + NATS
Async and remote-sync plugins must be compiled against the same versions of pluginmanager and go.opentelemetry.io/otel/metric as the WACElib binary. Go plugin ABI requires identical package paths and versions across the host and plugin binaries.
WACElib skips (logs a warning for) any plugin whose exported symbol does not match the expected function signature. If a sync plugin is accidentally compiled with the wrong Process signature, it will not be invoked but Init will not return an error.

Build docs developers (and LLMs) love