Private/Write-TLManifest.ps1
|
function Write-TLManifest { <# .SYNOPSIS Writes manifest.json with SHA-256 integrity hashes for every snapshot file. #> [CmdletBinding()] param( [Parameter(Mandatory)] [string]$SnapshotPath, [Parameter(Mandatory)] [hashtable]$Metadata ) $files = @(Get-ChildItem -Path $SnapshotPath -Filter '*.json' -File | Where-Object { $_.Name -ne 'manifest.json' } | Sort-Object -Property Name) $fileEntries = @(foreach ($file in $files) { [ordered]@{ name = $file.Name sha256 = (Get-FileHash -Path $file.FullName -Algorithm SHA256).Hash.ToLowerInvariant() sizeBytes = [long]$file.Length } }) $manifest = [ordered]@{ tool = 'TenantLens' version = $script:TLVersion generatedUtc = [DateTime]::UtcNow.ToString('o') tenant = $Metadata['Tenant'] scopes = @($Metadata['Scopes']) areas = $Metadata['Areas'] redacted = [bool]$Metadata['Redacted'] files = $fileEntries } $manifestPath = Join-Path -Path $SnapshotPath -ChildPath 'manifest.json' Write-TLFile -Path $manifestPath -Content (ConvertTo-Json -InputObject $manifest -Depth 10) return $manifestPath } |