fix: SAC JSON serialize daily report without PSMethod cycle 2.0.1-SAC

Convert-AnyToJsonSerializable returns plain arrays and skips PSMethod/ScriptBlock instead of Generic.List objects that broke JavaScriptSerializer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-01 09:08:14 +10:00
parent 1a1467f910
commit 084494cfa8
4 changed files with 32 additions and 9 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ $script:MonitorStopRequested = $false
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
$ScriptVersion = "2.0.0-SAC"
$ScriptVersion = "2.0.1-SAC"
# Логи (все под InstallRoot)
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
+1 -1
View File
@@ -13,7 +13,7 @@ PowerShell-набор для мониторинга входов в Windows с
- Документация по развёртыванию: **[Docs/README.md](Docs/README.md)** (RDP-монитор, Exchange, NETLOGON).
- **`Encrypt-DpapiForRdpMonitor.ps1`** — опционально для подготовки DPAPI-строк токена/chat id и пароля SMTP (`$MailSmtpPasswordProtectedB64` в файле настроек).
- **Локальные настройки RDP-монитора:** **`login_monitor.settings.ps1`** в каталоге установки (образец **`login_monitor.settings.example.ps1`**). При автообновлении **`Login_Monitor.ps1`** с шары файл настроек **не перезаписывается** (как **`exchange_monitor.settings.ps1`** для Exchange).
- **Security Alert Center (SAC):** модуль **`Sac-Client.ps1`** (копируется вместе с `Login_Monitor.ps1`). Режимы **`$UseSAC`**: `off` | `exclusive` | `dual` | `fallback` — контракт в репозитории **security-alert-center** (`docs/agent-integration.md`). Версия релиза: **`$ScriptVersion`** и **`version.txt`** (сейчас **2.0.0-SAC**); **`Sac-Client.ps1`** передаёт ту же версию в SAC (`product_version`).
- **Security Alert Center (SAC):** модуль **`Sac-Client.ps1`** (копируется вместе с `Login_Monitor.ps1`). Режимы **`$UseSAC`**: `off` | `exclusive` | `dual` | `fallback` — контракт в репозитории **security-alert-center** (`docs/agent-integration.md`). Версия релиза: **`$ScriptVersion`** и **`version.txt`** (сейчас **2.0.1-SAC**); **`Sac-Client.ps1`** передаёт ту же версию в SAC (`product_version`).
## Что изменилось (важное)
+29 -6
View File
@@ -170,9 +170,32 @@ function Get-SacOccurredAtIso {
function Convert-AnyToJsonSerializable {
param($Value)
if ($null -eq $Value) { return $null }
if ($Value -is [string] -or $Value -is [bool] -or $Value -is [int] -or $Value -is [long] -or $Value -is [double] -or $Value -is [decimal]) {
if ($Value -is [string] -or $Value -is [bool] -or $Value -is [char]) {
return $Value
}
if ($Value -is [byte] -or $Value -is [sbyte] -or $Value -is [int16] -or $Value -is [uint16] -or
$Value -is [int] -or $Value -is [uint] -or $Value -is [long] -or $Value -is [ulong] -or
$Value -is [float] -or $Value -is [double] -or $Value -is [decimal]) {
return $Value
}
if ($Value -is [datetime] -or $Value -is [datetimeoffset] -or $Value -is [guid]) {
return [string]$Value
}
if ($Value -is [System.Management.Automation.PSMethod] -or
$Value -is [System.Management.Automation.ScriptBlock] -or
$Value -is [Delegate]) {
return $null
}
if ($Value -is [pscustomobject]) {
$out = @{}
foreach ($prop in $Value.PSObject.Properties) {
if ($prop.MemberType -notin @('NoteProperty', 'Property', 'AliasProperty', 'CodeProperty', 'ScriptProperty')) {
continue
}
$out[$prop.Name] = Convert-AnyToJsonSerializable $prop.Value
}
return $out
}
if ($Value -is [hashtable] -or $Value -is [System.Collections.IDictionary]) {
$out = @{}
foreach ($key in $Value.Keys) {
@@ -181,11 +204,11 @@ function Convert-AnyToJsonSerializable {
return $out
}
if ($Value -is [System.Collections.IEnumerable]) {
$list = New-Object System.Collections.Generic.List[object]
foreach ($item in $Value) {
$list.Add((Convert-AnyToJsonSerializable $item)) | Out-Null
}
return $list
return ,@(
foreach ($item in $Value) {
Convert-AnyToJsonSerializable $item
}
)
}
return [string]$Value
}
+1 -1
View File
@@ -1 +1 @@
2.0.0-SAC
2.0.1-SAC