-
-
Notifications
You must be signed in to change notification settings - Fork 2
Parser: implement regex and search types #39
Copy link
Copy link
Closed
Labels
compatibilitylibmagic compatibility and migrationlibmagic compatibility and migrationenhancementNew feature or requestNew feature or requestevaluatorRule evaluation engine and logicRule evaluation engine and logicparserMagic file parsing components and grammarMagic file parsing components and grammarpriority:highImportant, significant compatibility or architecture impactImportant, significant compatibility or architecture impact
Milestone
Metadata
Metadata
Assignees
Labels
compatibilitylibmagic compatibility and migrationlibmagic compatibility and migrationenhancementNew feature or requestNew feature or requestevaluatorRule evaluation engine and logicRule evaluation engine and logicparserMagic file parsing components and grammarMagic file parsing components and grammarpriority:highImportant, significant compatibility or architecture impactImportant, significant compatibility or architecture impact
Type
Fields
Give feedbackNo fields configured for Feature.
Summary
Implement
regexandsearchtype specifiers for pattern-based matching in magic rules.Context
The
regextype matches binary-safe regular expressions against file content. Thesearchtype searches for a byte sequence within a range. Both are essential for text file detection (JSON, XML, scripts, etc.) and many binary formats.Current state: Neither type exists in the
TypeKindenum or parser.Acceptance Criteria
TypeKindenum extended withRegexandSearchvariantsregexandsearchtype specifiers including flags (e.g.,regex/cfor case-insensitive)regex::bytes::Regexfor binary-safe regex matchingImpact
HIGH - Required for text file detection (JSON, XML, HTML, scripts, config files). The test corpus includes JSON tests, shell script tests, and regex-eol.magic that all require this.
Test Corpus Files Blocked
Files to Modify
src/parser/ast.rs- ExtendTypeKindenumsrc/parser/grammar.rs- Parse regex/search type specifierssrc/evaluator/types.rs- Implement regex/search evaluationregexcrate bytes feature is enabledReferences