Module magic

Module magic 

Source
Expand description

Hierarchical magic byte pattern evaluation engine for format identification.

Structs§

MagicPattern
A signature rule defining magic bytes to inspect in a file header (legacy compatibility).
RuleMatchResult
Result of evaluating a hierarchical magic rule against a payload source.

Enums§

FormatValue
Extracted value used for printf-style format interpolation in descriptions.

Functions§

evaluate_rule
Evaluates a single HierarchicalMagicRule and its child tree against a DetectionSource.
evaluate_rule_with_mode
Evaluates a single HierarchicalMagicRule and its child tree against a DetectionSource with file mode.
evaluate_rule_with_templates
Evaluates a hierarchical magic rule against a payload source using provided subroutines.
evaluate_rule_with_templates_and_mode
Evaluates a hierarchical magic rule against a payload source using provided subroutines and file mode.
format_magic_description
Formats a libmagic rule description interpolating %s, %d, %x, etc. specifiers.
varexpand
Expands ${x?then:else} variable expressions according to mode execution bits, matching varexpand in softmagic.c.