Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Feb 23, 2024
2 parents 2d8e766 + 3e5d393 commit d3e4480
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/cipp-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Scheduled CIPP Update
on:
schedule:
- cron: '50 11 * * 5'
# scheduled for 11:50 UTC every Friday
workflow_dispatch:

jobs:
merge-upstream:
runs-on: ubuntu-latest
steps:
- uses: anatawa12/fork-sync-all-branches@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/master_cippcklru.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Powershell project to Azure Function App - cippcklru

on:
push:
branches:
- master
- dev
workflow_dispatch:

env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root

jobs:
build-and-deploy:
runs-on: windows-latest
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2

- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: 'cippcklru'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_27B63F21821146D7B2D087D67F258F04 }}
34 changes: 28 additions & 6 deletions Modules/CIPPCore/Public/Invoke-CIPPWebhookProcessing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function Invoke-CippWebhookProcessing {
{ 'UserLoggedIn' -eq $data.operation -and $hosting -eq $true -and !$TrustedIps } { $data.operation = 'HostedIP' }
{ 'UserLoggedIn' -eq $data.operation -and $Country -notin $AllowedLocations -and $data.ResultStatus -eq 'Success' -and $TableObj.ResultStatusDetail -eq 'Success' } {
Write-Host "$($country) is not in $($AllowedLocations)"
$data.operation = 'UserLoggedInFromUnknownLocation'
$data.operation = 'UserLoggedInFromUnknownLocation'
}
{ 'UserloggedIn' -eq $data.operation -and $data.UserType -eq 2 -and $data.ResultStatus -eq 'Success' -and $TableObj.ResultStatusDetail -eq 'Success' } { $data.operation = 'AdminLoggedIn' }
default { break }
Expand Down Expand Up @@ -129,7 +129,7 @@ function Invoke-CippWebhookProcessing {
$key = $parts[0]
$operator = $parts[1]
$value = $parts[2]
if (!$value) {
if (!$value) {
Write-Host 'blank value, skip'
continue
}
Expand Down Expand Up @@ -164,9 +164,9 @@ function Invoke-CippWebhookProcessing {
$RuleDisabled = 0
New-ExoRequest -anchor $username -tenantid $TenantFilter -cmdlet 'get-inboxrule' -cmdParams @{Mailbox = $username } | ForEach-Object {
$null = New-ExoRequest -anchor $username -tenantid $TenantFilter -cmdlet 'Disable-InboxRule' -cmdParams @{Confirm = $false; Identity = $_.Identity }
"Disabled Inbox Rule $($_.Identity) for $username"
"Disabled Inbox Rule $($_.Identity) for $username"
$RuleDisabled ++
}
}
if ($RuleDisabled) {
"Disabled $RuleDisabled Inbox Rules for $username"
} else {
Expand Down Expand Up @@ -210,7 +210,7 @@ function Invoke-CippWebhookProcessing {
}
}
Write-Host 'Going to create the content'
foreach ($action in $dos) {
foreach ($action in $dos) {
switch ($action.execute) {
'generatemail' {
Write-Host 'Going to create the email'
Expand All @@ -219,7 +219,7 @@ function Invoke-CippWebhookProcessing {
Send-CIPPAlert -Type 'email' -Title $GenerateEmail.title -HTMLContent $GenerateEmail.htmlcontent -TenantFilter $TenantFilter
Write-Host 'email should be sent'

}
}
'generatePSA' {
$GenerateEmail = New-CIPPAlertTemplate -format 'html'-data $Data -LocationInfo $Location -ActionResults $ActionResults
Send-CIPPAlert -Type 'psa' -Title $GenerateEmail.title -HTMLContent $GenerateEmail.htmlcontent -TenantFilter $TenantFilter
Expand Down Expand Up @@ -247,4 +247,26 @@ function Invoke-CippWebhookProcessing {
}
}
}

if ($data.ClientIP) {
try {
$IP = $data.ClientIP
if ($IP -match '^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$') {
$IP = $IP -replace ':\d+$', '' # Remove the port number if present
}
$LocationInfo = @{
RowKey = [string]$ip
PartitionKey = [string]$data.UserId
Tenant = [string]$TenantFilter
CountryOrRegion = "$Country"
City = "$City"
Proxy = "$Proxy"
Hosting = "$hosting"
ASName = "$ASName"
}
$null = Add-CIPPAzDataTableEntity @LocationTable -Entity $LocationInfo -Force
} catch {
Write-Host "Exception adding IP to table - $IP - $($_.Exception.Message)"
}
}
}

0 comments on commit d3e4480

Please sign in to comment.