From e7cf1aed73bd998c122dd7dda7bbb4ef8bd2d31d Mon Sep 17 00:00:00 2001 From: Kevin Janssen Date: Sun, 15 Nov 2026 20:37:49 +0100 Subject: [PATCH] Bind empty-profile receipts to the file ID recorded before publication --- .../windows/Open-TimeProfileReceiptWindow.ps1 | 31 ++++++++++++++----- docs/windows-time-profile-config.md | 14 +++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/deploy/windows/Open-TimeProfileReceiptWindow.ps1 b/deploy/windows/Open-TimeProfileReceiptWindow.ps1 index 35d0466..ef6504b 100644 --- a/deploy/windows/Open-TimeProfileReceiptWindow.ps1 +++ b/deploy/windows/Open-TimeProfileReceiptWindow.ps1 @@ -1,13 +1,13 @@ #requires -Version 5.1 #requires -RunAsAdministrator # The relay receives a fixed public receipt. There is no command reader. -param([Parameter(Mandatory)][DateTimeOffset]$Until) +param([Parameter(Mandatory)][DateTimeOffset]$Until, [switch]$ResumeEmpty) $ErrorActionPreference = 'Stop' $deadline = [DateTimeOffset]::UtcNow.AddMinutes(12) if ($deadline -gt $until) { $deadline = $until } if ($deadline -le [DateTimeOffset]::UtcNow) { throw 'Das Wartungsfenster ist abgelaufen.' } -$base = 'https://gitea.incoso.eu/kevin_janssen/rust-discovery/raw/commit/38e6df51ea57a76ec2d5462513d59e855f36c0f4/deploy/windows' +$base = 'https://gitea.incoso.eu/kevin_janssen/rust-discovery/raw/commit/b614b6f5be9d700eef20586a038aa9643356049a/deploy/windows' $bootstrap = 'C:\ProgramData\RustDiscoveryBootstrap' $caseId = 'ad9fd154-b2be-4f5d-9e17-65abb721ceaf' $case = Join-Path $bootstrap "time-profile-$caseId" @@ -24,7 +24,7 @@ $null = New-Item -ItemType Directory -Path $work $listener = $null $ssh = $null $scripts = [ordered]@{ - 'Complete-OriginalTimeProfile.ps1' = 'c2fb92ebd0f4ab19545b55ad92d7a9b21ec6e3604d33107d0dd78882162be131' + 'Complete-OriginalTimeProfile.ps1' = 'aacc56321dccc6efe496a782d4cf67defba5b0be6759cba08d9e0b775913210b' 'Read-PassiveTimeSamples.ps1' = 'd9e2b9344c19af1296b86ec70ba754ef820f369ac5ec897979bd4233e0722d04' } try { @@ -45,17 +45,25 @@ try { $ssh = Start-Process -FilePath "$sshBin\ssh.exe" -ArgumentList $options -PassThru -NoNewWindow if ($ssh.WaitForExit(1800)) { throw "SSH Exit $($ssh.ExitCode)" } Write-Host 'Wartungsfenster aktiv. Dieses Fenster offen lassen. Strg+C beendet es.' - $receipt = [ordered]@{session=$session; case_id=$caseId; method='initial_create'; phase='preflight'; read_only_channel=$true} - $result = Join-Path $case 'console-initial-create-result.json' - $intentPath = Join-Path $case 'console-initial-create-intent.json' - $failurePath = Join-Path $case 'console-initial-create-error.json' + $method = 'initial_create' + $prefix = 'console-initial-create' + $arguments = @{ InitialCreate=$true } + if ($ResumeEmpty) { + $method = 'resume_empty' + $prefix = 'console-resume-empty' + $arguments = @{ ResumeEmpty=$true } + } + $receipt = [ordered]@{session=$session; case_id=$caseId; method=$method; phase='preflight'; read_only_channel=$true} + $result = Join-Path $case "$prefix-result.json" + $intentPath = Join-Path $case "$prefix-intent.json" + $failurePath = Join-Path $case "$prefix-error.json" $receipt.finalizer_invoked = $false try { if (Test-Path -LiteralPath $failurePath) { throw 'Previous profile finalization error recorded' } if (!(Test-Path -LiteralPath $result)) { if (Test-Path -LiteralPath $intentPath) { throw 'Previous profile finalization intent without result' } $receipt.finalizer_invoked = $true - $null = & (Join-Path $work 'Complete-OriginalTimeProfile.ps1') -InitialCreate + $null = & (Join-Path $work 'Complete-OriginalTimeProfile.ps1') @arguments } $record = Get-Content -LiteralPath $result -Raw | ConvertFrom-Json $actual = Get-FileHash -LiteralPath 'C:\ProgramData\RustDiscoverySystem\time-attestation.json' @@ -68,6 +76,13 @@ try { $marker.config_sha256 -ne $actual.Hash -or $record.configuration.sha256 -ne $actual.Hash -or $record.original_candidate.file_id -cne '6d990300000003000000000000000000' -or $record.configuration.file_id -cnotmatch '^[0-9a-f]{32}$' -or $record.configuration.file_id -ceq '6d990300000003000000000000000000') { throw 'Unexpected finalization intent' } + if ($ResumeEmpty) { + if ($record.resumed_empty -ne $true -or $marker.target_id -cne $record.configuration.file_id) { + throw 'Recovered profile file identity differs from the recovery intent' + } + $receipt.resumed_empty = $true + $receipt.reserved_target_id = $marker.target_id + } $receipt.phase = 'published' $receipt.publication_since = $record.publication_since $receipt.initial_create = $record.initial_create diff --git a/docs/windows-time-profile-config.md b/docs/windows-time-profile-config.md index 8b3258a..8410fc5 100644 --- a/docs/windows-time-profile-config.md +++ b/docs/windows-time-profile-config.md @@ -535,3 +535,17 @@ SHA-256 der UTF-8-Texte ohne die Zeilenumbrüche der Konsolendarstellung: erwartet `d4726c7973c9b0cd8a66c1b129d1b5eb58d2bbfc1b103018e0a31a71fb1d9020`, gelesen `a0e1d856ed3bdbe884b23599f7c53d8a281d6409a42bbfa48649127b2aa22793`. Die erste Fehlerquittung enthielt keine FileID der leeren Zieldatei. + +Der Modus `-ResumeEmpty` prüft die bestehenden Fallbelege und öffnet das +leere Ziel exklusiv. Vor dem Schreiben protokolliert er dessen jetzt +festgestellte FileID. Dieselbe Kennung muss nach dem Schreiben und nach +der Freigabe der Leserechte wieder vorliegen. Beim DACL-Vergleich sind nur +die beiden für diesen Fall beschriebenen Formen zulässig. Der Starter +vergleicht die FileID zusätzlich mit der Quittung. Der Rückkanal überträgt +das Ergebnis und die passiven Zeitmessungen. + +Lokal bestanden acht Profiltests, die PowerShell-Parserprüfung, die +C#-Kompilierung, fünf AMD64-Strukturlayoutprüfungen und 20 Vergleiche +von Sicherheitsdeskriptoren. Acht lokale Fälle prüften die Auswahl des +Startmodus und das Verhalten bei vorhandenen Markern. Die Anwendung auf +dem Windowsgast und signierte Zeitmessungen beider Dienste stehen aus.