tools: open real offline frmP2PChat window
This commit is contained in:
58
scripts/test-extract-frmP2PChat-il-risk.ps1
Normal file
58
scripts/test-extract-frmP2PChat-il-risk.ps1
Normal file
@@ -0,0 +1,58 @@
|
||||
param(
|
||||
[string]$ScriptPath = "scripts/extract-frmP2PChat-il-risk.ps1",
|
||||
[string]$OutDir = "runs/offline-chat-window/il-risk-contract"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repo = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
|
||||
$target = if ([System.IO.Path]::IsPathRooted($ScriptPath)) {
|
||||
$ScriptPath
|
||||
}
|
||||
else {
|
||||
Join-Path $repo $ScriptPath
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $target)) {
|
||||
throw "script not found: $target"
|
||||
}
|
||||
|
||||
$outFull = if ([System.IO.Path]::IsPathRooted($OutDir)) {
|
||||
$OutDir
|
||||
}
|
||||
else {
|
||||
Join-Path $repo $OutDir
|
||||
}
|
||||
if (Test-Path -LiteralPath $outFull) {
|
||||
Remove-Item -LiteralPath $outFull -Recurse -Force
|
||||
}
|
||||
|
||||
$raw = & powershell -NoProfile -ExecutionPolicy Bypass -File $target -OutDir $OutDir
|
||||
$result = $raw | ConvertFrom-Json
|
||||
|
||||
if (-not $result.ok) {
|
||||
throw "extract script returned ok=false"
|
||||
}
|
||||
foreach ($path in @($result.ctor_il_file, $result.risk_csv_file, $result.risk_md_file)) {
|
||||
if (-not (Test-Path -LiteralPath $path)) {
|
||||
throw "expected output missing: $path"
|
||||
}
|
||||
}
|
||||
if ($result.ctor_line_count -lt 500) {
|
||||
throw "ctor IL line count too small: $($result.ctor_line_count)"
|
||||
}
|
||||
if ($result.risk_count -lt 50) {
|
||||
throw "risk count too small: $($result.risk_count)"
|
||||
}
|
||||
$riskText = Get-Content -LiteralPath $result.risk_csv_file -Raw
|
||||
foreach ($required in @("IL_00f6", "add_OnConnectError", "P2PChat::get_OtherJid", "IMPPManager::get_UserInfo")) {
|
||||
if ($riskText -notmatch [regex]::Escape($required)) {
|
||||
throw "risk csv missing evidence: $required"
|
||||
}
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
ok = $true
|
||||
checked = 4
|
||||
ctor_line_count = $result.ctor_line_count
|
||||
risk_count = $result.risk_count
|
||||
} | ConvertTo-Json -Compress
|
||||
Reference in New Issue
Block a user