Skip to content

Commit b2972fc

Browse files
committed
update dnshealth
1 parent 0ff5451 commit b2972fc

File tree

19 files changed

+199
-177
lines changed

19 files changed

+199
-177
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Settings/Invoke-ExecCPVPermissions.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using namespace System.Net
22

3-
Function Invoke-ExecCPVPermissions {
3+
function Invoke-ExecCPVPermissions {
44
<#
55
.FUNCTIONALITY
66
Entrypoint
@@ -15,7 +15,7 @@ Function Invoke-ExecCPVPermissions {
1515
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
1616
$TenantFilter = $Request.Body.tenantFilter
1717

18-
$Tenant = Get-Tenants -IncludeAll | Where-Object -Property customerId -EQ $TenantFilter | Select-Object -First 1
18+
$Tenant = Get-Tenants -TenantFilter $TenantFilter -IncludeErrors
1919

2020
if ($Tenant) {
2121
Write-Host "Our tenant is $($Tenant.displayName) - $($Tenant.defaultDomainName)"

Modules/DNSHealth/1.0.7/MailProviders/Microsoft365.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

Modules/DNSHealth/1.0.7/DNSHealth.psd1 renamed to Modules/DNSHealth/1.1.0/DNSHealth.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'DNSHealth.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.7'
15+
ModuleVersion = '1.1.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

Modules/DNSHealth/1.0.7/DNSHealth.psm1 renamed to Modules/DNSHealth/1.1.0/DNSHealth.psm1

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ function Read-MXRecord {
11791179

11801180
catch { Write-Verbose $_.Exception.Message }
11811181
}
1182-
$ValidationPasses.Add('Mail exchanger record(s) are present for this domain.') | Out-Null
1182+
$ValidationPasses.Add('Mail exchanger records record(s) are present for this domain.') | Out-Null
11831183
$MXRecords = $MXRecords | Sort-Object -Property Priority
11841184

11851185
# Attempt to identify mail provider based on MX record
@@ -2073,9 +2073,11 @@ function Read-WhoisRecord {
20732073
$WhoisRegex = '^(?!(?:%|>>>|-+|#|[*]))[^\S\n]*(?<PropName>.+?):(?:[\r\n]+)?(:?(?!([0-9]|[/]{2}))[^\S\r\n]*(?<PropValue>.+))?$'
20742074

20752075
Write-Verbose "Querying WHOIS Server: $Server"
2076-
# TCP Client for Whois
2077-
$Client = New-Object System.Net.Sockets.TcpClient($Server, 43)
2076+
20782077
try {
2078+
# TCP Client for Whois
2079+
$Client = New-Object System.Net.Sockets.TcpClient($Server, 43)
2080+
20792081
# Open TCP connection and send query
20802082
$Stream = $Client.GetStream()
20812083
$ReferralServers = [System.Collections.Generic.List[string]]::new()
@@ -2159,16 +2161,18 @@ function Read-WhoisRecord {
21592161
$Results = $LastResult
21602162
}
21612163
}
2162-
}
2163-
2164-
else {
2164+
} else {
21652165
if ($Results._Raw -Match '(No match|Not Found|No Data)') {
21662166
$first, $newquery = ($Query -split '\.')
21672167
if (($newquery | Measure-Object).Count -gt 1) {
21682168
$Query = $newquery -join '.'
2169-
$Results = Read-WhoisRecord -Query $Query -Server $Server -Port $Port
2170-
foreach ($s in $Results._ReferralServers) {
2171-
$ReferralServers.Add($s) | Out-Null
2169+
try {
2170+
$Results = Read-WhoisRecord -Query $Query -Server $Server -Port $Port
2171+
foreach ($s in $Results._ReferralServers) {
2172+
$ReferralServers.Add($s) | Out-Null
2173+
}
2174+
} catch {
2175+
$Results = $LastResult
21722176
}
21732177
}
21742178
}
@@ -2185,17 +2189,17 @@ function Read-WhoisRecord {
21852189
$Stream.Dispose()
21862190
}
21872191
}
2188-
2189-
# Collect referral server list
2190-
$Results._ReferralServers = $ReferralServers
2191-
2192+
if ($ReferralServers) {
2193+
# Collect referral server list
2194+
$Results._ReferralServers = $ReferralServers
2195+
}
21922196
# Convert to json and back to preserve object order
21932197
$WhoisResults = $Results | ConvertTo-Json | ConvertFrom-Json
21942198

21952199
# Return Whois results as PSObject
21962200
$WhoisResults
21972201
}
2198-
#EndRegion './Public/Records/Read-WhoisRecord.ps1' 175
2202+
#EndRegion './Public/Records/Read-WhoisRecord.ps1' 179
21992203
#Region './Public/Resolver/Resolve-DnsHttpsQuery.ps1' -1
22002204

22012205
function Resolve-DnsHttpsQuery {
@@ -2221,7 +2225,7 @@ function Resolve-DnsHttpsQuery {
22212225
22222226
#>
22232227
[cmdletbinding()]
2224-
Param(
2228+
param(
22252229
[Parameter(Mandatory = $true)]
22262230
[string]$Domain,
22272231

@@ -2251,23 +2255,23 @@ function Resolve-DnsHttpsQuery {
22512255
$Uri = $QueryTemplate -f $BaseUri, $Domain, $RecordType
22522256

22532257
$x = 0
2258+
$Exception = $null
22542259
do {
22552260
$x++
22562261
try {
22572262
$Results = Invoke-RestMethod -Uri $Uri -Headers $Headers -ErrorAction Stop
2258-
}
2259-
2260-
catch {
2263+
} catch {
2264+
$Exception = $_
22612265
Start-Sleep -Milliseconds 300
22622266
}
22632267
}
22642268
while (-not $Results -and $x -le 3)
2265-
if (!$Results) { throw $_ }
2269+
if (!$Results) { throw 'Exception querying resolver {0}: {1}' -f $Resolver.Resolver, $Exception.Exception.Message }
22662270

22672271
if ($RecordType -eq 'txt' -and $Results.Answer) {
22682272
if ($Resolver -eq 'Cloudflare' -or $Resolver -eq 'Quad9') {
22692273
$Results.Answer | ForEach-Object {
2270-
$_.data = $_.data -replace '"' -replace '\s+', ' '
2274+
$_.data = $_.data -replace '" "' -replace '"', ''
22712275
}
22722276
}
22732277
$Results.Answer = $Results.Answer | Where-Object { $_.type -eq 16 }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Name": "Hornet Security",
3+
"MxMatch": "mx[0-9][0-9].hornetsecurity.com",
4+
"SpfInclude": "spf.hornetsecurity.com",
5+
"Selectors": [""],
6+
"_MxComment": "https://www.hornetsecurity.com/en/onboarding-information/",
7+
"_SpfComment": "https://www.hornetsecurity.com/en/onboarding-information/",
8+
"_DkimComment": "https://support.hornetsecurity.com/hc/en-us/articles/15123377800593-How-to-set-up-DKIM"
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Name": "Microsoft 365",
3+
"MxMatch": "mail.protection.outlook.com|mx.microsoft",
4+
"SpfInclude": "spf.protection.outlook.com",
5+
"Selectors": ["selector1", "selector2"],
6+
"MinimumSelectorPass": 1,
7+
"_MxComment": "https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider",
8+
"_SpfComment": "https://docs.microsoft.com/en-us/microsoft-365/admin/get-help-with-domains/create-dns-records-at-any-dns-hosting-provider",
9+
"_DkimComment": "https://docs.microsoft.com/en-us/microsoft-365/security/office-365-security/use-dkim-to-validate-outbound-email?view=o365-worldwide"
10+
}

0 commit comments

Comments
 (0)