Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dacf107
Initial plan
Copilot Sep 12, 2025
6564084
Add status tracking to GitHubAppInstallation class to compare permiss…
Copilot Sep 12, 2025
439519d
Add Status property to GitHubAppInstallation display formats and upda…
Copilot Sep 12, 2025
4bffffe
Fix app link
MariusStorhaug Sep 12, 2025
896aaac
🩹 [Patch]: Enhance argument completers for GitHub configuration and u…
MariusStorhaug Sep 12, 2025
5dfd0f5
🩹 [Patch]: Make the Context parameter mandatory in Switch-GitHubConte…
MariusStorhaug Sep 12, 2025
6447faa
Add initial test scripts for GitHub API interactions
MariusStorhaug Sep 13, 2025
6dc3cc6
🩹 [Patch]: Update Permissions property type to GitHubPermission array…
MariusStorhaug Sep 13, 2025
d3285a6
🩹 [Patch]: Add GitHubPermission.Format.ps1xml for GitHubPermission ta…
MariusStorhaug Sep 13, 2025
c402d1f
🩹 [Patch]: Enhance GitHubPermission initialization to handle unknown …
MariusStorhaug Sep 13, 2025
1fc35cf
🩹 [Patch]: Refactor permission handling in GitHubApp and GitHubAppIns…
MariusStorhaug Sep 13, 2025
bfe5279
Fix formatting in NewFullCatalog function for better readability of s…
MariusStorhaug Sep 13, 2025
2c60136
🩹 [Patch]: Simplify return statement in NewFullCatalog function for c…
MariusStorhaug Sep 13, 2025
32710e4
🩹 [Patch]: Update permissions assignment in GitHubAppInstallationCont…
MariusStorhaug Sep 13, 2025
a8097a4
🩹 [Patch]: Refactor permission handling to use newPermissionList for …
MariusStorhaug Sep 13, 2025
968dce5
🩹 [Patch]: Add new permission definition for enterprise custom organi…
MariusStorhaug Sep 13, 2025
6ce56a6
🩹 [Patch]: Remove 'read' option from permission definition for improv…
MariusStorhaug Sep 13, 2025
8d245b6
🩹 [Patch]: Remove CompareWithAppConfiguration method and replace with…
MariusStorhaug Sep 13, 2025
4b901dd
🩹 [Patch]: Update permission filtering for 'User' scope to only inclu…
MariusStorhaug Sep 14, 2025
4172bab
🩹 [Patch]: Update permission validation in tests to ensure correct ty…
MariusStorhaug Sep 14, 2025
68c1bd7
🩹 [Patch]: Refactor permission list creation in GitHubPermission clas…
MariusStorhaug Sep 14, 2025
4b67e3d
🩹 [Patch]: Remove unused variables related to permissions in GitHubPe…
MariusStorhaug Sep 14, 2025
db204ad
🩹 [Patch]: Add default case to permission filtering in GitHubPermissi…
MariusStorhaug Sep 14, 2025
51eed1f
🩹 [Patch]: Enhance logging in Apps.Tests by adding permission context…
MariusStorhaug Sep 14, 2025
54f4957
🩹 [Patch]: Refactor GitHub app tests for improved structure and clari…
MariusStorhaug Sep 15, 2025
fa601ec
🩹 [Patch]: Fix logging in installation tests to output individual ins…
MariusStorhaug Sep 15, 2025
ee7477c
🩹 [Patch]: Refactor permission checks in Apps.Tests to use a single v…
MariusStorhaug Sep 15, 2025
fb83868
🩹 [Patch]: Refactor permission list creation in GitHubPermission clas…
MariusStorhaug Sep 15, 2025
2e46e9d
Refactor NewPermissionList methods to improve property handling from …
MariusStorhaug Sep 15, 2025
53e5249
🩹 [Patch]: Refactor NewPermissionList method calls to use consistent …
MariusStorhaug Sep 15, 2025
2a1944b
🩹 [Patch]: Simplify response handling in Get-GitHubAuthenticatedApp b…
MariusStorhaug Sep 15, 2025
20f713f
🩹 [Patch]: Simplify GitHubPermission constructor and NewPermissionLis…
MariusStorhaug Sep 15, 2025
ac1a3a7
🩹 [Patch]: Update NewPermissionList methods to return GitHubPermissio…
MariusStorhaug Sep 15, 2025
5f8a82e
Refactor NewPermissionList methods to streamline object property acce…
MariusStorhaug Sep 15, 2025
fe0dae8
🩹 [Patch]: Update Get-GitHubPermissionDefinition to use List property…
MariusStorhaug Sep 15, 2025
3529d91
🩹 [Patch]: Enhance app context tests to verify Permissions property a…
MariusStorhaug Sep 15, 2025
b4cfbda
🩹 [Patch]: Remove skip condition from app context permission tests to…
MariusStorhaug Sep 15, 2025
f72dad0
🩹 [Patch]: Update app context tests to use Format-Table for permissio…
MariusStorhaug Sep 15, 2025
1449987
🩹 [Patch]: Simplify permission validation by directly iterating over …
MariusStorhaug Sep 15, 2025
058bdce
Add initial test scripts for GitHub API interactions
MariusStorhaug Sep 15, 2025
c5d8ad0
🩹 [Patch]: Clarify comment for Permissions property in GitHubAppInsta…
MariusStorhaug Sep 15, 2025
c4021cc
🩹 [Patch]: Replace ScriptBlock with PropertyName for Status column in…
MariusStorhaug Sep 15, 2025
9041814
🩹 [Patch]: Update argument completers to use GitHubPermissionDefiniti…
MariusStorhaug Sep 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/classes/public/App/GitHubApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
[System.Nullable[datetime]] $UpdatedAt

