Skip to content

Commit ed0770e

Browse files
authored
Fixes Ifw writing passwords to EventLog for failed command execution (#774)
Fixes EventLog error handling by no longer parsing command arguments to ensure passwords are not stored on the EventLog, unless the debug mode of Icinga for Windows is enable
1 parent 336b38d commit ed0770e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1111

1212
### Bugfixes
1313

14+
* [#754](https://github.com/Icinga/icinga-powershell-framework/issues/754) Fixes EventLog error handling by no longer parsing command arguments to ensure passwords are not stored on the EventLog, unless the debug mode of Icinga for Windows is enable
1415
* [#759](https://github.com/Icinga/icinga-powershell-framework/pull/759) Fixes maximum cache duration for service daemons to the right value
1516
* [#773](https://github.com/Icinga/icinga-powershell-framework/pull/773) Fixes REST-Api invoke command `Invoke-IcingaForWindowsRESTApi` by removing CA certificate check
1617

lib/core/framework/Invoke-IcingaInternalServiceCall.psm1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ function Invoke-IcingaInternalServiceCall()
6161
Set-IcingaTLSVersion;
6262
Enable-IcingaUntrustedCertificateValidation -SuppressMessages;
6363

64+
# For security reasons, we will not log the arguments in case of an error, only in debug mode
65+
$ErrorArguments = '';
66+
if ($Global:Icinga.Protected.DebugMode) {
67+
$ErrorArguments = $Arguments;
68+
}
69+
6470
# Now queue the check inside our REST-Api
6571
try {
6672
$ApiResult = Invoke-WebRequest -Method POST -UseBasicParsing -Uri ([string]::Format('https://localhost:{0}/v1/checker?command={1}', $RestApiPort, $Command)) -Body (ConvertTo-JsonUTF8Bytes -InputObject $Arguments -Depth 100 -Compress) -ContentType 'application/json' -TimeoutSec $Timeout;
6773
} catch {
6874
# Fallback to execute plugin locally
69-
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -ExceptionObject $_ -Objects $Command, $Arguments;
75+
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -ExceptionObject $_ -Objects $Command, $ErrorArguments;
7076
return $NULL;
7177
}
7278

@@ -76,12 +82,12 @@ function Invoke-IcingaInternalServiceCall()
7682

7783
# In case we didn't receive a check result, fallback to local execution
7884
if ([string]::IsNullOrEmpty($IcingaResult.$Command.checkresult)) {
79-
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $Arguments;
85+
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $ErrorArguments;
8086
return $NULL;
8187
}
8288

8389
if ([string]::IsNullOrEmpty($IcingaResult.$Command.exitcode)) {
84-
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $Arguments;
90+
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $ErrorArguments;
8591
return $NULL;
8692
}
8793

0 commit comments

Comments
 (0)