diff --git a/src/domain/zip/zipEntryText.test.ts b/src/domain/zip/zipEntryText.test.ts deleted file mode 100644 index 1fe3864b87..0000000000 --- a/src/domain/zip/zipEntryText.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { expect, it } from "vitest"; - -import { decodeZipCp437 } from "./zipEntryText.js"; - -it("decodes legacy ZIP names as ASCII below 0x80 and Unicode CP437 above", () => { - // macOS folder icon file: the trailing CR stays a control character. - expect(decodeZipCp437(Uint8Array.of(0x49, 0x63, 0x6f, 0x6e, 0x0d))).toBe( - "Icon\r", - ); - expect(decodeZipCp437(Uint8Array.of(0x80, 0x9e, 0xe1, 0xff))).toBe( - `Ç₧ß${String.fromCharCode(0xa0)}`, - ); -}); diff --git a/src/nuget/NugetNupkgParser.test.ts b/src/nuget/NugetNupkgParser.test.ts index f1b9505fab..b1eec8da32 100644 --- a/src/nuget/NugetNupkgParser.test.ts +++ b/src/nuget/NugetNupkgParser.test.ts @@ -1,9 +1,6 @@ import { ParseFailureError } from "../domain/parseFailure.js"; import { expect, it, vi } from "vitest"; import { createHash } from "node:crypto"; -import { writeFile } from "node:fs/promises"; -import { join } from "node:path"; -import { createTestTempDirectory } from "../../tests/fixtures/temporaryDirectory.js"; import { TextReader, Uint8ArrayWriter, @@ -21,13 +18,8 @@ import { nugetNupkgMalformedNuspecFixture, nugetNupkgMissingNuspecFixture, ungroupedNuspec, - NUPKG_NAME_ENCODING_CASES, - nugetNupkgNameEncodingFixture, } from "./NugetNupkg.fixture.js"; -import { - ArtifactReaderFailure, - ZipArtifactReader, -} from "../resources/index.js"; +import { ArtifactReaderFailure } from "../resources/index.js"; import { NUPKG_LIMITATIONS, distinctTargetMatches, @@ -44,48 +36,6 @@ const artifactOf = (bytes: Uint8Array) => ({ bytes: bytes.length, }); -it.each(NUPKG_NAME_ENCODING_CASES)( - "preserves $encoding filename provenance consistently with the shared ZIP reader", - async (input) => { - const bytes = await nugetNupkgNameEncodingFixture(input); - const result = await parseNugetNupkg(bytes, artifactOf(bytes), defaults); - expect(result.contents).toContainEqual( - expect.objectContaining({ - name: input.name, - path: input.name, - role: "lib", - }), - ); - const root = await createTestTempDirectory("rea-nupkg-name-encoding-"); - const path = join(root, "package.nupkg"); - await writeFile(path, bytes); - const reader = new ZipArtifactReader(path, "zip"); - try { - const entries = []; - for await (const entry of reader.entries()) entries.push(entry); - const shared = entries.find((entry) => entry.path === input.name); - expect(shared).toBeDefined(); - const warnings = result.limitations.filter((value) => - value.includes("CP437"), - ); - if (input.uncertain) { - expect(shared?.limitations).toEqual([ - expect.stringContaining(input.rawName.toString("hex")), - ]); - expect(warnings).toEqual([ - expect.stringContaining(shared!.limitations[0]!), - ]); - expect(warnings[0]).toContain(JSON.stringify(input.name)); - } else { - expect(shared?.limitations).toEqual([]); - expect(warnings).toEqual([]); - } - } finally { - await reader.close(); - } - }, -); - it("redacts an unfollowed authority manifest target before package-path normalization", async () => { const bytes = await nugetNupkgFixture({ relsTarget: "//user:password@feed.invalid/missing.nuspec?token=visible", diff --git a/tests/acceptance/nugetNupkgCli.test.ts b/tests/acceptance/nugetNupkgCli.test.ts index 975f8eff10..11f56a0cb8 100644 --- a/tests/acceptance/nugetNupkgCli.test.ts +++ b/tests/acceptance/nugetNupkgCli.test.ts @@ -43,14 +43,20 @@ cliTest( ); expect(evidence.normalized_result).toEqual(cliEvidence.normalized_result); expect(evidence.normalized_result.contents).toContainEqual( - expect.objectContaining({ name: input.name, path: input.name }), + expect.objectContaining({ + name: input.name, + path: input.name, + role: "lib", + }), ); const warnings = evidence.normalized_result.limitations.filter((value) => value.includes("CP437"), ); if (input.uncertain) { expect(warnings).toEqual([ - expect.stringContaining(input.rawName.toString("hex")), + expect.stringContaining( + `CP437 fallback; source encoding unverified; raw hex: ${input.rawName.toString("hex")}`, + ), ]); expect(warnings[0]).toContain(JSON.stringify(input.name)); expect(evidence.limitations).toContain(warnings[0]); diff --git a/tests/boundary/filesystem/artifactZipIntegrity.test.ts b/tests/boundary/filesystem/artifactZipIntegrity.test.ts index 65c5d03b03..c501298943 100644 --- a/tests/boundary/filesystem/artifactZipIntegrity.test.ts +++ b/tests/boundary/filesystem/artifactZipIntegrity.test.ts @@ -160,7 +160,12 @@ const legacyControlNames = [ ] as const; it.each([ - ["legacy CP437", Buffer.from([0x82, 0x2e, 0x74, 0x78, 0x74]), false, "é.txt"], + [ + "legacy CP437 mapping", + Buffer.from([0x82, 0x80, 0x9e, 0xe1, 0xff, 0x2e, 0x74, 0x78, 0x74]), + false, + "éÇ₧ß\u00a0.txt", + ], ["unflagged ASCII", Buffer.from("plain.txt"), false, "plain.txt"], ...legacyControlNames, [ @@ -297,29 +302,6 @@ it("preserves valid Info-ZIP Unicode Path overrides", async () => { ); }); -it("reports unflagged high-byte ZIP names as CP437 readings with their source bytes", async () => { - const root = await createTestTempDirectory("rea-zip-legacy-name-limitation-"); - const path = join(root, "legacy-name.zip"); - const rawName = Buffer.from([0xc7, 0xd1, 0xb1, 0xdb, 0x2e, 0x74, 0x78, 0x74]); - await writeSingleEntryZip(path, "name.txt"); - const archive = await readFile(path); - await writeFile( - path, - rewriteSingleEntryZipName(archive, "name.txt", rawName, false), - ); - - const inventory = await inventoryArtifact(path); - expect(inventory.occurrences).toContainEqual( - expect.objectContaining({ - logical_path: "╟╤▒█.txt", - hash_status: "verified", - limitations: [ - expect.stringMatching(/CP437.*unverified.*c7d1b1db2e747874/iu), - ], - }), - ); -}); - it("falls back to the stored name and reports bytes when a Unicode Path field CRC is invalid", async () => { const root = await createTestTempDirectory( "rea-zip-invalid-unicode-extra-crc-", diff --git a/tests/boundary/mcp/artifactMcp.test.ts b/tests/boundary/mcp/artifactMcp.test.ts index 930be4f829..87a5e3f71c 100644 --- a/tests/boundary/mcp/artifactMcp.test.ts +++ b/tests/boundary/mcp/artifactMcp.test.ts @@ -294,6 +294,7 @@ it("preserves raw legacy ZIP name bytes and CP437 path interpretation through MC expect(inventory.occurrences).toContainEqual( expect.objectContaining({ logical_path: "╟╤▒█.txt", + hash_status: "verified", limitations: [ expect.stringMatching(/CP437.*unverified.*c7d1b1db2e747874/iu), ], diff --git a/tests/boundary/providers/desktopZipPython.test.ts b/tests/boundary/providers/desktopZipPython.test.ts index a988810002..0affdcabd4 100644 --- a/tests/boundary/providers/desktopZipPython.test.ts +++ b/tests/boundary/providers/desktopZipPython.test.ts @@ -88,7 +88,6 @@ it("gives the UTF-8 flag precedence over a Unicode Path for names and formats", }); it.each([ - "file", "crc", "version", "short",