Skip to content

Commit

Permalink
Magic tests fix (#1714)
Browse files Browse the repository at this point in the history
* test: Relax pe32 condition in magic tests

Turns out different versions of libmagic return different file
identification for the PE32 sample in magic tests. Relax this condition
to the common part of the identification to make tests less reliant on
the testing platform.

* test: Relax macho condition in magic tests
  • Loading branch information
MatejKastak authored and plusvic committed Jun 30, 2022
1 parent 32faec6 commit dc523c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/test-magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ int main(int argc, char** argv)

assert_true_rule_blob(
"import \"magic\" rule test { condition: \
magic.type() contains \"PE32\" and \
magic.type() contains \"MS-DOS executable\" and \
magic.mime_type() == \"application/x-dosexec\" }",
PE32_FILE);

// Test case for https://github.com/VirusTotal/yara/issues/1663
assert_true_rule_blob(
"import \"magic\" rule test { condition: \
magic.type() contains \"Mach-O\" and \
magic.mime_type() == \"application/x-mach-binary\" and \
(magic.mime_type() == \"application/x-mach-binary\" or magic.mime_type() == \"application/octet-stream\") and \
magic.type() contains \"Mach-O\"}",
MACHO_X86_FILE);

Expand Down

0 comments on commit dc523c0

Please sign in to comment.