Skip to content

Parser/Evaluator: surface !:apple Mac type/creator directive metadata #286

Description

@unclesp1d3r

Summary

Surface !:apple TYPE/CREATOR directive metadata in the AST and evaluation output. magic(5) defines !:apple for Mac OS Classic-style four-character type and creator codes; libmagic emits them in detailed output and exposes them through API consumers.

Current State (after #51 work)

After #51 lands !:mime and !:ext directive evaluation, !:apple will remain the only commonly-used !: directive that is parsed-as-known-but-unimplemented in src/parser/preprocessing.rs (see KNOWN_UNIMPLEMENTED_DIRECTIVES). Lines beginning with !:apple parse without warning so magic files load cleanly, but the eight-character TTTTCCCC (4-byte type + 4-byte creator) payload is discarded.

Why Low Priority

  • !:apple appears in only a handful of GNU file magic entries (mostly classic Mac formats like ResEdit, AppleSingle/Double, classic Mac binaries).
  • No corpus fixtures in third_party/tests/ exercise it today.
  • Modern macOS uses extended attributes and UTIs rather than HFS type/creator codes.

Acceptance Criteria

  • Parser captures !:apple TTTTCCCC and attaches the 8-character payload to the preceding rule
  • AST exposes apple_type (4 chars) and apple_creator (4 chars) on MagicRule (or via a Directives struct alongside mime_type / extensions added in Evaluator: ZIP content inspection for compound document detection #51)
  • Library API surfaces the values in EvaluationResult and JSON output
  • Round-trip codegen preserves the directive
  • At least one synthesized fixture exercises end-to-end (a rule with !:apple paired with a buffer that triggers it)

Out of Scope

  • HFS attribute reading from the underlying filesystem — !:apple is a magic-rule annotation, not a filesystem probe.
  • UTI / extended-attribute integration — separate concern.

Refs

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatibilitylibmagic compatibility and migrationenhancementNew feature or requestevaluatorRule evaluation engine and logicparserMagic file parsing components and grammarpriority:lowNice to have, can defertestingTest infrastructure and coveragetype:feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions