Skip to content

Commit 71d4297

Browse files
authored
Merge pull request #194 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 0966093 + 3786149 commit 71d4297

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Modules/CIPPCore/Public/Get-CIPPGeoIPLocation.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function Get-CIPPGeoIPLocation {
66

77
$CacheGeoIPTable = Get-CippTable -tablename 'cachegeoip'
88
$30DaysAgo = (Get-Date).AddDays(-30).ToString('yyyy-MM-ddTHH:mm:ssZ')
9-
$Filter = "RowKey eq '$IP' and Timestamp ge datetime'$30DaysAgo'"
9+
$Filter = "PartitionKey eq 'IP' and RowKey eq '$IP' and Timestamp ge datetime'$30DaysAgo'"
1010
$GeoIP = Get-CippAzDataTableEntity @CacheGeoIPTable -Filter $Filter
1111
if ($GeoIP) {
1212
return ($GeoIP.Data | ConvertFrom-Json)

Modules/CIPPCore/Public/Webhooks/Test-CIPPAuditLogRules.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,19 @@ function Test-CIPPAuditLogRules {
9898
$HasLocationData = $false
9999
if (![string]::IsNullOrEmpty($Data.clientip) -and $Data.clientip -notmatch '[X]+') {
100100
# Ignore IP addresses that have been redacted
101-
if ($Data.clientip -match '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$') {
102-
$Data.clientip = $Data.clientip -replace ':\d+$', '' # Remove the port number if present
103-
}
101+
102+
$IPRegex = '^(?<IP>(?:\d{1,3}(?:\.\d{1,3}){3}|\[[0-9a-fA-F:]+\]|[0-9a-fA-F:]+))(?::\d+)?$'
103+
$Data.clientip = $Data.clientip -replace $IPRegex, '$1' -replace '[\[\]]', ''
104+
104105
# Check if IP is on trusted IP list
105-
$TrustedIP = Get-CIPPAzDataTableEntity @TrustedIPTable -Filter "((PartitionKey eq '$TenantFilter') or (PartitionKey eq 'AllTenants')) and RowKey eq '$($Data.clientip)' and state eq 'Trusted'"
106+
$TrustedIP = Get-CIPPAzDataTableEntity @TrustedIPTable -Filter "((PartitionKey eq '$TenantFilter') or (PartitionKey eq 'AllTenants')) and RowKey eq '$($Data.clientip)' and state eq 'Trusted'"
106107
if ($TrustedIP) {
107108
#write-warning "IP $($Data.clientip) is trusted"
108109
$Trusted = $true
109110
}
110111
if (!$Trusted) {
111112
$CacheLookupStartTime = Get-Date
112-
$Location = Get-CIPPAzDataTableEntity @LocationTable -Filter "RowKey eq '$($Data.clientIp)'" | Select-Object -Last 1 -ExcludeProperty Tenant
113+
$Location = Get-AzDataTableEntity @LocationTable -Filter "PartitionKey eq 'ip' and RowKey eq '$($Data.clientIp)'" | Select-Object -ExcludeProperty Tenant
113114
$CacheLookupEndTime = Get-Date
114115
$CacheLookupSeconds = ($CacheLookupEndTime - $CacheLookupStartTime).TotalSeconds
115116
Write-Warning "Cache lookup for IP $($Data.clientip) took $CacheLookupSeconds seconds"

0 commit comments

Comments
 (0)