On v0.2.0 and current main, a real APK v3 package is reported as generic binary content with empty Format and MIME fields:
data, _ := os.ReadFile("unzip-6.0-r9.apk")
result := magic.Detect(data)
fmt.Printf("%q %q %q\n", result.Kind, result.Format, result.MIME)
// "binary" "" ""
A public APK v3 fixture suitable for reproducing this result is OpenWrt's unzip-6.0-r9.apk. It starts with 41 44 42 64 (ADBd) and has SHA-256 e00b404394cc68e38df58c0bb67beed5dc1260d277a478093a55979906292a1e.
Add FormatADB = "adb" to the physical format registry and detect Alpine's APK v3 ADB format in binaryFormat. Use application/octet-stream for the MIME value. ADB is also used for repository indexes and installed databases, so a package-specific MIME value would describe only one use of the physical format.
The APK v3 format description calls the binary format ADB. apk-tools defines the uncompressed file magic as ADB. followed by a schema ID. Its compression wrapper accepts three prefixes in adb_decompress:
Detection should recognize only the outer physical format and leave schema parsing to consumers. It should not distinguish the indx, idb, and pckg schema IDs, and it should not decompress the input. For ADBc, require both compression-specification bytes and a supported algorithm ID rather than matching the four ASCII bytes alone. Unknown schema IDs after ADB. should still match so future ADB schemas do not need registry changes.
DetectPrefix should return a final binary ADB result once it has a complete valid outer signature. Short inputs such as A, AD, ADB, ADBc, and ADBc plus one valid algorithm byte should retain ReasonNeedMore. Complete input with those truncated signatures must not return FormatADB. Nearby values such as ADBx, lowercase variants, an unsupported ADBc algorithm, and ADB. at a nonzero offset must remain non-ADB.
Add the three valid prefix forms to the existing binary registry and truncation tests, plus negative cases for malformed compression headers and nearby ASCII. Add an ADB seed to each fuzz target, update the README format list, and retain zero-allocation detection.
APK v2 packages should continue to return gzip, and Android APK files should continue to return zip. The new ADB result is needed by git-pkgs/archives#30 to route APK v3 packages to its v3 reader without relying on the .apk extension.
On v0.2.0 and current main, a real APK v3 package is reported as generic binary content with empty
FormatandMIMEfields:A public APK v3 fixture suitable for reproducing this result is OpenWrt's
unzip-6.0-r9.apk. It starts with41 44 42 64(ADBd) and has SHA-256e00b404394cc68e38df58c0bb67beed5dc1260d277a478093a55979906292a1e.Add
FormatADB = "adb"to the physical format registry and detect Alpine's APK v3 ADB format inbinaryFormat. Useapplication/octet-streamfor the MIME value. ADB is also used for repository indexes and installed databases, so a package-specific MIME value would describe only one use of the physical format.The APK v3 format description calls the binary format ADB. apk-tools defines the uncompressed file magic as
ADB.followed by a schema ID. Its compression wrapper accepts three prefixes inadb_decompress:ADB.for an uncompressed ADB streamADBdfor a deflate streamADBcfollowed by the two-byte compression specification for an explicitly selected algorithm and levelDetection should recognize only the outer physical format and leave schema parsing to consumers. It should not distinguish the
indx,idb, andpckgschema IDs, and it should not decompress the input. ForADBc, require both compression-specification bytes and a supported algorithm ID rather than matching the four ASCII bytes alone. Unknown schema IDs afterADB.should still match so future ADB schemas do not need registry changes.DetectPrefixshould return a final binary ADB result once it has a complete valid outer signature. Short inputs such asA,AD,ADB,ADBc, andADBcplus one valid algorithm byte should retainReasonNeedMore. Complete input with those truncated signatures must not returnFormatADB. Nearby values such asADBx, lowercase variants, an unsupportedADBcalgorithm, andADB.at a nonzero offset must remain non-ADB.Add the three valid prefix forms to the existing binary registry and truncation tests, plus negative cases for malformed compression headers and nearby ASCII. Add an ADB seed to each fuzz target, update the README format list, and retain zero-allocation detection.
APK v2 packages should continue to return
gzip, and Android APK files should continue to returnzip. The new ADB result is needed by git-pkgs/archives#30 to route APK v3 packages to its v3 reader without relying on the.apkextension.