Add fresh device trust, installer recovery and scoped patch runtime

This commit is contained in:
2026-11-17 16:08:53 +01:00
parent 60f8f21f54
commit 81fcd9c8f8
24 changed files with 543 additions and 45 deletions
+19 -5
View File
@@ -2,7 +2,6 @@
"""Prepare an Ed25519 agent release on the signing host and publish through the catalog API."""
import argparse
import base64
import datetime
import getpass
import hashlib
import http.client
@@ -11,7 +10,6 @@ import json
import os
from pathlib import Path
import re
import shutil
import ssl
import subprocess
import tempfile
@@ -132,11 +130,19 @@ def prepare(args):
save_once(config / (label + '-keyring.json'), encoded(ring), args.service_uid)
boot = {'gateway_origin': args.gateway.rstrip('/'), 'updater_sha256': blobs[2]['sha256'], 'updater_bytes': blobs[2]['bytes']}
boot_path = config / (label + '-bootstrap.json')
# The stable bootstrap worker is provisioned separately from replaceable code.
# Keep the original verified worker available for publication into additional
# tenants, even if a newer build also generated a different worker.
stable = args.state / 'bootstrap-workers' / label
provision_folder(stable.parent)
if not boot_path.exists():
save_once(boot_path, encoded(boot), args.service_uid)
existing = json.loads(boot_path.read_bytes())
check(existing['gateway_origin'] == boot['gateway_origin'], 'existing gateway origin differs')
if not stable.exists() and boot == existing:
save_once(stable, (args.artifacts / FILES[platform][2]).read_bytes())
if stable.exists():
check(fingerprint(stable) == (existing['updater_sha256'], existing['updater_bytes']),
'stored bootstrap worker differs from protected configuration')
prepared = args.state / 'prepared' / label / str(args.sequence)
provision_folder(prepared.parent)
if prepared.exists():
@@ -212,9 +218,16 @@ def publish(args):
tenant = str(uuid.UUID(args.tenant))
check(session['tenant_id'] == tenant and 'catalog:write' in session['permissions'], 'tenant catalog write permission required')
path = '/api/v1/tenants/' + tenant
for name, blob in zip(FILES[platform], blobs):
paths = [args.artifacts / name for name in FILES[platform]]
if args.bootstrap_worker:
paths[2] = args.bootstrap_worker
sha, size = fingerprint(paths[2])
name = FILES[platform][2]
blobs[2] = {'artifact_id': str(uuid.uuid5(uuid.NAMESPACE_OID, platform + '/' + name + '/' + sha)),
'sha256': sha, 'bytes': size}
for file, blob in zip(paths, blobs):
query = urlencode(dict(artifact_id=blob['artifact_id'], sha256=blob['sha256'], size_bytes=blob['bytes']))
with (args.artifacts / name).open('rb') as data:
with file.open('rb') as data:
result = client.request('POST', path + '/agent-update-artifacts?' + query, data,
{'Content-Type': 'application/octet-stream', 'Content-Length': str(blob['bytes'])})
check(result['sha256'] == blob['sha256'] and result['size_bytes'] == blob['bytes'], 'artifact receipt differs')
@@ -243,6 +256,7 @@ def main():
cmd.add_argument('--service-uid', type=int, default=os.getuid())
else:
cmd.add_argument('--origin', required=True)
cmd.add_argument('--bootstrap-worker', type=Path, help='Pinned initial stable updater when publishing subsequent code pairs')
cmd.add_argument('--ca', type=Path)
cmd.add_argument('--tenant', required=True)
cmd.add_argument('--envelope', type=Path, required=True)