Skip to content

Commit 6871d26

Browse files
authored
Dev to hotfix (KelvinTegelaar#2047)
2 parents bd676d3 + e99b4aa commit 6871d26

439 files changed

Lines changed: 11024 additions & 641 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/PR_Branch_Check.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,46 @@ permissions:
1616

1717
jobs:
1818
check-branch:
19-
runs-on: ubuntu-latest
19+
runs-on: ubuntu-slim
2020
steps:
2121
- name: Check and Comment on PR
2222
# Only process fork PRs with specific branch conditions
2323
# Must be a fork AND (source is main/master OR target is main/master)
2424
if: |
25-
github.event.pull_request.head.repo.fork == true &&
25+
github.event.pull_request.head.repo.fork == true &&
2626
((github.event.pull_request.head.ref == 'main' || github.event.pull_request.head.ref == 'master') ||
2727
(github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'master'))
28-
uses: actions/github-script@v7
28+
uses: actions/github-script@v9
2929
with:
3030
github-token: ${{ secrets.GITHUB_TOKEN }}
3131
script: |
3232
let message = '';
3333
34-
message += '🔄 If you are attempting to update your CIPP repo please follow the instructions at: https://docs.cipp.app/setup/self-hosting-guide/updating ';
34+
// Check if the fork has open PRs (indicates pull bot or similar is active)
35+
const forkOwner = context.payload.pull_request.head.repo.owner.login;
36+
const forkRepo = context.payload.pull_request.head.repo.name;
37+
const forkPullsUrl = context.payload.pull_request.head.repo.html_url + '/pulls';
38+
39+
let openPRs = [];
40+
try {
41+
const { data: prs } = await github.rest.pulls.list({
42+
owner: forkOwner,
43+
repo: forkRepo,
44+
state: 'open',
45+
per_page: 5
46+
});
47+
openPRs = prs;
48+
} catch (e) {
49+
// Can't read fork PRs — skip
50+
}
51+
52+
message += '🔄 If you are attempting to update your CIPP-API repo please follow the instructions at: https://docs.cipp.app/setup/self-hosting-guide/updating. Are you a sponsor? Contact the helpdesk for direct assistance with updating to the latest version.';
53+
54+
if (openPRs.length > 0) {
55+
message += ` It looks like you may already have a pending update PR on your fork — check your [open pull requests](${forkPullsUrl}) to accept it.`;
56+
} else {
57+
message += ` You can enable [Pull Bot](https://github.com/apps/pull) or [Repo Sync](https://github.com/apps/repo-sync) to automatically keep your fork up to date.`;
58+
}
3559
message += '\n\n';
3660
3761
// Check if PR is targeting main/master
@@ -40,20 +64,20 @@ jobs:
4064
}
4165
4266
// Check if PR is from a fork's main/master branch
43-
if (context.payload.pull_request.head.repo.fork &&
67+
if (context.payload.pull_request.head.repo.fork &&
4468
(context.payload.pull_request.head.ref === 'main' || context.payload.pull_request.head.ref === 'master')) {
4569
message += '⚠️ This PR cannot be merged because it originates from your fork\'s main/master branch. If you are attempting to contribute code please PR from your dev branch or another non-main/master branch.\n\n';
4670
}
4771
48-
message += '🔒 This PR will now be automatically closed due to the above violation(s).';
49-
72+
message += '🔒 This PR will now be automatically closed due to the above rules.';
73+
5074
// Post the comment
5175
await github.rest.issues.createComment({
5276
...context.repo,
5377
issue_number: context.issue.number,
5478
body: message
5579
});
56-
80+
5781
// Close the PR
5882
await github.rest.pulls.update({
5983
...context.repo,

Config/CIPPTimers.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"Cron": "0 0 */12 * * *",
7979
"Priority": 4,
8080
"RunOnProcessor": true,
81+
"TZOffset": true,
8182
"PreferredProcessor": "standards"
8283
},
8384
{
@@ -87,6 +88,7 @@
8788
"Cron": "0 15 */12 * * *",
8889
"Priority": 5,
8990
"RunOnProcessor": true,
91+
"TZOffset": true,
9092
"PreferredProcessor": "standards"
9193
},
9294
{
@@ -120,6 +122,7 @@
120122
"Cron": "0 0 0 * * 0",
121123
"Priority": 7,
122124
"RunOnProcessor": true,
125+
"TZOffset": true,
123126
"IsSystem": true
124127
},
125128
{
@@ -137,6 +140,7 @@
137140
"Description": "Orchestrator to process domains",
138141
"Cron": "0 30 5 * * *",
139142
"Priority": 22,
143+
"TZOffset": true,
140144
"RunOnProcessor": true
141145
},
142146
{
@@ -149,6 +153,7 @@
149153
"Cron": "0 0 23 * * *",
150154
"Priority": 10,
151155
"RunOnProcessor": true,
156+
"TZOffset": true,
152157
"IsSystem": true
153158
},
154159
{
@@ -158,6 +163,7 @@
158163
"Cron": "0 0 0 * * *",
159164
"Priority": 10,
160165
"RunOnProcessor": true,
166+
"TZOffset": true,
161167
"IsSystem": true
162168
},
163169
{
@@ -166,6 +172,7 @@
166172
"Description": "Timer to process billing",
167173
"Cron": "0 0 0 * * *",
168174
"Priority": 12,
175+
"TZOffset": true,
169176
"RunOnProcessor": true
170177
},
171178
{
@@ -174,6 +181,7 @@
174181
"Description": "Orchestrator to process BPA reports",
175182
"Cron": "0 0 3 * * *",
176183
"Priority": 10,
184+
"TZOffset": true,
177185
"RunOnProcessor": true
178186
},
179187
{
@@ -191,6 +199,7 @@
191199
"Cron": "0 0 0 * * *",
192200
"Priority": 15,
193201
"RunOnProcessor": true,
202+
"TZOffset": true,
194203
"IsSystem": true
195204
},
196205
{
@@ -200,6 +209,7 @@
200209
"Cron": "0 0 23 * * *",
201210
"Priority": 20,
202211
"RunOnProcessor": true,
212+
"TZOffset": true,
203213
"IsSystem": true
204214
},
205215
{
@@ -212,6 +222,7 @@
212222
"Cron": "0 0 0 * * *",
213223
"Priority": 20,
214224
"RunOnProcessor": true,
225+
"TZOffset": true,
215226
"IsSystem": true
216227
},
217228
{
@@ -221,6 +232,7 @@
221232
"Cron": "0 0 2 * * *",
222233
"Priority": 21,
223234
"RunOnProcessor": true,
235+
"TZOffset": true,
224236
"IsSystem": true
225237
},
226238
{
@@ -230,6 +242,7 @@
230242
"Cron": "0 30 2 * * *",
231243
"Priority": 22,
232244
"RunOnProcessor": true,
245+
"TZOffset": true,
233246
"IsSystem": true
234247
},
235248
{
@@ -239,6 +252,7 @@
239252
"Cron": "0 0 3 * * *",
240253
"Priority": 23,
241254
"RunOnProcessor": true,
255+
"TZOffset": true,
242256
"IsSystem": true
243257
},
244258
{
@@ -248,6 +262,7 @@
248262
"Cron": "0 0 4 * * *",
249263
"Priority": 24,
250264
"RunOnProcessor": true,
265+
"TZOffset": true,
251266
"IsSystem": true
252267
}
253268
]

Modules/CIPPActivityTriggers/Public/Entrypoints/Activity Triggers/Domain Analyser/Push-DomainAnalyserDomain.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function Push-DomainAnalyserDomain {
6262
MSCNAMEDKIMSelectors = ''
6363
EnterpriseEnrollment = ''
6464
EnterpriseRegistration = ''
65+
AutoDiscover = ''
6566
Score = ''
6667
MaximumScore = 160
6768
ScorePercentage = ''
@@ -293,6 +294,26 @@ function Push-DomainAnalyserDomain {
293294
}
294295
#EndRegion Intune Enrollment CNAME Check
295296

297+
#Region AutoDiscover Check
298+
try {
299+
$AutoDiscoverRecord = Read-AutoDiscoverRecord -Domain $Domain
300+
$AutoDiscoverFailCount = $AutoDiscoverRecord.ValidationFails | Measure-Object | Select-Object -ExpandProperty Count
301+
$AutoDiscoverWarnCount = $AutoDiscoverRecord.ValidationWarns | Measure-Object | Select-Object -ExpandProperty Count
302+
if ($AutoDiscoverFailCount -eq 0 -and $AutoDiscoverWarnCount -eq 0) {
303+
$Result.AutoDiscover = 'Correct'
304+
} elseif ($AutoDiscoverFailCount -eq 0) {
305+
$Result.AutoDiscover = "$($AutoDiscoverRecord.RecordType): $($AutoDiscoverRecord.Record)"
306+
$ScoreExplanation.Add("AutoDiscover $($AutoDiscoverRecord.RecordType) record points to unexpected target") | Out-Null
307+
} else {
308+
$Result.AutoDiscover = 'No Record'
309+
$ScoreExplanation.Add('No AutoDiscover DNS record found') | Out-Null
310+
}
311+
} catch {
312+
$Result.AutoDiscover = 'Error'
313+
Write-LogMessage -API 'DomainAnalyser' -tenant $DomainObject.TenantId -message "AutoDiscover check error for $Domain" -LogData (Get-CippException -Exception $_) -sev Error
314+
}
315+
#EndRegion AutoDiscover Check
316+
296317
#Region MSCNAME DKIM Records
297318
# Get Microsoft DKIM CNAME selector Records
298319
# Ugly, but i needed to create a scope/loop i could break out of without breaking the rest of the function

Modules/CIPPActivityTriggers/Public/Entrypoints/Activity Triggers/Graph Requests/Push-ListGraphRequestQueue.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ function Push-ListGraphRequestQueue {
6363
Data = [string]$Json
6464
}
6565
Add-CIPPAzDataTableEntity @Table -Entity $GraphResults -Force | Out-Null
66+
67+
if ($env:CIPPNG -eq 'true') {
68+
try {
69+
[Craft.Services.CacheBridge]::InvalidateByScope('AllTenants')
70+
} catch {
71+
Write-Information "CacheBridge invalidation skipped: $($_.Exception.Message)"
72+
}
73+
}
74+
6675
return $true
6776
} catch {
6877
Write-Warning "Queue Error: $($_.Exception.Message)"

Modules/CIPPActivityTriggers/Public/Entrypoints/Activity Triggers/Push-CIPPDBCacheData.ps1

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,23 @@ function Push-CIPPDBCacheData {
6565
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message "Compliance license check failed: $($_.Exception.Message)" -sev Warning -LogData $ErrorMessage
6666
}
6767

68-
Write-Information "License capabilities for $TenantFilter - Intune: $IntuneCapable, CA: $ConditionalAccessCapable, P2: $AzureADPremiumP2Capable, Exchange: $ExchangeCapable, Compliance: $ComplianceCapable"
68+
$SharePointCapable = $false
69+
try {
70+
$SharePointCapable = Test-CIPPStandardLicense -StandardName 'SharePointLicenseCheck' -TenantFilter $TenantFilter -RequiredCapabilities @('SHAREPOINTWAC', 'SHAREPOINTSTANDARD', 'SHAREPOINTENTERPRISE', 'SHAREPOINTENTERPRISE_EDU', 'ONEDRIVE_BASIC', 'ONEDRIVE_ENTERPRISE') -SkipLog
71+
} catch {
72+
$ErrorMessage = Get-CippException -Exception $_
73+
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message "SharePoint license check failed: $($_.Exception.Message)" -sev Warning -LogData $ErrorMessage
74+
}
75+
76+
$TeamsCapable = $false
77+
try {
78+
$TeamsCapable = Test-CIPPStandardLicense -StandardName 'TeamsLicenseCheck' -TenantFilter $TenantFilter -RequiredCapabilities @('MCOSTANDARD', 'MCOEV', 'MCOIMP', 'TEAMS1', 'Teams_Room_Standard') -SkipLog
79+
} catch {
80+
$ErrorMessage = Get-CippException -Exception $_
81+
Write-LogMessage -API 'CIPPDBCache' -tenant $TenantFilter -message "Teams license check failed: $($_.Exception.Message)" -sev Warning -LogData $ErrorMessage
82+
}
83+
84+
Write-Information "License capabilities for $TenantFilter - Intune: $IntuneCapable, CA: $ConditionalAccessCapable, P2: $AzureADPremiumP2Capable, Exchange: $ExchangeCapable, Compliance: $ComplianceCapable, SharePoint: $SharePointCapable, Teams: $TeamsCapable"
6985

7086
# Build grouped collection tasks — one activity per license category instead of one per cache type
7187
$Tasks = [System.Collections.Generic.List[object]]::new()
@@ -174,6 +190,30 @@ function Push-CIPPDBCacheData {
174190
Write-Host "Skipping Compliance data collection for $TenantFilter - no required license"
175191
}
176192

193+
if ($SharePointCapable) {
194+
$Tasks.Add(@{
195+
FunctionName = 'ExecCIPPDBCache'
196+
CollectionType = 'SharePoint'
197+
TenantFilter = $TenantFilter
198+
QueueId = $QueueId
199+
QueueName = "DB Cache SharePoint - $TenantFilter"
200+
})
201+
} else {
202+
Write-Host "Skipping SharePoint data collection for $TenantFilter - no required license"
203+
}
204+
205+
if ($TeamsCapable) {
206+
$Tasks.Add(@{
207+
FunctionName = 'ExecCIPPDBCache'
208+
CollectionType = 'Teams'
209+
TenantFilter = $TenantFilter
210+
QueueId = $QueueId
211+
QueueName = "DB Cache Teams - $TenantFilter"
212+
})
213+
} else {
214+
Write-Host "Skipping Teams data collection for $TenantFilter - no required license"
215+
}
216+
177217
Write-Information "Built $($Tasks.Count) grouped cache tasks for tenant $TenantFilter (down from individual per-type tasks)"
178218

179219
# Return the task list — the PostExecution function will aggregate and start a flat orchestrator

Modules/CIPPActivityTriggers/Public/Entrypoints/Activity Triggers/Push-UpdatePermissionsQueue.ps1

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ function Push-UpdatePermissionsQueue {
55
#>
66
param($Item)
77

8-
try {
9-
$DomainRefreshRequired = $false
8+
$Status = 'Failed'
9+
$FailureMessage = $null
10+
$DomainRefreshRequired = $false
1011

12+
try {
1113
if (!$Item.defaultDomainName) {
1214
$DomainRefreshRequired = $true
1315
}
@@ -46,33 +48,55 @@ function Push-UpdatePermissionsQueue {
4648

4749
if ($Item.defaultDomainName -ne 'PartnerTenant') {
4850
Write-Information 'Pushing CIPP-SAM admin roles'
49-
Set-CIPPSAMAdminRoles -TenantFilter $Item.customerId
51+
try {
52+
Set-CIPPSAMAdminRoles -TenantFilter $Item.customerId
53+
} catch {
54+
$SamRoleError = Get-CippException -Exception $_
55+
Write-Information "Failed to set CIPP-SAM admin roles for $($Item.displayName): $($_.Exception.Message)"
56+
Write-LogMessage -tenant $Item.defaultDomainName -tenantId $Item.customerId -message "Failed to set CIPP-SAM admin roles for $($Item.displayName) - $($_.Exception.Message)" -Sev 'Warning' -API 'UpdatePermissionsQueue' -LogData $SamRoleError
57+
if ($Status -eq 'Success') {
58+
$Status = 'Failed'
59+
$FailureMessage = "Set-CIPPSAMAdminRoles: $($_.Exception.Message)"
60+
}
61+
}
5062
}
51-
52-
$Table = Get-CIPPTable -TableName cpvtenants
53-
$unixtime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
54-
$GraphRequest = @{
55-
LastApply = "$unixtime"
56-
LastStatus = "$Status"
57-
applicationId = "$($env:ApplicationID)"
58-
Tenant = "$($Item.customerId)"
59-
PartitionKey = 'Tenant'
60-
RowKey = "$($Item.customerId)"
63+
} catch {
64+
Write-Information "Error updating permissions for $($Item.displayName): $($_.Exception.Message)"
65+
Write-Information $_.InvocationInfo.PositionMessage
66+
Write-LogMessage -tenant $Item.defaultDomainName -tenantId $Item.customerId -message "Error updating permissions for $($Item.displayName) - $($_.Exception.Message)" -Sev 'Error' -API 'UpdatePermissionsQueue' -LogData (Get-CippException -Exception $_)
67+
$Status = 'Failed'
68+
if (-not $FailureMessage) {
69+
$FailureMessage = $_.Exception.Message
6170
}
62-
if ($PermissionFailures) {
63-
$GraphRequest.LastError = $FailureMessage
71+
} finally {
72+
try {
73+
$CpvTable = Get-CIPPTable -TableName cpvtenants
74+
$unixtime = [int64](([datetime]::UtcNow) - (Get-Date '1/1/1970')).TotalSeconds
75+
$GraphRequest = @{
76+
LastApply = "$unixtime"
77+
LastStatus = "$Status"
78+
applicationId = "$($env:ApplicationID)"
79+
Tenant = "$($Item.customerId)"
80+
PartitionKey = 'Tenant'
81+
RowKey = "$($Item.customerId)"
82+
}
83+
if ($FailureMessage) {
84+
$GraphRequest.LastError = "$FailureMessage"
85+
}
86+
Add-CIPPAzDataTableEntity @CpvTable -Entity $GraphRequest -Force
87+
} catch {
88+
Write-Information "Failed to persist cpvtenants row for $($Item.displayName): $($_.Exception.Message)"
6489
}
65-
Add-CIPPAzDataTableEntity @Table -Entity $GraphRequest -Force
6690

6791
if ($DomainRefreshRequired) {
68-
$UpdatedTenant = Get-Tenants -TenantFilter $Item.customerId -TriggerRefresh
69-
if ($UpdatedTenant.defaultDomainName) {
70-
Write-Information "Updated tenant domains $($UpdatedTenant.defaultDomainName)"
92+
try {
93+
$UpdatedTenant = Get-Tenants -TenantFilter $Item.customerId -TriggerRefresh
94+
if ($UpdatedTenant.defaultDomainName) {
95+
Write-Information "Updated tenant domains $($UpdatedTenant.defaultDomainName)"
96+
}
97+
} catch {
98+
Write-Information "Failed to refresh tenant domains for $($Item.displayName): $($_.Exception.Message)"
7199
}
72100
}
73-
} catch {
74-
Write-Information "Error updating permissions for $($Item.displayName): $($_.Exception.Message)"
75-
Write-Information $_.InvocationInfo.PositionMessage
76-
Write-LogMessage -tenant $Item.defaultDomainName -tenantId $Item.customerId -message "Error updating permissions for $($Item.displayName) - $($_.Exception.Message)" -Sev 'Error' -API 'UpdatePermissionsQueue' -LogData (Get-CippException -Exception $_)
77101
}
78102
}

0 commit comments

Comments
 (0)