[Git][reproducible-builds/diffoscope][master] Dalvik .dex files can also serve as APK containers so restrict the narrower...

Chris Lamb gitlab at salsa.debian.org
Mon Apr 13 15:37:47 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
f1297ac0 by Chris Lamb at 2020-04-13T16:37:27+01:00
Dalvik .dex files can also serve as APK containers so restrict the narrower identification of .dex files to files ending with this extension, and widen the identification of APK files to when file(1) discovers a Dalvik file. (Closes: Debian:#884095, reproducible-builds/diffoscope#28)

This is essentially functionally equivalent (yet superior to) always
identifying files named *.apk as APK containers or adding a command-line switch
to "force" identification.

This is not a bug in file(1) as the files do legitimately differ in their
magic numbers:

    $ xxd HelloWorld.apk | head -n1
    00000000: 504b 0304 0a00 0000 0800 c907 c37d 8dea  PK...........}..

    $ xxd helloworld-janus.apk | head -n1
    00000000: 6465 780a 3033 3500 b5f7 4441 c609 399e  dex.035...DA..9.

- - - - -


2 changed files:

- diffoscope/comparators/apk.py
- diffoscope/comparators/dex.py


Changes:

=====================================
diffoscope/comparators/apk.py
=====================================
@@ -188,7 +188,7 @@ class ApkContainer(Archive):
 class ApkFile(File):
     DESCRIPTION = "Android APK files"
     FILE_TYPE_HEADER_PREFIX = b"PK\x03\x04"
-    FILE_TYPE_RE = re.compile(r'^(Java|Zip) archive data.*\b')
+    FILE_TYPE_RE = re.compile(r'^((Java|Zip) archive data|Dalvik dex file)\b')
     FILE_EXTENSION_SUFFIX = '.apk'
     CONTAINER_CLASSES = [ApkContainer, ZipContainer]
 


=====================================
diffoscope/comparators/dex.py
=====================================
@@ -60,4 +60,5 @@ class DexContainer(Archive):
 class DexFile(File):
     DESCRIPTION = "Dalvik .dex files"
     FILE_TYPE_RE = re.compile(r'^Dalvik dex file .*\b')
+    FILE_EXTENSION_SUFFIX = '.dex'
     CONTAINER_CLASSES = [DexContainer]



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/f1297ac09c77387568e58c6e8dfb4009a1a7c4cf

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/f1297ac09c77387568e58c6e8dfb4009a1a7c4cf
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20200413/445917e0/attachment.htm>


More information about the rb-commits mailing list