# The permissions that the app is requesting.
[pscustomobject] $Permissions
[GitHubPermission[]] $Permissions

# The events that the app is subscribing to on its target.
[string[]] $Events
Expand All @@ -59,7 +59,7 @@
$this.Url = $Object.html_url
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.Permissions = $Object.permissions
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.permissions)
$this.Events = , ($Object.events)
$this.Installations = $Object.installations_count
}
Expand Down
109 changes: 106 additions & 3 deletions src/classes/public/App/GitHubAppInstallation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[string] $RepositorySelection

# The permissions that the app has on the target.
[pscustomobject] $Permissions
[GitHubPermission[]] $Permissions

# The events that the app is subscribing to.
[string[]] $Events
Expand All @@ -41,6 +41,9 @@
# The URL to the target's profile based on the target type.
[string] $Url

# The status indicating if the installation permissions and events match the app's configuration.
[string] $Status

GitHubAppInstallation() {}

GitHubAppInstallation([PSCustomObject] $Object) {
Expand All @@ -55,14 +58,32 @@
$this.Target = [GitHubOwner]::new($Object.account)
$this.Type = $Object.target_type
$this.RepositorySelection = $Object.repository_selection
$this.Permissions = $Object.permissions
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.permissions, $this.Type)
$this.Events = , ($Object.events)
$this.FilePaths = $Object.single_file_paths
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.SuspendedAt = $Object.suspended_at
$this.SuspendedBy = [GitHubUser]::new($Object.suspended_by)
$this.Url = $Object.html_url
$this.Status = 'Unknown'
}

GitHubAppInstallation([PSCustomObject] $Object, [GitHubApp] $App) {
$this.ID = $Object.id
$this.App = $App
$this.Target = [GitHubOwner]::new($Object.account)
$this.Type = $Object.target_type
$this.RepositorySelection = $Object.repository_selection
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.permissions, $this.Type)
$this.Events = , ($Object.events)
$this.FilePaths = $Object.single_file_paths
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.SuspendedAt = $Object.suspended_at
$this.SuspendedBy = [GitHubUser]::new($Object.suspended_by)
$this.Url = $Object.html_url
$this.UpdateStatus()
}

GitHubAppInstallation([PSCustomObject] $Object, [string] $Target, [string] $Type, [GitHubContext] $Context) {
Expand All @@ -81,13 +102,95 @@
}
$this.Type = $Type
$this.RepositorySelection = $Object.repository_selection
$this.Permissions = $Object.permissions
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.permissions, $this.Type)
$this.Events = , ($Object.events)
$this.FilePaths = $Object.single_file_paths
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.SuspendedAt = $Object.suspended_at
$this.SuspendedBy = [GitHubUser]::new($Object.suspended_by)
$this.Url = "https://$($Context.HostName)/$($Type.ToLower())s/$Target/settings/installations/$($Object.id)"
$this.Status = 'Unknown'
}

GitHubAppInstallation([PSCustomObject] $Object, [string] $Target, [string] $Type, [GitHubContext] $Context, [GitHubApp] $App) {
$this.ID = $Object.id
$this.App = $App
$this.Target = [GitHubOwner]@{
Name = $Target
Type = $Type
Url = "https://$($Context.HostName)/$Target"
}
$this.Type = $Type
$this.RepositorySelection = $Object.repository_selection
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.permissions, $this.Type)
$this.Events = , ($Object.events)
$this.FilePaths = $Object.single_file_paths
$this.CreatedAt = $Object.created_at
$this.UpdatedAt = $Object.updated_at
$this.SuspendedAt = $Object.suspended_at
$this.SuspendedBy = [GitHubUser]::new($Object.suspended_by)
$this.Url = "https://$($Context.HostName)/$($Type.ToLower())s/$Target/settings/installations/$($Object.id)"
$this.UpdateStatus()
}

# Updates the Status property by comparing installation permissions with app permissions
# filtered by the appropriate scope based on installation type
[void] UpdateStatus() {
if (-not $this.App -or -not $this.App.Permissions) {
$this.Status = 'Unknown'
return
}

# Get app permissions filtered by installation type scope
$appPermissionsFiltered = switch ($this.Type) {
'Enterprise' {
$this.App.Permissions | Where-Object { $_.Scope -eq 'Enterprise' }
}
'Organization' {
$this.App.Permissions | Where-Object { $_.Scope -in @('Organization', 'Repository') }
}
'User' {
$this.App.Permissions | Where-Object { $_.Scope -in @('Repository') }
}
default {
$this.App.Permissions
}
}

# Compare permissions by creating lookup dictionaries
$appPermissionLookup = @{}
foreach ($perm in $appPermissionsFiltered) {
$appPermissionLookup[$perm.Name] = $perm.Value
}

$installationPermissionLookup = @{}
foreach ($perm in $this.Permissions) {
$installationPermissionLookup[$perm.Name] = $perm.Value
}

# Check if permissions match
$permissionsMatch = $true

# Check if all app permissions exist in installation with same values
foreach ($name in $appPermissionLookup.Keys) {
if (-not $installationPermissionLookup.ContainsKey($name) -or
$installationPermissionLookup[$name] -ne $appPermissionLookup[$name]) {
$permissionsMatch = $false
break
}
}

# Check if installation has any extra permissions not in the app
if ($permissionsMatch) {
foreach ($name in $installationPermissionLookup.Keys) {
if (-not $appPermissionLookup.ContainsKey($name)) {
$permissionsMatch = $false
break
}
}
}

$this.Status = $permissionsMatch ? 'Ok' : 'Outdated'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[string] $OwnerType

# The permissions that the app is requesting on the target
[pscustomobject] $Permissions
[GitHubPermission[]] $Permissions

# The events that the app is subscribing to once installed
[string[]] $Events
Expand Down Expand Up @@ -47,7 +47,7 @@
$this.KeyVaultKeyReference = $Object.KeyVaultKeyReference
$this.OwnerName = $Object.OwnerName
$this.OwnerType = $Object.OwnerType
$this.Permissions = $Object.Permissions
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.Permissions)
$this.Events = $Object.Events
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[System.Nullable[uint64]] $InstallationID

# The permissions that the app is requesting on the target
[pscustomobject] $Permissions
[GitHubPermission[]] $Permissions

# The events that the app is subscribing to once installed
[string[]] $Events
Expand Down Expand Up @@ -41,7 +41,7 @@
$this.PerPage = $Object.PerPage
$this.ClientID = $Object.ClientID
$this.InstallationID = $Object.InstallationID
$this.Permissions = $Object.Permissions
$this.Permissions = [GitHubPermission]::NewPermissionList($Object.Permissions, $Object.InstallationType)
$this.Events = $Object.Events
$this.InstallationType = $Object.InstallationType
$this.InstallationName = $Object.InstallationName
Expand Down
Loading
Loading