Skip to content

Commit 0894f10

Browse files
committed
[red] Revalidate preserved public firmware
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th> (cherry picked from commit 693e623f37be92e36ce99cdc6a892f7cff602607)
1 parent d26a4b3 commit 0894f10

3 files changed

Lines changed: 86 additions & 1 deletion

File tree

‎tests/firmware_tests/host/test_release_bundle.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,33 @@ def test_complete_passed_hil_bundle_passes_public_validation(self):
24962496
finally:
24972497
license_fixture.close()
24982498

2499+
def test_previously_activated_public_bundle_revalidates_without_build_evidence(
2500+
self,
2501+
):
2502+
bundle = self.fixture.make_bundle(public=True)
2503+
result = RELEASE.validate_bundle(
2504+
bundle,
2505+
previously_activated_public=True,
2506+
qualification_repo_root=self.fixture.repo,
2507+
)
2508+
self.assertEqual(result["identity"]["version"], "0.4.1")
2509+
2510+
with self.assertRaises(RELEASE.ReleaseError):
2511+
RELEASE.validate_bundle(
2512+
bundle,
2513+
public=True,
2514+
previously_activated_public=True,
2515+
qualification_repo_root=self.fixture.repo,
2516+
)
2517+
2518+
pending = self.fixture.make_bundle(public=False)
2519+
with self.assertRaises(RELEASE.ReleaseError):
2520+
RELEASE.validate_bundle(
2521+
pending,
2522+
previously_activated_public=True,
2523+
qualification_repo_root=self.fixture.repo,
2524+
)
2525+
24992526
def test_corrupt_truncated_missing_and_swapped_parts_fail_closed(self):
25002527
mutations = {
25012528
"corrupt": lambda bundle: (

‎tools/web/src/test/firmware-staging.test.ts‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,64 @@ describe("external firmware bundle staging", () => {
638638
).rejects.toThrow();
639639
});
640640

641+
it("revalidates only an exact previously activated public staged release", async () => {
642+
const fixture = createFirmwareReleaseFixture({
643+
deployment: "public",
644+
accessControlled: false,
645+
hilStatus: "passed",
646+
});
647+
const bundleDirectory = await temporaryDirectory(
648+
"preserved-public-source",
649+
);
650+
const stagedRoot = await temporaryDirectory("preserved-public-staged");
651+
await writeExternalBundle(bundleDirectory, fixture);
652+
const descriptor = await stageFixture({
653+
accessControlled: false,
654+
bundleDirectory,
655+
deployment: "public",
656+
outputDirectory: stagedRoot,
657+
});
658+
659+
const stagingModule =
660+
(await import("../../scripts/stage-firmware-release")) as unknown as {
661+
validatePreservedPublicFirmwareRelease?: (
662+
stagedRoot: string,
663+
options: {
664+
releaseValidator: typeof acceptSyntheticFixture;
665+
},
666+
) => Promise<typeof descriptor>;
667+
};
668+
const validatePreserved =
669+
stagingModule.validatePreservedPublicFirmwareRelease;
670+
expect(validatePreserved).toBeTypeOf("function");
671+
if (!validatePreserved) {
672+
return;
673+
}
674+
675+
await expect(
676+
validatePreserved(stagedRoot, {
677+
releaseValidator: acceptSyntheticFixture,
678+
}),
679+
).resolves.toEqual(descriptor);
680+
681+
const selectionPath = join(
682+
stagedRoot,
683+
".pyble-firmware-release-selection.json",
684+
);
685+
const selection = JSON.parse(await readFile(selectionPath, "utf8")) as {
686+
deployment: string;
687+
hilStatus: string;
688+
};
689+
selection.deployment = "candidate";
690+
selection.hilStatus = "pending";
691+
await writeFile(selectionPath, `${JSON.stringify(selection, null, 2)}\n`);
692+
await expect(
693+
validatePreserved(stagedRoot, {
694+
releaseValidator: acceptSyntheticFixture,
695+
}),
696+
).rejects.toThrow(/previously activated|public|passed/i);
697+
});
698+
641699
it("requires explicit published-GitHub evidence with byte equality before public activation", async () => {
642700
const fixture = createFirmwareReleaseFixture();
643701
const bundleDirectory = await temporaryDirectory(

‎tools/web/src/test/vps-self-hosted-release-contract.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("self-hosted firmware activation", () => {
2525
/\b(?:ssh|rsync)\b[\s\S]{0,2400}\.pyble-firmware-release-selection\.json/,
2626
);
2727
const preservedValidation = script.indexOf(
28-
"--verify-staged",
28+
"--verify-preserved-staged",
2929
authenticatedRetrieval,
3030
);
3131

0 commit comments

Comments
 (0)