algorithms.base

Base classes for analysis algorithms.

class AnalysisContext[source]

Bases: object

Describe the current capture and supply inputs to an algorithm.

secrets can hold known values from ground truth. extra carries algorithm-specific options.

library: str
protocol_version: str
phase: str
secrets: List[CryptoSecret]
extra: Dict[str, Any]
property tls_version: str

Backward-compatible alias for protocol_version.

__init__(library, protocol_version, phase, secrets=<factory>, extra=<factory>)
Parameters:
Return type:

None

class Match[source]

Bases: object

Report one match with a byte offset, length, and confidence.

The algorithm can supply a label, matched bytes, and metadata when it has them. Interpret the offset in the input coordinates.

offset: int
length: int
confidence: float
label: str = ''
data: bytes = b''
metadata: Dict[str, Any]
__init__(offset, length, confidence, label='', data=b'', metadata=<factory>)
Parameters:
Return type:

None

class AlgorithmResult[source]

Bases: object

Report the algorithm name, overall confidence, and matches.

The metadata can contain algorithm-specific diagnostics.

algorithm_name: str
confidence: float
matches: List[Match]
metadata: Dict[str, Any]
__init__(algorithm_name, confidence, matches=<factory>, metadata=<factory>)
Parameters:
Return type:

None

class BaseAlgorithm[source]

Bases: ABC

Base class for all analysis algorithms.

name: str = ''
description: str = ''
mode: str = ''
abstractmethod run(dump_data, context)[source]

Run the algorithm on dump data.

Parameters:
Return type:

AlgorithmResult

estimate_working_set(size, context=None, sample=None)[source]

Estimate the peak additional memory that run() needs, in bytes.

Exclude the input buffer because the caller budgets it separately. Use context for analysis options and sample for examples of the input bytes when the memory cost depends on content. Give a conservative estimate. The default is zero for algorithms with no size-dependent working set.

Parameters:
Return type:

int

Auto-discovery registry for algorithm plugins.

ALGORITHM_ENTRY_POINT_GROUP = 'memdiver.algorithms'

Entry-point group under which out-of-tree packages advertise algorithms.

class AlgorithmRegistry[source]

Bases: object

Discover and manage algorithm plugins.

__init__()[source]
discover()[source]

Load built-in algorithms and installed algorithm plugins.

Search the known-key, unknown-key, key-finder, and pattern packages. Discover external plugins in the memdiver.algorithms entry-point group. A built-in import failure is logged and does not stop the rest of the scan.

Return type:

None

get(name)[source]
Parameters:

name (str)

Return type:

BaseAlgorithm

list_all()[source]
Return type:

List[BaseAlgorithm]

list_by_mode(mode)[source]
Parameters:

mode (Literal['known_key', 'unknown_key'])

Return type:

List[BaseAlgorithm]

property names: List[str]
get_registry()[source]
Return type:

AlgorithmRegistry