Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magic tests fix #1714

Merged
merged 2 commits into from
May 28, 2022
Merged

Magic tests fix #1714

merged 2 commits into from
May 28, 2022

Conversation

MatejKastak
Copy link
Contributor

Update test conditions for magic module. This change is necessary because different versions of libmagic return different identifications.

For example docker image centos:7 fails to pass make check tests. I extracted the PE32_FILE and MACHO_X86_FILE using python into a file and using file identified expected output.

Additionally to the original issue there is also problem with the macho binary, this time not with magic.type() but magic.mime_type() which returns:

[root@f6c81b5ba76a /]# file -i full.macho
full.macho: application/octet-stream; charset=binary

vs. current arch linux:

λ file -i full.macho
full.macho: application/x-mach-binary; charset=binary
  1. pe32 test condition is changed to MS-DOS executable which is common identification for both libmagic versions
  2. macho test condition is extended with alternative magic.mime_type()

Fixes #1713

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.
@plusvic plusvic merged commit a60f47c into VirusTotal:master May 28, 2022
BitsOfBinary pushed a commit to BitsOfBinary/yara that referenced this pull request May 29, 2022
* 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
@MatejKastak MatejKastak deleted the magic-tests-fix branch June 23, 2022 06:25
plusvic pushed a commit that referenced this pull request Jun 30, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Magic module tests can sometimes fail depending on libmagic version
2 participants