77 lines
2.5 KiB
PowerShell
77 lines
2.5 KiB
PowerShell
param(
|
|
[string]$PackageDir = "runs/live-probe-recorder-package"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
|
$packagePath = Join-Path $repo $PackageDir
|
|
$verifyRoot = Join-Path $repo "runs/live-probe-recorder-verify-output"
|
|
|
|
if (-not (Test-Path -LiteralPath $packagePath)) {
|
|
throw "package directory not found: $packagePath"
|
|
}
|
|
|
|
$executables = @(
|
|
Join-Path $packagePath "ISphereLiveProbeRecorder.exe"
|
|
Join-Path $packagePath "variants\ISphereLiveProbeRecorder-x86.exe"
|
|
Join-Path $packagePath "variants\ISphereLiveProbeRecorder-anycpu.exe"
|
|
Join-Path $packagePath "variants\ISphereLiveProbeRecorder-x64.exe"
|
|
)
|
|
|
|
$results = @()
|
|
foreach ($exe in $executables) {
|
|
if (-not (Test-Path -LiteralPath $exe)) {
|
|
throw "recorder executable missing: $exe"
|
|
}
|
|
|
|
$variantName = [System.IO.Path]::GetFileNameWithoutExtension($exe)
|
|
$safeVariantName = $variantName -replace '[^A-Za-z0-9_.-]', '_'
|
|
$probeRoot = Join-Path $verifyRoot $safeVariantName
|
|
if (Test-Path -LiteralPath $probeRoot) {
|
|
Remove-Item -LiteralPath $probeRoot -Recurse -Force
|
|
}
|
|
New-Item -ItemType Directory -Force -Path $probeRoot | Out-Null
|
|
|
|
$output = & $exe --out $probeRoot --no-pause 2>&1
|
|
$exit = $LASTEXITCODE
|
|
if ($exit -ne 0) {
|
|
throw "recorder failed: $exe exit=$exit output=$($output -join "`n")"
|
|
}
|
|
|
|
$created = Get-ChildItem -LiteralPath $probeRoot -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1 -ExpandProperty FullName
|
|
if (-not $created) {
|
|
throw "recorder did not create a probe output directory: $exe"
|
|
}
|
|
|
|
foreach ($required in @(
|
|
"manifest.json",
|
|
"probe_client_runtime.json",
|
|
"process_details.json",
|
|
"network_inventory.json",
|
|
"filesystem_inventory.json",
|
|
"scan_windows.json",
|
|
"feasibility_summary.json"
|
|
)) {
|
|
$path = Join-Path $created $required
|
|
if (-not (Test-Path -LiteralPath $path)) {
|
|
throw "required output missing for ${exe}: $required"
|
|
}
|
|
}
|
|
|
|
$results += [ordered]@{
|
|
exe = (Resolve-Path -LiteralPath $exe).Path
|
|
sha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath $exe).Hash
|
|
length = (Get-Item -LiteralPath $exe).Length
|
|
output_dir = $created
|
|
ok = $true
|
|
}
|
|
}
|
|
|
|
[ordered]@{
|
|
ok = $true
|
|
package_dir = (Resolve-Path -LiteralPath $packagePath).Path
|
|
verify_output_dir = (Resolve-Path -LiteralPath $verifyRoot).Path
|
|
results = $results
|
|
} | ConvertTo-Json -Depth 6 -Compress
|