diff --git a/scripts/verify-n14-uia-selector-report.ps1 b/scripts/verify-n14-uia-selector-report.ps1 new file mode 100644 index 0000000..a5d102f --- /dev/null +++ b/scripts/verify-n14-uia-selector-report.ps1 @@ -0,0 +1,79 @@ +$ErrorActionPreference = "Stop" +Set-StrictMode -Version Latest + +$repo = (Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")).Path +Set-Location -LiteralPath $repo + +if (-not (Get-Command go -ErrorAction SilentlyContinue)) { + throw "go was not found. Run this verifier in a Go 1.23.x environment." +} + +Write-Host "## go test ./internal/uiaselector ./cmd/uia-selector-report" +go test ./internal/uiaselector ./cmd/uia-selector-report -count=1 +if ($LASTEXITCODE -ne 0) { + throw "go tests failed with exit code $LASTEXITCODE" +} + +$outDir = Join-Path $repo "runs\n14-selector-report" +New-Item -ItemType Directory -Force -Path $outDir | Out-Null +$jsonPath = Join-Path $outDir "n12r-selector-report.json" +$mdPath = Join-Path $outDir "n12r-selector-report.md" + +Write-Host "## go run ./cmd/uia-selector-report" +go run ./cmd/uia-selector-report ` + -dump internal/uiaselector/testdata/n12r-2026-07-09-uia-redacted.json ` + -out-json $jsonPath ` + -out-md $mdPath ` + -strict +if ($LASTEXITCODE -ne 0) { + throw "uia-selector-report failed with exit code $LASTEXITCODE" +} + +if (-not (Test-Path -LiteralPath $jsonPath)) { + throw "JSON report was not created: $jsonPath" +} +if (-not (Test-Path -LiteralPath $mdPath)) { + throw "Markdown report was not created: $mdPath" +} + +$report = Get-Content -LiteralPath $jsonPath -Raw -Encoding UTF8 | ConvertFrom-Json +if (-not $report.ok) { + throw "report ok=false" +} +if ($report.catalog_size -ne 10) { + throw "catalog_size=$($report.catalog_size), want 10" +} +if ($report.matched_count -ne 10) { + throw "matched_count=$($report.matched_count), want 10" +} +if ($report.unmatched_count -ne 0) { + throw "unmatched_count=$($report.unmatched_count), want 0" +} +if ($report.ambiguous_count -ne 0) { + throw "ambiguous_count=$($report.ambiguous_count), want 0" +} + +Write-Host "## output safety scan" +$jsonRaw = Get-Content -LiteralPath $jsonPath -Raw -Encoding UTF8 +$mdRaw = Get-Content -LiteralPath $mdPath -Raw -Encoding UTF8 +$forbiddenOutput = @( + '\"name\"', + '\"value\"', + '国网甘肃省电力公司', + 'send_after_approval', + 'send_file_after_approval', + 'receive_file_after_approval', + 'open_conversation', + 'InvokePattern', + 'ValuePattern.SetValue' +) +foreach ($term in $forbiddenOutput) { + if ($jsonRaw.Contains($term)) { + throw "JSON report contains forbidden term: $term" + } + if ($mdRaw.Contains($term)) { + throw "Markdown report contains forbidden term: $term" + } +} + +Write-Host "N14 UIA selector report verification passed."