Skip to content

Commit d701eab

Browse files
committed
[green] Enable exact unqualified firmware beta
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent f8c0919 commit d701eab

8 files changed

Lines changed: 93 additions & 28 deletions

File tree

‎tools/web/deploy/nginx/10-pyble-dev-https.conf‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,6 @@ server {
7575
try_files $uri =404;
7676
}
7777

78-
# v0.4.1 was a pending pre-public candidate exposed without the required
79-
# access control. Keep its retained bytes outside public routing forever.
80-
location ^~ /firmware/v0.4.1/ {
81-
include /etc/nginx/snippets/pyble-security-headers.conf;
82-
add_header Cache-Control "no-store" always;
83-
error_page 404 = @burned_firmware_candidate;
84-
return 404;
85-
}
86-
87-
location @burned_firmware_candidate {
88-
internal;
89-
include /etc/nginx/snippets/pyble-security-headers.conf;
90-
add_header Cache-Control "no-store" always;
91-
return 404;
92-
}
93-
9478
location ^~ /firmware/ {
9579
include /etc/nginx/snippets/pyble-security-headers.conf;
9680
add_header Cache-Control $pyble_firmware_cache_control always;

‎tools/web/src/components/flash-status.tsx‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { installReleaseKeyedArtifactFetch } from "@/lib/firmware-fetch-cache";
99
import { verifyFirmwareProfile } from "@/lib/firmware-integrity";
1010
import {
1111
hasExactFirmwareProfileDescriptors,
12+
isExactPublicBetaFirmwareRelease,
1213
type FirmwareProfileDescriptor,
1314
type FirmwareProfileId,
1415
type FirmwareReleaseDescriptor,
@@ -126,9 +127,23 @@ function policyFailure(release: FirmwareReleaseDescriptor | null | undefined) {
126127
};
127128
}
128129
if (release.deployment !== "public" && release.deployment !== "candidate") {
130+
if (
131+
release.deployment !== "public-beta" ||
132+
!isExactPublicBetaFirmwareRelease(release)
133+
) {
134+
return {
135+
heading: "Installer unavailable",
136+
body: "The selected firmware deployment mode is invalid, so installation remains unavailable.",
137+
};
138+
}
139+
}
140+
if (
141+
release.deployment === "public-beta" &&
142+
!isExactPublicBetaFirmwareRelease(release)
143+
) {
129144
return {
130145
heading: "Installer unavailable",
131-
body: "The selected firmware deployment mode is invalid, so installation remains unavailable.",
146+
body: "The public beta does not match the exact attested v0.4.1 firmware, so installation remains unavailable.",
132147
};
133148
}
134149
if (!hasExactFirmwareProfileDescriptors(release.version, release.profiles)) {
@@ -285,6 +300,7 @@ function FlashStatusForRelease({
285300
);
286301
const everyConsent = consentItems.every(({ id }) => consents[id]);
287302
const candidate = activeRelease.deployment === "candidate";
303+
const publicBeta = activeRelease.deployment === "public-beta";
288304

289305
function chooseProfile(profileId: FirmwareProfileId) {
290306
verificationAttempt.current += 1;
@@ -372,18 +388,24 @@ function FlashStatusForRelease({
372388
<div>
373389
<p className="flash-status__eyebrow">Installer status</p>
374390
<h2 id="installer-status-title">
375-
{candidate ? "Protected release candidate" : "Qualified release"}
391+
{candidate
392+
? "Protected release candidate"
393+
: publicBeta
394+
? "Unqualified firmware beta"
395+
: "Qualified release"}
376396
</h2>
377397
</div>
378398
</div>
379399

380400
<div
381-
role={candidate ? "status" : undefined}
401+
role={candidate || publicBeta ? "status" : undefined}
382402
className="flash-status__message"
383403
>
384404
{candidate
385405
? "Protected release candidate: hardware validation is pending."
386-
: "Select and verify the exact module profile before installation."}
406+
: publicBeta
407+
? "Unqualified firmware beta: full hardware-in-the-loop qualification is pending. These exact v0.4.1 bytes were manually exercised on the maintainer's ESP32 and ESP32-S3 boards, but they are not qualified. Use at your own risk."
408+
: "Select and verify the exact module profile before installation."}
387409
</div>
388410

389411
<div
@@ -475,6 +497,12 @@ function FlashStatusForRelease({
475497
Installation erases the device. Keep stable power connected and
476498
select only the serial port for this board.
477499
</p>
500+
{publicBeta ? (
501+
<p className="flash-warning">
502+
This is an unqualified beta with full HIL pending. Use at your own
503+
risk.
504+
</p>
505+
) : null}
478506
<a className="text-link" href={activeRelease.recoveryPath}>
479507
{`Version ${verified.version} recovery instructions`}
480508
</a>
@@ -484,7 +512,8 @@ function FlashStatusForRelease({
484512
type="button"
485513
slot="activate"
486514
>
487-
Install PyBLE {verified.version}
515+
{publicBeta ? "Install unqualified beta PyBLE" : "Install PyBLE"}{" "}
516+
{verified.version}
488517
</button>
489518
</esp-web-install-button>
490519
</div>

‎tools/web/src/lib/firmware-integrity.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import {
55
firmwareProfileDescriptors,
66
firmwareProfileTable,
7+
isExactPublicBetaFirmwareRelease,
78
type FirmwareProfileDescriptor,
89
type FirmwareProfileId,
910
type FirmwareReleaseDescriptor,
@@ -275,7 +276,8 @@ function validateDescriptor(
275276
) {
276277
if (
277278
descriptor.deployment !== "public" &&
278-
descriptor.deployment !== "candidate"
279+
descriptor.deployment !== "candidate" &&
280+
descriptor.deployment !== "public-beta"
279281
) {
280282
fail("Selected firmware deployment mode is invalid");
281283
}
@@ -294,6 +296,12 @@ function validateDescriptor(
294296
if (descriptor.deployment === "public" && descriptor.hilStatus !== "passed") {
295297
fail("Public firmware requires passed hardware validation");
296298
}
299+
if (
300+
descriptor.deployment === "public-beta" &&
301+
!isExactPublicBetaFirmwareRelease(descriptor)
302+
) {
303+
fail("Public beta does not match the exact attested v0.4.1 release");
304+
}
297305

298306
const releasePath = `/firmware/v${descriptor.version}/release.json`;
299307
const schemaPath = `/firmware/v${descriptor.version}/release.schema.json`;
@@ -623,6 +631,12 @@ function validateRelease(
623631
if (descriptor.deployment === "candidate" && !descriptor.accessControlled) {
624632
fail("Pending candidate release is not access-controlled");
625633
}
634+
if (
635+
descriptor.deployment === "public-beta" &&
636+
statuses.some((status) => status !== "pending")
637+
) {
638+
fail("Public beta hardware validation must remain pending");
639+
}
626640
const aggregateStatus = statuses.every((status) => status === "passed")
627641
? "passed"
628642
: "pending";

‎tools/web/src/lib/firmware-release-selection.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { resolve } from "node:path";
66

77
import {
88
hasExactFirmwareProfileDescriptors,
9+
isExactPublicBetaFirmwareRelease,
910
type FirmwareReleaseDescriptor,
1011
} from "@/lib/firmware-release";
1112

@@ -30,7 +31,8 @@ export function firmwareReleaseSelectedAtBuild(): FirmwareReleaseDescriptor | nu
3031
const descriptor = parsed as FirmwareReleaseDescriptor;
3132
if (
3233
descriptor.deployment !== "public" &&
33-
descriptor.deployment !== "candidate"
34+
descriptor.deployment !== "candidate" &&
35+
descriptor.deployment !== "public-beta"
3436
) {
3537
throw new Error(
3638
"Build-selected firmware descriptor has an invalid deployment mode",
@@ -57,5 +59,13 @@ export function firmwareReleaseSelectedAtBuild(): FirmwareReleaseDescriptor | nu
5759
"Build-selected public firmware must have passed all hardware validation",
5860
);
5961
}
62+
if (
63+
descriptor.deployment === "public-beta" &&
64+
!isExactPublicBetaFirmwareRelease(descriptor)
65+
) {
66+
throw new Error(
67+
"Build-selected public beta does not match the exact attested v0.4.1 release",
68+
);
69+
}
6070
return descriptor;
6171
}

‎tools/web/src/lib/firmware-release.ts‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ export const plannedFirmwareProfileTable = [
5252
export type FirmwareProfileId = (typeof firmwareProfileTable)[number]["id"];
5353
export type PlannedFirmwareProfileId =
5454
(typeof plannedFirmwareProfileTable)[number]["id"];
55-
export type FirmwareDeployment = "public" | "candidate";
55+
export type FirmwareDeployment = "public" | "candidate" | "public-beta";
5656
export type FirmwareHilStatus = "pending" | "passed";
5757

58+
export const publicBetaFirmwareVersion = "0.4.1";
59+
export const publicBetaReleaseJsonSha256 =
60+
"8b84fbb65a0463d20369e1d86dac566ca7a2039ebc30f9186f55c05421962445";
61+
5862
export interface FirmwareProfileDescriptor {
5963
readonly id: FirmwareProfileId;
6064
readonly label: string;
@@ -98,6 +102,27 @@ export interface VerifiedFirmwareProfile {
98102
readonly version: string;
99103
}
100104

105+
export function isExactPublicBetaFirmwareRelease(
106+
value: unknown,
107+
): value is FirmwareReleaseDescriptor {
108+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
109+
return false;
110+
}
111+
const descriptor = value as Partial<FirmwareReleaseDescriptor>;
112+
const version = publicBetaFirmwareVersion;
113+
return (
114+
descriptor.deployment === "public-beta" &&
115+
descriptor.accessControlled === false &&
116+
descriptor.version === version &&
117+
descriptor.hilStatus === "pending" &&
118+
descriptor.releaseJson?.path === `/firmware/v${version}/release.json` &&
119+
descriptor.releaseJson?.sha256 === publicBetaReleaseJsonSha256 &&
120+
descriptor.schemaPath === `/firmware/v${version}/release.schema.json` &&
121+
descriptor.recoveryPath === `/firmware/v${version}/RECOVERY.md` &&
122+
hasExactFirmwareProfileDescriptors(version, descriptor.profiles)
123+
);
124+
}
125+
101126
export function profileDescriptor(
102127
version: string,
103128
profileId: FirmwareProfileId,

‎tools/web/src/test/build-contract.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ describe("production build contract", () => {
173173
});
174174

175175
it("accepts only the exact attested public-beta selector at the build boundary", async () => {
176-
const selectionRoot = await mkdtemp(join(tmpdir(), "pyble-beta-selection-"));
176+
const selectionRoot = await mkdtemp(
177+
join(tmpdir(), "pyble-beta-selection-"),
178+
);
177179
const selectionFile = join(selectionRoot, "selection.json");
178180
await writeFile(
179181
selectionFile,

‎tools/web/src/test/fixtures/firmware-release.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,7 @@ export const publicBetaFirmwareRelease = {
714714
accessControlled: false,
715715
releaseJson: {
716716
path: "/firmware/v0.4.1/release.json",
717-
sha256:
718-
"8b84fbb65a0463d20369e1d86dac566ca7a2039ebc30f9186f55c05421962445",
717+
sha256: "8b84fbb65a0463d20369e1d86dac566ca7a2039ebc30f9186f55c05421962445",
719718
},
720719
} satisfies FirmwareReleaseDescriptor;
721720
export const pendingCandidateFirmwareRelease = createFirmwareReleaseFixture({

‎tools/web/src/test/flash-installer.test.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ describe("browser firmware installer states", () => {
335335
await waitFor(() => {
336336
expect(document.querySelector("esp-web-install-button")).not.toBeNull();
337337
});
338-
expect(screen.getByText(/unqualified beta.*use at your own risk/i)).toBeInTheDocument();
338+
expect(
339+
screen.getByText(/unqualified beta.*use at your own risk/i),
340+
).toBeInTheDocument();
339341
expect(
340342
screen.getByRole("button", {
341343
name: /install unqualified beta pyble 0\.4\.1/i,

0 commit comments

Comments
 (0)