Skip to content

Commit 4b39166

Browse files
authored
Merge pull request #1147 from JohnDuprey/dev
Bugfixes
2 parents abf80f4 + 482c185 commit 4b39166

File tree

9 files changed

+450
-116
lines changed

9 files changed

+450
-116
lines changed

Config/standards.json

Lines changed: 315 additions & 35 deletions
Large diffs are not rendered by default.

Modules/CIPPCore/Public/AuditLogs/Get-CippAuditLogSearches.ps1

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,26 @@ function Get-CippAuditLogSearches {
1313
[Parameter()]
1414
[switch]$ReadyToProcess
1515
)
16-
$Queries = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/security/auditLog/queries' -AsApp $true -tenantid $TenantFilter
16+
1717
if ($ReadyToProcess.IsPresent) {
1818
$AuditLogSearchesTable = Get-CippTable -TableName 'AuditLogSearches'
1919
$PendingQueries = Get-CIPPAzDataTableEntity @AuditLogSearchesTable -Filter "Tenant eq '$TenantFilter' and CippStatus eq 'Pending'"
20+
21+
$BulkRequests = foreach ($PendingQuery in $PendingQueries) {
22+
@{
23+
id = $PendingQuery.RowKey
24+
url = 'security/auditLog/queries/' + $PendingQuery.RowKey
25+
method = 'GET'
26+
}
27+
}
28+
if ($BulkRequests.Count -eq 0) {
29+
return @()
30+
}
31+
$Queries = New-GraphBulkRequest -Requests @($BulkRequests) -AsApp $true -TenantId $TenantFilter | Select-Object -ExpandProperty body
32+
2033
$Queries = $Queries | Where-Object { $PendingQueries.RowKey -contains $_.id -and $_.status -eq 'succeeded' }
34+
} else {
35+
$Queries = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/security/auditLog/queries' -AsApp $true -tenantid $TenantFilter
2136
}
2237
return $Queries
2338
}

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Webhooks/Push-AuditLogTenant.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function Push-AuditLogTenant {
3636
$Configuration = $ConfigEntries | Where-Object { ($_.Tenants -match $TenantFilter -or $_.Tenants -match 'AllTenants') }
3737
if ($Configuration) {
3838
try {
39-
$LogSearches = Get-CippAuditLogSearches -TenantFilter $TenantFilter -ReadyToProcess
39+
$LogSearches = Get-CippAuditLogSearches -TenantFilter $TenantFilter -ReadyToProcess | Select-Object -First 20
4040
Write-Information ('Audit Logs: Found {0} searches, begin processing' -f $LogSearches.Count)
4141
foreach ($Search in $LogSearches) {
4242
$SearchEntity = Get-CIPPAzDataTableEntity @LogSearchesTable -Filter "Tenant eq '$($TenantFilter)' and RowKey eq '$($Search.id)'"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Extensions/Invoke-ExecExtensionsConfig.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,20 @@ Function Invoke-ExecExtensionsConfig {
3131

3232
# Check if NinjaOne URL is set correctly and the instance has at least version 5.6
3333
if ($Body.NinjaOne) {
34+
$AllowedNinjaHostnames = @(
35+
'app.ninjarmmm.com',
36+
'eu.ninjarmmm.com',
37+
'oc.ninjarmmm.com',
38+
'ca.ninjarmmm.com',
39+
'us2.ninjarmm.com'
40+
)
41+
$SetNinjaHostname = $Body.NinjaOne.Instance -replace '/ws', '' -replace 'https://', ''
42+
if ($AllowedNinjaHostnames -notcontains $SetNinjaHostname) {
43+
throw "NinjaOne URL is not allowed. Allowed hostnames are: $($AllowedNinjaHostnames -join ', ')"
44+
}
45+
3446
try {
35-
[version]$Version = (Invoke-WebRequest -Method GET -Uri "https://$(($Body.NinjaOne.Instance -replace '/ws','') -replace 'https://','')/app-version.txt" -ea stop).content
47+
[version]$Version = (Invoke-WebRequest -Method GET -Uri "$SetNinjaHostname/app-version.txt" -ea stop).content
3648
} catch {
3749
throw "Failed to connect to NinjaOne check your Instance is set correctly eg 'app.ninjarmmm.com'"
3850
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tenant/Standards/Invoke-ListBPA.ps1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ Function Invoke-ListBPA {
4040
$row = $_
4141
$JSONFields | ForEach-Object {
4242
$jsonContent = $row.$_
43-
if ($jsonContent -ne $null -and $jsonContent -ne 'FAILED') {
44-
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15
43+
if (![string]::IsNullOrEmpty($jsonContent) -and $jsonContent -ne 'FAILED') {
44+
try {
45+
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15
46+
} catch {
47+
}
4548
}
4649
}
4750
$row.PSObject.Properties | ForEach-Object {
@@ -61,8 +64,11 @@ Function Invoke-ListBPA {
6164
$row = $_
6265
$JSONFields | ForEach-Object {
6366
$jsonContent = $row.$_
64-
if ($jsonContent -ne $null -and $jsonContent -ne 'FAILED') {
65-
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15
67+
if (![string]::IsNullOrEmpty($jsonContent) -and $jsonContent -ne 'FAILED') {
68+
try {
69+
$row.$_ = $jsonContent | ConvertFrom-Json -Depth 15
70+
} catch {
71+
}
6672
}
6773
}
6874
$row | Where-Object -Property PartitionKey -In $Tenants.customerId

Modules/CIPPCore/Public/GraphRequests/Get-GraphRequestList.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ function Get-GraphRequestList {
9696
$Count = 0
9797
if ($TenantFilter -ne 'AllTenants') {
9898
$GraphRequest = @{
99-
uri = $GraphQuery.ToString()
100-
tenantid = $TenantFilter
101-
}
102-
if ($Parameters.'$filter') {
103-
$GraphRequest.ComplexFilter = $true
99+
uri = $GraphQuery.ToString()
100+
tenantid = $TenantFilter
101+
ComplexFilter = $true
104102
}
105103
if ($NoPagination.IsPresent) {
106104
$GraphRequest.noPagination = $NoPagination.IsPresent

Modules/CIPPCore/Public/Set-CIPPAssignedPolicy.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function Set-CIPPAssignedPolicy {
4848
}
4949
default {
5050
$GroupNames = $GroupName.Split(',')
51-
$GroupIds = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/groups' -tenantid $TenantFilter | ForEach-Object {
51+
$GroupIds = New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/groups?$select=id,displayName&$top=999' -tenantid $TenantFilter | ForEach-Object {
5252
$Group = $_
5353
foreach ($SingleName in $GroupNames) {
54-
if ($_.displayname -like $SingleName) {
54+
if ($_.displayName -like $SingleName) {
5555
$group.id
5656
}
5757
}

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardPerUserMFA.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,14 @@ function Invoke-CIPPStandardPerUserMFA {
3939
url = "/users/$id/authentication/requirements"
4040
}
4141
}
42-
$UsersWithoutMFA = (New-GraphBulkRequest -tenantid $tenant -Requests @($Requests) -asapp $true).body | Where-Object { $_.perUserMfaState -ne 'enforced' } | Select-Object peruserMFAState, @{Name = 'userPrincipalName'; Expression = { [System.Web.HttpUtility]::UrlDecode($_.'@odata.context'.split("'")[1]) } }
42+
if ($Requests) {
43+
$UsersWithoutMFA = (New-GraphBulkRequest -tenantid $tenant -Requests @($Requests) -asapp $true).body | Where-Object { $_.perUserMfaState -ne 'enforced' } | Select-Object peruserMFAState, @{Name = 'userPrincipalName'; Expression = { [System.Web.HttpUtility]::UrlDecode($_.'@odata.context'.split("'")[1]) } }
44+
} else {
45+
$UsersWithoutMFA = @()
46+
}
4347

4448
If ($Settings.remediate -eq $true) {
45-
if (($UsersWithoutMFA.userPrincipalName | Measure-Object).Count -gt 0) {
49+
if (($UsersWithoutMFA | Measure-Object).Count -gt 0) {
4650
try {
4751
$MFAMessage = Set-CIPPPerUserMFA -TenantFilter $Tenant -userId @($UsersWithoutMFA.userPrincipalName) -State 'enforced'
4852
Write-LogMessage -API 'Standards' -tenant $tenant -message $MFAMessage -sev Info

0 commit comments

Comments
 (0)