mirror of
https://github.com/morluto/rea.git
synced 2026-11-29 01:46:39 +00:00
extract_artifact copied every selected occurrence's limitations into its own list, prefixed with the path. Extracting VLC's APK listed 862 limitations, 858 of them case-folding collisions between R8-shrunk resource names, and repeated them in the Evidence envelope. Each written file now carries its occurrence's limitations in artifacts[].limitations, absent when it has none, and the extraction's own list counts the files that carry them. The file digest and extraction ID are unchanged: they cover the written files, not their limitations. The same APK's extraction now lists 5 limitations. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { TextReader, Uint8ArrayWriter, ZipWriter } from "@zip.js/zip.js";
|
|
import { expect } from "vitest";
|
|
|
|
import { artifactExtractionResultSchema } from "../../src/domain/artifactGraph.js";
|
|
import { parseEvidence } from "../../src/domain/evidence.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
cliTest(
|
|
"keeps each extracted file's occurrence limitations on that file",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-zip-case-extraction-");
|
|
const archivePath = join(root, "case.zip");
|
|
const writer = new ZipWriter(new Uint8ArrayWriter());
|
|
// 50 pairs that collide under case folding, as R8-shrunk resources do.
|
|
for (let index = 0; index < 50; index += 1)
|
|
for (const name of [
|
|
`res/-A${String(index)}.xml`,
|
|
`res/-a${String(index)}.xml`,
|
|
])
|
|
await writer.add(name, new TextReader(name));
|
|
await writeFile(archivePath, await writer.close());
|
|
const output = join(root, "out");
|
|
const extracted = await cli.run({
|
|
arguments: [
|
|
"extract-artifact",
|
|
archivePath,
|
|
"--output-root",
|
|
output,
|
|
"--json",
|
|
],
|
|
});
|
|
expect(extracted.exitCode, extracted.stdout + extracted.stderr).toBe(0);
|
|
const extraction = artifactExtractionResultSchema.parse(
|
|
parseEvidence(extracted.json).normalized_result,
|
|
);
|
|
expect(extraction.artifacts).toHaveLength(100);
|
|
expect(
|
|
extraction.artifacts.find(
|
|
({ relative_path }) => relative_path === "res/-A0.xml",
|
|
)?.limitations,
|
|
).toEqual([
|
|
expect.stringContaining(
|
|
"Logical path res/-A0.xml collides under English (en-US) Unicode case folding with res/-a0.xml",
|
|
),
|
|
]);
|
|
// The extraction's own list counts them instead of repeating each one.
|
|
expect(extraction.limitations).toContain(
|
|
"100 extracted file(s) carry their inventory occurrence's limitations in artifacts[].limitations.",
|
|
);
|
|
expect(extraction.limitations.length).toBeLessThan(10);
|
|
},
|
|
);
|