fix(artifacts): bound mobile projection candidates
This commit is contained in:
@@ -111,4 +111,34 @@ describe("Apple application projection", () => {
|
||||
error: { _tag: "AnalysisInputError" },
|
||||
});
|
||||
});
|
||||
|
||||
it("infers an application root when the IPA omits directory entries", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "rea-apple-root-"));
|
||||
const path = join(root, "Fixture.ipa");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add(
|
||||
"Payload/Fixture.app/Fixture",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0xcf, 0xfa, 0xed, 0xfe, 0x0c, 0, 0, 1]),
|
||||
),
|
||||
);
|
||||
await writeFile(path, await writer.close());
|
||||
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
const result = projectAppleApplicationEvidence({
|
||||
inventory_evidence: [inventory],
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
expect(
|
||||
appleApplicationProjectionResultSchema.parse(
|
||||
result.value.normalized_result,
|
||||
),
|
||||
).toMatchObject({
|
||||
application_roots: ["Payload/Fixture.app"],
|
||||
components: { executables: [expect.any(Object)] },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { projectBoundedCartesian } from "../src/domain/boundedCartesianProjection.js";
|
||||
|
||||
describe("bounded Cartesian projection", () => {
|
||||
it("stops projection work at the output limit", () => {
|
||||
const values = Array.from({ length: 10_000 }, (_, index) => index);
|
||||
let projections = 0;
|
||||
|
||||
const result = projectBoundedCartesian(values, values, 3, (left, right) => {
|
||||
projections += 1;
|
||||
return [left, right] as const;
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
values: [
|
||||
[0, 0],
|
||||
[0, 1],
|
||||
[0, 2],
|
||||
],
|
||||
omitted: 100_000_000 - 3,
|
||||
});
|
||||
expect(projections).toBe(3);
|
||||
});
|
||||
});
|
||||
@@ -78,6 +78,11 @@ describe("runtime identification", () => {
|
||||
]);
|
||||
expect(first.runtimes).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
family: "android",
|
||||
inspection: "available",
|
||||
provider_id: "rea-android-application",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
family: "jvm",
|
||||
inspection: "provider-missing",
|
||||
|
||||
Reference in New Issue
Block a user