fix(esp): disclose partition entries outside the table checksum (#12384)

* fix(esp): disclose partition entries outside the table checksum

* fix(esp): label the partition checksum offset origin

* fix(esp): count partition entries outside the table MD5

The coverage warning was only prose, and it presented the MD5 entry's
table-relative offset without a structured fact. Record
entriesAfterChecksum on the MD5 result, project it as
entries_after_checksum, and keep the warning as presentation.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(esp): accept saved flash inventories without the checksum count

A required entries_after_checksum rejected ESP flash Evidence written
before the field existed. Keep the count exactOptional so omission
stays unknown, and still emit it for new inventories.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com>
Co-authored-by: ShuaixinHuang <ShuaixinHuang@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-11-19 11:59:02 -05:00
1 parent 8c3dbd99e1
commit ebd709cef5
7 files changed
+232 -6

No files matched your search

@@ -18,6 +18,7 @@ import {
espFlashDump,
otaData,
otaRecord,
partitionEntry,
partitionTable,
} from "../domain/firmware/espFlash.fixture.js";
import {
@@ -106,7 +107,7 @@ describe("ESP flash layout inventory", () => {
flash_address: 0x8000,
method: "default",
partition_count: 6,
md5: { status: "valid" },
md5: { status: "valid", entries_after_checksum: 0 },
},
partitions_outside_dump: [],
otadata: { partition_index: 1 },
@@ -174,6 +175,30 @@ describe("ESP flash layout inventory", () => {
expect.stringMatching(/0xa000.*0x1000.*MD5.*does not record/iu),
);
});
it("reports partition entries after the MD5 record as a count", async () => {
const [first, second, third] = TWO_OTA_PARTITIONS;
const prefix = partitionTable([first!]);
const snapshot = await scanCanonicalArtifactInventory(
await writeDump(
espFlashDump({
bootloader: { at: 0, bytes: BOOTLOADER },
table: Buffer.concat([
prefix.subarray(0, 64),
partitionEntry(second!),
partitionEntry(third!),
prefix.subarray(64),
]),
}),
),
);
expect(root(snapshot)).toMatchObject({
partition_table: {
flash_address: 0x8000,
md5: { status: "valid", entries_after_checksum: 2 },
},
});
});
});
it("inventories a zero-byte partition without reporting missing bytes", async () => {
@@ -334,6 +334,7 @@ const layoutMetadata = (
status: table.md5.status,
stored: table.md5.stored,
computed: table.md5.computed,
entries_after_checksum: table.md5.entriesAfterChecksum,
},
},
partitions_outside_dump: table.partitions