From 467f366c7ca5ec0ecf8703188bbf16eb9b2b2d6e Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Tue, 24 Mar 2020 20:14:06 +0100 Subject: [PATCH] Adds function to securely read header values from our requests --- lib/web/Get-IcingaRESTHeaderValue.psm1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/web/Get-IcingaRESTHeaderValue.psm1 diff --git a/lib/web/Get-IcingaRESTHeaderValue.psm1 b/lib/web/Get-IcingaRESTHeaderValue.psm1 new file mode 100644 index 0000000..4eb9caa --- /dev/null +++ b/lib/web/Get-IcingaRESTHeaderValue.psm1 @@ -0,0 +1,17 @@ +function Get-IcingaRESTHeaderValue() +{ + param( + [hashtable]$Request = @{}, + [string]$Header = $null + ); + + if ($null -eq $Request -or [string]::IsNullOrEmpty($Header) -Or $Request.Count -eq 0) { + return $null; + } + + if ($Request.Header.ContainsKey($Header) -eq $FALSE) { + return $null + } + + return $Request.Header[$Header]; +}