Implementation:416rehman DeepZero resolve processor class
| Knowledge Sources | |
|---|---|
| Domains | Pipeline_Orchestration, Extensibility |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Processor class resolution function that maps a pipeline YAML processor reference to a concrete Processor subclass via three resolution strategies: built-in registry, external file, or dotted import.
Description
The resolve_processor_class function is the bridge between pipeline YAML and executable code. It takes a processor reference string and returns the corresponding Processor subclass. Three resolution strategies are supported:
- Bare name (e.g., "metadata_filter"): looks up the built-in processor registry. Built-in processors are registered at import time.
- dir/file.py (e.g., "ghidra_decompile/ghidra_decompile.py"): loads an external processor from the processors/ directory relative to CWD. The first Processor subclass in the file is used. Optionally, a specific class can be named: dir/file.py:ClassName.
- module:Class (e.g., "deepzero.stages.filter:MetadataFilter"): imports a dotted module path and gets the named class.
For external processors, the resolved class's _source_file is set to the absolute path, enabling the processor to locate co-located assets (scripts, rule files) via self.processor_dir.
Usage
- Referencing a built-in processor in YAML: processor: metadata_filter
- Referencing an external processor: processor: ghidra_decompile/ghidra_decompile.py
- Referencing a specific class in an external file: processor: pe_ingest/pe_ingest.py:PEIngest
- Registering a built-in processor: call register_processor(name, cls) at import time
Code Reference
Source Location
- Repository: DeepZero
- File: src/deepzero/engine/registry.py
Signature
def resolve_processor_class(processor_ref: str) -> type[Any]: ...
def register_processor(name: str, cls: type[Any]) -> None: ...
def get_registered_processors() -> dict[str, type[Any]]: ...
Import
from deepzero.engine.registry import resolve_processor_class, register_processor
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| processor_ref | str | Yes | Bare name, dir/file.py, dir/file.py:Class, or module:Class |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | type[Processor] | Resolved processor subclass with _source_file set |
Usage Examples
Resolving Built-in vs External
from deepzero.engine.registry import resolve_processor_class
# Built-in (registered in the registry)
cls = resolve_processor_class("metadata_filter")
# External in processors/ directory
cls = resolve_processor_class("ghidra_decompile/ghidra_decompile.py")
# External with explicit class name
cls = resolve_processor_class("pe_ingest/pe_ingest.py:PEIngest")
# The resolved class has _source_file set for asset resolution
instance = cls(spec)
print(f"Processor dir: {instance.processor_dir}")
Registering a Built-in Processor
from deepzero.engine.registry import register_processor
from deepzero.engine.stage import MapProcessor
class MyFilter(MapProcessor):
...
register_processor("my_filter", MyFilter)
# Now usable in YAML as: processor: my_filter