Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Accept canonical schema-v4 runtime evidence

Richard Courtmanb369dc5410a7
diff --git a/scripts/installtests/secure_runtime_systemd_lab_test.go b/scripts/installtests/secure_runtime_systemd_lab_test.go
index 0b3fcb834b..fc5384a45e 100644
--- a/scripts/installtests/secure_runtime_systemd_lab_test.go
+++ b/scripts/installtests/secure_runtime_systemd_lab_test.go
@@ -658,7 +658,7 @@ type secureRuntimeTranscriptEvent struct {
Observations map[string]any `json:"observations,omitempty"`
Summary string `json:"summary,omitempty"`
Operation string `json:"operation,omitempty"`
- Output string `json:"output,omitempty"`
+ Output string `json:"output"`
OutputSHA256 string `json:"output_sha256,omitempty"`
}
@@ -788,6 +788,25 @@ func TestSecureRuntimeReceiptCredentialDetection(t *testing.T) {
}
}
+func TestSecureRuntimeTranscriptPreservesEmptyCommandOutput(t *testing.T) {
+ event := secureRuntimeTranscriptEvent{
+ Sequence: 1, EventID: "event-0001", ObservedAt: time.Now().UTC().Format(time.RFC3339Nano),
+ Kind: "command_output", Operation: "systemctl", OutputSHA256: secureRuntimeHash(nil),
+ }
+ encoded, err := json.Marshal(event)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var payload map[string]any
+ if err := json.Unmarshal(encoded, &payload); err != nil {
+ t.Fatal(err)
+ }
+ output, present := payload["output"]
+ if !present || output != "" {
+ t.Fatalf("empty command output was not represented explicitly: %s", encoded)
+ }
+}
+
func TestSecureRuntimeSourceManifestCoversTransitiveProviders(t *testing.T) {
_, hashes := secureRuntimeLoadSourceBoundary(t, runtime.GOARCH)
for _, required := range []string{
diff --git a/scripts/release_control/secure_runtime_attestation.py b/scripts/release_control/secure_runtime_attestation.py
index 41f04983bf..0af9381b98 100644
--- a/scripts/release_control/secure_runtime_attestation.py
+++ b/scripts/release_control/secure_runtime_attestation.py
@@ -11,12 +11,17 @@ import re
import subprocess
import sys
from datetime import datetime, timezone
+from decimal import Decimal
from pathlib import Path, PurePosixPath
from typing import Any, Sequence
COMMIT_RE = re.compile(r"^[0-9a-f]{40}$")
SHA256_RE = re.compile(r"^[0-9a-f]{64}$")
+RFC3339_RE = re.compile(
+ r"^(?P<whole>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})"
+ r"(?:\.(?P<fraction>\d+))?(?P<offset>Z|[+-]\d{2}:\d{2})$"
+)
RECEIPT_SCHEMA_VERSION = 4
ATTESTATION_SCHEMA_VERSION = 4
SOURCE_MANIFEST_PATH = "scripts/release_control/secure_runtime_source_manifest_v4.json"
@@ -280,16 +285,25 @@ def load_receipt(path: Path) -> tuple[dict[str, Any], bytes]:
return receipt, raw
-def parse_utc_timestamp(value: Any, label: str) -> datetime:
+def parse_utc_timestamp(value: Any, label: str) -> Decimal:
if not isinstance(value, str) or not value:
raise AttestationError(f"{label} must be an RFC3339 timestamp")
+ match = RFC3339_RE.fullmatch(value)
+ if match is None:
+ raise AttestationError(f"{label} must be an RFC3339 timestamp")
+ offset = "+00:00" if match.group("offset") == "Z" else match.group("offset")
try:
- parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
+ parsed = datetime.fromisoformat(match.group("whole") + offset)
except ValueError as exc:
raise AttestationError(f"{label} must be an RFC3339 timestamp") from exc
if parsed.tzinfo is None or parsed.utcoffset() != timezone.utc.utcoffset(parsed):
raise AttestationError(f"{label} must be UTC")
- return parsed
+ delta = parsed - datetime(1970, 1, 1, tzinfo=timezone.utc)
+ whole_seconds = delta.days * 86400 + delta.seconds
+ fraction = match.group("fraction")
+ if fraction is None:
+ return Decimal(whole_seconds)
+ return Decimal(whole_seconds) + Decimal(f"0.{fraction}")
def load_and_verify_transcript(
@@ -312,7 +326,7 @@ def load_and_verify_transcript(
raise AttestationError("transcript digest mismatch")
events: list[dict[str, Any]] = []
- previous_time: datetime | None = None
+ previous_time: Decimal | None = None
event_ids: set[str] = set()
for line_number, raw_line in enumerate(raw.splitlines(), 1):
if not raw_line.strip():
diff --git a/scripts/release_control/secure_runtime_attestation_test.py b/scripts/release_control/secure_runtime_attestation_test.py
index 8a49ed6cc4..4f68200b7d 100644
--- a/scripts/release_control/secure_runtime_attestation_test.py
+++ b/scripts/release_control/secure_runtime_attestation_test.py
@@ -21,6 +21,7 @@ from secure_runtime_attestation import (
SOURCE_MANIFEST_PATH,
SOURCE_MANIFEST_SCHEMA_VERSION,
create_attestation,
+ parse_utc_timestamp,
sha256_bytes,
verify_artifact_build_identity,
)
@@ -227,6 +228,17 @@ class SecureRuntimeAttestationTest(unittest.TestCase):
self.assertEqual(result["source_manifest"]["manifest_id"], SOURCE_MANIFEST_ID)
self.assertEqual(len(result["attestation_tool_sha256"]), 64)
+ def test_accepts_go_rfc3339nano_without_losing_fractional_order(self) -> None:
+ earlier = parse_utc_timestamp("2026-08-30T17:53:17.73472767Z", "earlier")
+ later = parse_utc_timestamp("2026-08-30T17:53:17.734727671Z", "later")
+ equivalent = parse_utc_timestamp("2026-08-30T17:53:17.734727670+00:00", "equivalent")
+ self.assertLess(earlier, later)
+ self.assertEqual(earlier, equivalent)
+
+ def test_rejects_non_utc_rfc3339nano(self) -> None:
+ with self.assertRaisesRegex(AttestationError, "must be UTC"):
+ parse_utc_timestamp("2026-08-30T18:53:17.73472767+01:00", "offset")
+
def test_accepts_exact_release_candidate_ref(self) -> None:
self.git("tag", "v9.0.0-rc.1", self.commit)
result = self.attest(release_candidate_ref="v9.0.0-rc.1")