From 44700e4bd20ea683156339bf1fd75560d42fb3e3 Mon Sep 17 00:00:00 2001 From: Fabian Thomys Date: Tue, 16 Sep 2025 13:50:22 +0200 Subject: [PATCH] fix(lib/core): Allow Cache-Key deletion with NULL --- doc/100-General/10-Changelog.md | 1 + lib/core/cache/Set-IcingaCacheData.psm1 | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 73a4ede..c367780 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#814](https://github.com/Icinga/icinga-powershell-framework/pull/814) Fixes random chars function to truly generate unpredictable character sequences and to replace `Get-Random` which is not entirely secure * [#815](https://github.com/Icinga/icinga-powershell-framework/pull/815) Fixes a possible crash for `Test-IcingaAddTypeExist`, causing the Icinga for Windows installation to fail when third party components are checked which are malfunctioning +* [#829](https://github.com/Icinga/icinga-powershell-framework/pull/829) Fixes `Set-IcingaCacheData` to properly remove cache files in case `$null` is passed as value ## 1.13.3 (2025-05-08) diff --git a/lib/core/cache/Set-IcingaCacheData.psm1 b/lib/core/cache/Set-IcingaCacheData.psm1 index cb0f0c8..419f5f0 100644 --- a/lib/core/cache/Set-IcingaCacheData.psm1 +++ b/lib/core/cache/Set-IcingaCacheData.psm1 @@ -38,6 +38,16 @@ function Set-IcingaCacheData() $CacheTmpFile = [string]::Format('{0}.tmp', $CacheFile); $cacheData = @{ }; + if ($null -eq $Value) { + if (Test-Path $CacheTmpFile) { + Remove-ItemSecure -Path $CacheTmpFile -Retries 5 -Force | Out-Null; + } + if (Test-Path $CacheFile) { + Remove-ItemSecure -Path $CacheFile -Retries 5 -Force | Out-Null; + } + return; + } + if ((Test-IcingaCacheDataTempFile -Space $Space -CacheStore $CacheStore -KeyName $KeyName)) { Copy-IcingaCacheTempFile -CacheFile $CacheFile -CacheTmpFile $CacheTmpFile; }