Documentation Index
Fetch the complete documentation index at: https://docs.malbox.app/llms.txt
Use this file to discover all available pages before exploring further.
Getting started
Create a new repository from the Rust plugin template by clicking Use this template on GitHub. Clone your new repository and rename the project inCargo.toml and plugin.toml to match your plugin name.
The template gives you a working plugin with Cargo configuration, a plugin.toml manifest, a build.rs, example source code, and CI already set up.
Prerequisites
- Rust toolchain (stable, 2024 edition)
- For Windows guest plugins: MinGW cross-compilation toolchain (provided by the Malbox devenv)
Project structure
Cargo.toml
The SDK is declared as a dependency with either the host or guest feature enabled depending on your plugin type.
For a guest plugin:
plugin.toml
Every plugin needs a manifest alongside its binary. This tells the daemon how to manage your plugin, and its [runtime] section is baked into the plugin binary at compile time by the SDK’s proc-macro.
[runtime] fields are optional and have sensible defaults. See the Plugin Configuration Reference for the full list and defaults.
build.rs
The build.rs ensures cargo re-runs the proc-macro when plugin.toml changes:
src/main.rs
The SDK uses attribute macros to wire your plugin into the runtime. You annotate your struct and impl block instead of manually implementing traits.
#[malbox::handlers] macro scans your impl block for annotated methods and generates the necessary trait implementations. Your method names can be anything you like - the attributes determine their role.
Plugin struct macros
Use one of these on your struct to declare the plugin type:| Macro | Description |
|---|---|
#[malbox::host_plugin] | Host plugin - runs on the daemon machine via IPC |
#[malbox::guest_plugin] | Guest plugin - runs inside a VM/container via gRPC |
plugin.toml’s [runtime] section at compile time - no attribute configuration is needed on the struct.
Handler methods
Annotate methods inside a#[malbox::handlers] impl block:
| Attribute | Signature | Required |
|---|---|---|
#[malbox::on_task] | fn(&self, Task, &Context) -> Result<()> | Yes |
#[malbox::on_start] | fn(&self) -> Result<()> | No |
#[malbox::on_stop] | fn(&self) -> Result<()> | No |
#[malbox::health_check] | fn(&self) -> HealthStatus | No |
#[malbox::on_event(...)] | Varies (see Subscribing to events) | No |
#[malbox::on_task] is required. All other handlers are optional and default to no-ops.
Pushing results
Results are pushed to the daemon duringon_task via ctx.push_result(). You can call it multiple times to stream results incrementally. There are three result types:
plugin.toml under [results.*].
For structured analysis output with verdicts, indicators, TTPs, and frontend-renderable sections, use the ReportBuilder to construct a Report and push it as a result:
Handling errors
The SDK uses its ownResult<T> type aliased to std::result::Result<T, SdkError>. Handler methods return Result<()> and can use ? to propagate errors naturally.
Subscribing to events
Use#[malbox::on_event(...)] to react to system events. Specify the event variant as the argument:
from filter narrows plugin events to results from specific named plugins. You can also declare event subscriptions in plugin.toml:
Holding state
Your plugin struct can hold fields. For concurrent access withExecutionContext::Parallel, wrap mutable state in Mutex or similar:
Thread safety
When usingExecutionContext::Parallel, multiple on_task calls may execute concurrently. The SDK requires Send + Sync for guest plugins. Protect shared mutable state with Mutex, RwLock, or atomic types. Health checks may also arrive on a different thread regardless of execution context.
Build
Linux
Host plugins always target Linux (they run on the daemon machine). Guest plugins targeting a Linux guest VM also use this:Windows (cross-compile)
Guest plugins that run inside a Windows analysis VM need to be cross-compiled:The Malbox devenv automatically configures the MinGW linker and library paths for the
x86_64-pc-windows-gnu target. No additional setup is needed if you’re using devenv shell.Deploy
Host plugins
Place the compiled binary andplugin.toml in a subdirectory of the daemon’s plugin directory. The daemon discovers plugins automatically on startup.
~/.config/malbox/plugins/
my-host-plugin-bin
plugin.toml
Guest plugins
Guest plugin binaries must be deployed inside the analysis VM. Place them in the daemon’s plugin directory (so the daemon knows about them), then provision the binary into the VM:~/.config/malbox/plugins/
my-guest-plugin-bin
plugin.toml