Skip to content

AI-Net-Guard v5.9.3

Choose a tag to compare

@github-actions github-actions released this 24 Nov 11:32
· 21 commits to main since this release

AI-Net-Guard v5.9.3 发布说明 (Release Notes)

维护修复版 (Maintenance Patch Release):在 v5.9.2 功能冻结基线之上,修复本机实机排查中确认的 2 项脚本维护缺陷与回归门禁盲区,保持单 EXE + 零常驻静态 WFP + 三公共库轻量架构不变,不新增功能与架构改动。


一、相较 v5.9.2 的修复内容

  1. 修复 Windows PowerShell 5.1 下 auto-disabled-outbound-allow.json 递归嵌套并实现自愈(lib-guard-common.ps1 / 07-mode.ps1 / 09-rollback.ps1 / 14-apply-policy.ps1)

    • 根因:此前 07-mode.ps1 使用 @(Get-Content ... | ConvertFrom-Json) 读取并写回隔离清单时,PowerShell 5.1 会把 JSON 数组当作单个元素包入外层数组并序列化为 { "value": [...], "Count": N } 嵌套包装对象,导致后续读取无法识别 .Name、重复写入同一规则,且在回滚或关闭 QuarantineRogueAllow 时无法重新启用被隔离规则。
    • 修复:在 lib-guard-common.ps1 新增单一收口函数 Read-GuardQuarantineList(递归展开嵌套数组与 { value, Count } 包装对象、过滤无效空项、按 Name 忽略大小写去重,并兼容 PowerShell 7 下 '[]' 空数组解析)与 Write-GuardQuarantineList(基于 ConvertTo-Json -InputObject [object[]] 与 UTF-8 无 BOM 原子落盘,0/1/多项均保证输出标准扁平 JSON 数组)。
    • 自愈与全入口接入:07-mode.ps1 每次运行均可通过 NeedsRewrite 自动将历史上已被 PS 5.1 写坏的 auto-disabled-outbound-allow.json 原地重写为干净扁平数组;09-rollback.ps1 与 14-apply-policy.ps1 同步改用 Read-GuardQuarantineList,确保历史嵌套规则也可被完整恢复。
  2. 修复 scripts\ 子目录直接运行时的默认 $Root 解析与回归 Check 7 缺失文件守卫(07-mode.ps1 / 12-regression.ps1 / 13-harden-acl.ps1 / 14-apply-policy.ps1)

    • 当不传 -Root 直接执行 C:\AI-Net-Guard\scripts\12-regression.ps1 等位于 scripts\ 子目录下的入口脚本时,默认 $Root 过去误取为 C:\AI-Net-Guard\scripts,导致找不到 cn-ipv4.txt 并在 scripts\ 下生成多余 backup\ / logs\ 子目录。现统一检测若 $PSScriptRoot 末级目录为 scripts,则自动回退到上一级安装根目录。
    • 12-regression.ps1 第 7 项(corrupt geoip rejected without altering CN allowlist)新增 cn-ipv4.txt 存在性及最小行数(>= 1000)断言,防止路径错误时以 before=0, after=0 静默误判 PASS。

二、验证范围与未验证事项

  • 已执行并通过(非提权工作区 + 双引擎测试):
    • 全仓 .ps1 脚本 100% 纯 ASCII、0 AST 解析错误;
    • tests\test-stun-ports.ps1(Windows PowerShell 5.1):58/58 条断言 PASS(含 PS 5.1 嵌套 { value, Count } 恢复、去重与 0/1/2/3 项扁平往返实测);
    • PowerShell 7(pwsh)下 Read/Write-GuardQuarantineList 0/1/2/3 项及畸形嵌套自愈直测通过;
    • gui\build.ps1 -RunSmokeTest:WPF Release 0 警告 0 错误,8 项 UI 冒烟 PASS。
  • 尚未由本会话直接修改/执行(因非提权会话无法写入受 ACL 保护的 C:\AI-Net-Guard 及卸载 SYSTEM 计划任务):
    • 需在 管理员 PowerShell 中运行下方同步与清理命令,将 C:\AI-Net-Guard\scripts\ 更新至 v5.9.3、清除残留的 AI-Guard-Test-Rollback 任务与根目录旧 07-mode.ps1、自愈 backup\auto-disabled-outbound-allow.json 并运行提权回归 12-regression.ps1。

三、同步本机生产目录、清理历史残留并验收(管理员 PowerShell 执行)

在 管理员 PowerShell 中执行以下一行命令完成同步、清理、自愈与验收:

$ws = "C:\path\to\AI-Net-Guard"; $root = "C:\AI-Net-Guard"; Unregister-ScheduledTask -TaskName "AI-Guard-Test-Rollback" -Confirm:$false -ErrorAction SilentlyContinue; Remove-Item "$root\07-mode.ps1", "$root\scripts\backup", "$root\scripts\logs" -Recurse -Force -ErrorAction SilentlyContinue; powershell -ExecutionPolicy Bypass -File "$ws\scripts\13-harden-acl.ps1" -Root $root -SyncWorkspace -WorkspaceRoot $ws -SkipVerification; & "$root\scripts\07-mode.ps1"; Get-Content "$root\backup\auto-disabled-outbound-allow.json"; Get-ScheduledTask -TaskName "AI-Guard*" | Select-Object TaskName, State; & "$root\scripts\12-regression.ps1"