mirror of
https://github.com/morluto/rea.git
synced 2026-11-08 07:46:28 +00:00
* feat(apktool): decode Android resource tables through a caller-supplied launcher Add an Apktool family with two operations over the caller's apktool launcher (REA_APKTOOL_COMMAND, absolute, or apktool on PATH): - inspect_apktool_client: resolved launcher, selection source, and version; decodes nothing. - decode_android_resources: apktool d --no-src in a provider-owned workspace that is removed before the result returns. Projects the decoded AndroidManifest.xml (bounded at 512 KiB), apktool.yml version and SDK facts exactly as printed, string resources verbatim (default or one locale, bounded at 2000 entries, nested-markup entries counted as unparsed), available string locales, and the decoded file count with a hard cap. The target APK is digested with SHA-256 before decoding so Evidence binds the observation to the exact input. Smali production is skipped by design: Java-source recovery belongs to the JADX family. Workspace cleanup happens before results return; an unremovable workspace is named in the limitations instead of abandoned. Verified against apktool 2.7.0-dirty (Debian packaging) on Linux with OpenJDK 25 against a signed aapt2-built probe APK with two resource locales: launcher version, on-disk digest agreement, metadata projection, manifest package agreement, and both string tables (default and de). Parser goldens come from the same decode. READMEs carry the new 'Android resources' row in every supported language. * fix(apktool): own snapshots and bound decoded resource reads * docs(apktool): describe owned resources and bounded projection --------- Co-authored-by: REA Contributor <contributor@rea.tools> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
115 lines
3.4 KiB
TypeScript
115 lines
3.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
parseApktoolYml,
|
|
parseDecodedStrings,
|
|
parseManifestPackage,
|
|
} from "./ApktoolDecodeOutput.js";
|
|
|
|
const REAL_YML = [
|
|
"!!brut.androlib.meta.MetaInfo",
|
|
"apkFileName: probe.apk",
|
|
"compressionType: false",
|
|
"doNotCompress:",
|
|
"- resources.arsc",
|
|
"isFrameworkApk: false",
|
|
"packageInfo:",
|
|
" forcedPackageId: '127'",
|
|
" renameManifestPackage: null",
|
|
"sdkInfo:",
|
|
" minSdkVersion: '24'",
|
|
" targetSdkVersion: '34'",
|
|
"sharedLibrary: false",
|
|
"sparseResources: false",
|
|
"unknownFiles: {}",
|
|
"usesFramework:",
|
|
" ids:",
|
|
" - 1",
|
|
" tag: null",
|
|
"version: 2.7.0-dirty",
|
|
"versionInfo:",
|
|
" versionCode: '7'",
|
|
" versionName: 1.2.3",
|
|
"",
|
|
].join("\n");
|
|
|
|
describe("parseApktoolYml", () => {
|
|
it("projects version and SDK facts from a real apktool.yml", () => {
|
|
expect(parseApktoolYml(REAL_YML)).toEqual({
|
|
versionName: "1.2.3",
|
|
versionCode: "7",
|
|
minSdkVersion: "24",
|
|
targetSdkVersion: "34",
|
|
});
|
|
});
|
|
|
|
it("accepts quoted version values some builds emit", () => {
|
|
expect(parseApktoolYml("versionName: '2.0.0'\nversionCode: 45\n")).toEqual({
|
|
versionName: "2.0.0",
|
|
versionCode: "45",
|
|
minSdkVersion: null,
|
|
targetSdkVersion: null,
|
|
});
|
|
});
|
|
|
|
it("reports null facts for unrelated YAML", () => {
|
|
expect(parseApktoolYml("version: 2.7.0\n")).toEqual({
|
|
versionName: null,
|
|
versionCode: null,
|
|
minSdkVersion: null,
|
|
targetSdkVersion: null,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("parseManifestPackage", () => {
|
|
it("reads the package attribute from a decoded manifest", () => {
|
|
const manifest =
|
|
'<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="34" package="com.rea.apktool.probe" platformBuildVersionCode="34">';
|
|
expect(parseManifestPackage(manifest)).toBe("com.rea.apktool.probe");
|
|
});
|
|
|
|
it("reports null when no package attribute exists", () => {
|
|
expect(parseManifestPackage("<manifest>\n</manifest>\n")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("parseDecodedStrings", () => {
|
|
it("projects entries from a real decoded strings.xml", () => {
|
|
const stringsXml = [
|
|
'<?xml version="1.0" encoding="utf-8"?>',
|
|
"<resources>",
|
|
' <string name="api_endpoint">https://api.example.com/v1</string>',
|
|
' <string name="app_name">ApktoolProbe</string>',
|
|
' <string name="debug_flag">true</string>',
|
|
"</resources>",
|
|
"",
|
|
].join("\n");
|
|
expect(parseDecodedStrings(stringsXml)).toEqual({
|
|
entries: [
|
|
{ name: "api_endpoint", value: "https://api.example.com/v1" },
|
|
{ name: "app_name", value: "ApktoolProbe" },
|
|
{ name: "debug_flag", value: "true" },
|
|
],
|
|
unparsedCount: 0,
|
|
});
|
|
});
|
|
|
|
it("counts entries with nested markup instead of flattening them", () => {
|
|
const stringsXml =
|
|
'<resources><string name="styled">Hello <b>world</b></string><string name="plain">ok</string></resources>';
|
|
expect(parseDecodedStrings(stringsXml)).toEqual({
|
|
entries: [{ name: "plain", value: "ok" }],
|
|
unparsedCount: 1,
|
|
});
|
|
});
|
|
|
|
it("preserves escaped entities verbatim", () => {
|
|
const stringsXml =
|
|
'<resources><string name="escaped">a & b <c></string></resources>';
|
|
expect(parseDecodedStrings(stringsXml).entries[0]?.value).toBe(
|
|
"a & b <c>",
|
|
);
|
|
});
|
|
});
|