onekey-sec / unblob

Extract files from any kind of container formats
https://unblob.org
Other
2.14k stars 81 forks source link

parser: support regex style begin-end anchors (`^`, `$`) #723

Closed vlaci closed 7 months ago

vlaci commented 7 months ago

These are the only anchors supported by Hyperscan, making it easier to write handler patterns that should match exclusively at the beginning or at the end of a stream.

The exception mapping has also been changed in hexstring2regex, as anchors are processed during lexing, and it raises a different exception then what is raised during parsing. Fortunately lark has a nice exception base class to use.