Commit fff966d
🩹 [Patch]: Add Fine-Grained Permissions Data for GitHub PowerShell Module (#501)
This PR implements a comprehensive fine-grained permissions data
infrastructure for the GitHub PowerShell module, enabling detection of
GitHub App installations that may be missing newly added permissions.
- Fixes #485
## What's New
### GitHubPermission Class
Added a new public `GitHubPermission` class with the following
properties:
- **Name** - Programmatic permission name (e.g., `contents`, `issues`)
- **DisplayName** - Human-friendly name (e.g., "Contents", "Issues")
- **Description** - Brief description of what access the permission
grants
- **URL** - Link to relevant GitHub documentation
- **Options** - Available access levels (`read`, `write`, `admin`)
- **Type** - Permission type (`Fine-grained`, `Classic`)
- **Scope** - Application scope (`Repository`, `Organization`, `User`,
`Enterprise`)
### Comprehensive Permissions Database
Added 90 fine-grained permissions covering all major GitHub permission
categories:
- **33 Repository permissions** - actions, contents, issues,
pull_requests, secrets, etc.
- **33 Organization permissions** - members, administration,
organization_secrets, etc.
- **18 User permissions** - profile, followers, git_ssh_keys, etc.
- **6 Enterprise permissions** - custom properties, organization
installation, etc.
### Get-GitHubPermissionDefinition Function
New public function to query the permissions database with advanced
filtering:
```powershell
# Get all permissions
Get-GitHubPermissionDefinition
# Filter by scope
Get-GitHubPermissionDefinition -Scope Repository
# Combined filtering
Get-GitHubPermissionDefinition -Type Fine-grained -Scope Organization
# Find specific permissions
Get-GitHubPermissionDefinition -Name 'contents'
```
### Argument Completers
Added argument completers for `Get-GitHubPermissionDefinition`
parameters to improve user experience:
- **Name** - Tab completion for available permission names (actions,
contents, issues, etc.)
- **DisplayName** - Tab completion for available permission display
names (Actions, Dependabot alerts, etc.)
- **Type** - Tab completion for available permission types
(Fine-grained)
- **Scope** - Tab completion for available scopes (Repository,
Organization, User, Enterprise)
## Use Cases
This infrastructure enables several key scenarios:
1. **Permission Validation** - Compare GitHub App installations against
the complete permissions list
2. **Installation Health Checks** - Detect apps missing newly added
permissions
3. **Documentation** - Provide users with comprehensive permission
reference
4. **Automation** - Build tools that ensure installations stay current
with permission requirements
5. **Enhanced User Experience** - Tab completion for parameter values
improves usability
## Implementation Details
- **File path permissions excluded** - These are handled differently by
the GitHub API (appear under `FilePaths` property rather than as named
permissions)
- **Maintainable structure** - Easy to update when GitHub adds new
permissions
- **Performance optimized** - Efficient filtering and lookup operations
- **Comprehensive testing** - Full test coverage for all functionality
- **Argument completion** - Improves user experience with tab completion
support
## Example Usage
```powershell
# Check what repository permissions are available (with tab completion)
$repoPerms = Get-GitHubPermissionDefinition -Scope <TAB>
Write-Host "Repository permissions: $($repoPerms.Count)"
# Get details about the contents permission (with tab completion)
$contents = Get-GitHubPermissionDefinition -Name cont<TAB>
Write-Host "$($contents.DisplayName): $($contents.Description)"
Write-Host "Available options: $($contents.Options -join ', ')"
```
This provides the foundation for building automated permission
management tools and ensuring GitHub App installations remain up-to-date
with the latest permission requirements.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: Marius Storhaug <marstor@hotmail.com>1 parent 9e7a331 commit fff966d
File tree
6 files changed
+1622
-0
lines changed- src
- classes/public
- formats
- functions/public/Permission
- variables/private
- tests
6 files changed
+1622
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments