Skip to content

Parser: report warnings for skipped invalid magic rules #47

@unclesp1d3r

Description

@unclesp1d3r

Summary

When loading magic files with invalid rules, the parser should report warnings about skipped rules instead of silently ignoring them.

Context

Per Core Flow 11 (Corrupted Magic File Handling), the parser should:

  • Skip invalid individual rules and continue parsing
  • Collect warnings about each skipped rule with line numbers
  • Report summary: "Warning: Skipped N invalid rules in magic file"

Current state: Invalid rules are silently skipped. No warnings are collected or reported to the user.

Acceptance Criteria

  • Parser collects warnings for each skipped rule (line number + reason)
  • Warnings returned alongside successfully parsed rules (e.g., as a tuple or warnings field)
  • CLI outputs warnings to stderr when rules are skipped
  • Summary line: "Loaded N valid rules, skipped M invalid rules from {path}"
  • Individual warnings include line number and error description
  • Unit tests for warning collection
  • Integration test with a magic file containing intentional errors

Files to Modify

  • src/parser/mod.rs - Return warnings alongside parsed rules
  • src/parser/grammar.rs - Collect parse failures as warnings
  • src/main.rs - Display warnings to stderr
  • src/lib.rs - Propagate warnings through library API

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCommand-line interface and toolsenhancementNew feature or requestparserMagic file parsing components and grammarpriority:normalStandard work item

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions