fix(artifacts): take nested container families from bytes (#1553)
Inventory gave nested members a ZIP or ASAR family from their path suffix. Byte classification replaced it only for ZIP magic, so text named `.apk` or `.asar` stayed a container, and encrypted entries and symlinks kept the suffix guess. A filesystem `.asar` without an ASAR header failed the whole inventory as a malformed archive. Nested ZIP families now follow ZIP magic and ASAR follows its header pickle, shared with root classification. An unread member named like a container has an unknown format and a limitation naming the suffix. ASAR expansion requires the header. The Android projection adds a limitation when no root AndroidManifest.xml was observed, and its rejection names the observed root format. Fixes #1491 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c8fd2f152b
commit
4b985e5021
@@ -119,7 +119,14 @@ describe("Android application projection", () => {
|
||||
projectAndroidApplicationEvidence({ inventory_evidence: [inventory] }),
|
||||
).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "AnalysisInputError" },
|
||||
error: {
|
||||
_tag: "AnalysisInputError",
|
||||
issues: [
|
||||
expect.objectContaining({
|
||||
message: expect.stringContaining("root format is zip"),
|
||||
}),
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -168,6 +175,36 @@ describe("Android application projection", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("APK family without a root manifest", () => {
|
||||
const missingManifest =
|
||||
"No root AndroidManifest.xml occurrence was observed. The APK family comes from the .apk suffix of a ZIP archive, so these bytes may not be an APK.";
|
||||
const projectApk = async (entries: Record<string, string>) => {
|
||||
const root = await createTestTempDirectory("rea-android-manifest-");
|
||||
const path = join(root, "Plain.apk");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
for (const [entry, text] of Object.entries(entries))
|
||||
await writer.add(entry, new TextReader(text));
|
||||
await writeFile(path, await writer.close());
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
return androidApplicationProjectionResultSchema.parse(
|
||||
requireSuccessfulProjection(
|
||||
projectAndroidApplicationEvidence({ inventory_evidence: [inventory] }),
|
||||
).normalized_result,
|
||||
);
|
||||
};
|
||||
|
||||
it("says when the APK family rests only on the ZIP filename suffix", async () => {
|
||||
expect((await projectApk({ "readme.txt": "hello" })).limitations).toContain(
|
||||
missingManifest,
|
||||
);
|
||||
expect(
|
||||
(await projectApk({ "AndroidManifest.xml": "manifest" })).limitations,
|
||||
).not.toContain(missingManifest);
|
||||
});
|
||||
});
|
||||
|
||||
describe("case-distinct APK resource names", () => {
|
||||
it("inventories and projects an APK whose resource names differ only in case", async () => {
|
||||
const root = await createTestTempDirectory("rea-android-case-");
|
||||
|
||||
Reference in New Issue
Block a user