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:
+1
-1
@@ -82,7 +82,7 @@ $script:MonitorStopRequested = $false
|
|||||||
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
||||||
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
||||||
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
||||||
$ScriptVersion = "2.0.0-SAC"
|
$ScriptVersion = "2.0.1-SAC"
|
||||||
|
|
||||||
# Логи (все под InstallRoot)
|
# Логи (все под InstallRoot)
|
||||||
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ PowerShell-набор для мониторинга входов в Windows с
|
|||||||
- Документация по развёртыванию: **[Docs/README.md](Docs/README.md)** (RDP-монитор, Exchange, NETLOGON).
|
- Документация по развёртыванию: **[Docs/README.md](Docs/README.md)** (RDP-монитор, Exchange, NETLOGON).
|
||||||
- **`Encrypt-DpapiForRdpMonitor.ps1`** — опционально для подготовки DPAPI-строк токена/chat id и пароля SMTP (`$MailSmtpPasswordProtectedB64` в файле настроек).
|
- **`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).
|
- **Локальные настройки 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
@@ -170,9 +170,32 @@ function Get-SacOccurredAtIso {
|
|||||||
function Convert-AnyToJsonSerializable {
|
function Convert-AnyToJsonSerializable {
|
||||||
param($Value)
|
param($Value)
|
||||||
if ($null -eq $Value) { return $null }
|
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
|
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]) {
|
if ($Value -is [hashtable] -or $Value -is [System.Collections.IDictionary]) {
|
||||||
$out = @{}
|
$out = @{}
|
||||||
foreach ($key in $Value.Keys) {
|
foreach ($key in $Value.Keys) {
|
||||||
@@ -181,11 +204,11 @@ function Convert-AnyToJsonSerializable {
|
|||||||
return $out
|
return $out
|
||||||
}
|
}
|
||||||
if ($Value -is [System.Collections.IEnumerable]) {
|
if ($Value -is [System.Collections.IEnumerable]) {
|
||||||
$list = New-Object System.Collections.Generic.List[object]
|
return ,@(
|
||||||
foreach ($item in $Value) {
|
foreach ($item in $Value) {
|
||||||
$list.Add((Convert-AnyToJsonSerializable $item)) | Out-Null
|
Convert-AnyToJsonSerializable $item
|
||||||
}
|
}
|
||||||
return $list
|
)
|
||||||
}
|
}
|
||||||
return [string]$Value
|
return [string]$Value
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
2.0.0-SAC
|
2.0.1-SAC
|
||||||
|
|||||||
Reference in New Issue
Block a user