GNU file doesn't just check magic numbers against libmagic, it also defines a scripting language and a series of tests/printers written in it.
That's what allows it to do complex things, eg identify all the flavors of ELF objects even though they share a magic number or determine if something is JSON or CSV without one.
That's what allows it to do complex things, eg identify all the flavors of ELF objects even though they share a magic number or determine if something is JSON or CSV without one.