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
Install the Python SDK into your environment:plugin.toml manifest and a main.py entry script. That’s it - no Rust toolchain, no compilation step per plugin.
Prerequisites
- Python 3.10+
malbox-plugin-sdkpackage installed (provides the native extension module)
Project structure
my-python-plugin/
plugin.toml
main.py
requirements.txt
plugin.toml
Every plugin needs a manifest alongside its entry script. This tells the daemon how to manage your plugin.
binary field tells the daemon which file to execute. For Python plugins this points to your entry script (which must be executable with a #!/usr/bin/env python3 shebang).
main.py
Make this file executable with a shebang line. The daemon spawns it as a child process.
malbox.run() call starts the IPC event loop and blocks until the daemon shuts down. All communication with the daemon happens through the Rust runtime underneath - the Python layer dispatches handler calls.
Handler methods
Subclassmalbox.Plugin and override any of these methods. All have default no-op implementations.
| Method | Signature | Required |
|---|---|---|
on_task | (self, ctx: Context) -> None | No (default no-op) |
on_start | (self, config: dict[str, str]) -> None | No |
on_stop | (self) -> None | No |
health_check | (self) -> HealthStatus | No |
on_event | (self, event: Event) -> None | No |
Async handlers
Any handler can beasync def instead of def. The SDK detects coroutines at runtime and drives them on an asyncio event loop automatically.
TaskInfo
Access task metadata viactx.task(). The returned TaskInfo is only valid during the handler call.
Context and TaskInfo are only valid during the handler call. Do not store references to them.Pushing results
Results are pushed to the daemon via theResultSink obtained from ctx.results(). You can call push methods multiple times to stream results incrementally:
plugin.toml under [results.*].
Reports
For structured analysis output with verdicts, indicators, TTPs, and frontend-renderable sections, use theReportBuilder to construct a Report and push it as a result. Reports support:
- Verdicts with classification (clean/suspicious/malicious/unknown), confidence, and score
- Indicators (IOCs) with open-vocabulary types like
sha256,ipv4,domain - TTPs referencing MITRE ATT&CK techniques
- Artifact references linking to sibling
PluginResultentries - Presentation sections with typed blocks (markdown, tables, code, hex dumps, graphs, timelines, and more)
Context methods
Logging
Use the module-level logging functions to emit structured logs that integrate with the Rust tracing subscriber:Handling errors
Python exceptions in handlers are caught and reported to the daemon:- Exceptions in
on_taskresult in aTaskFailedevent - Exceptions in
on_startprevent the plugin from reachingReadystate - Tracebacks are captured and included in error messages
Subscribing to events
Overrideon_event to react to system-wide or plugin lifecycle events:
Holding state
Your plugin class can hold any instance attributes. Forexecution = "parallel" where multiple on_task calls may execute concurrently, use threading locks for shared mutable state:
Health checks
Overridehealth_check to report plugin health. The daemon polls this periodically.
Deploy
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
main.py is executable (chmod +x) and has the correct shebang (#!/usr/bin/env python3). The malbox-plugin-sdk package must be installed in the Python environment that the shebang points to.
Each Python plugin runs as its own process. The daemon spawns
main.py directly - the OS interprets the shebang and launches Python. The SDK’s native extension handles all IPC communication with the daemon.