Skip to content

Commit 884044e

Browse files
Expose caller permission and path boundaries
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent a1b4104 commit 884044e

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

.github/scripts/Get-ProcessPSModuleWorkflowInventory.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ function Get-WorkflowInventoryItem {
590590
} else {
591591
[ordered]@{}
592592
}
593+
Permissions = ConvertTo-PermissionValue -Value (Get-MapValue -Map $job -Name 'permissions')
593594
Environment = Get-MapValue -Map $job -Name 'environment'
594595
Condition = Get-MapValue -Map $job -Name 'if'
595596
}
@@ -677,6 +678,8 @@ function Get-WorkflowInventoryItem {
677678
PushPathsIgnore = ConvertTo-StringArray -Value (Get-MapValue -Map $push -Name 'paths-ignore')
678679
PullRequestBranches = ConvertTo-StringArray -Value (Get-MapValue -Map $pullRequest -Name 'branches')
679680
PullRequestTypes = ConvertTo-StringArray -Value (Get-MapValue -Map $pullRequest -Name 'types')
681+
PullRequestPaths = ConvertTo-StringArray -Value (Get-MapValue -Map $pullRequest -Name 'paths')
682+
PullRequestPathsIgnore = ConvertTo-StringArray -Value (Get-MapValue -Map $pullRequest -Name 'paths-ignore')
680683
ConcurrencyGroup = $concurrencyGroup
681684
CancelInProgress = $cancelInProgress
682685
Permissions = $permissions

.github/scripts/tests/Get-ProcessPSModuleWorkflowInventory.Tests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ permissions:
4040
jobs:
4141
Process-PSModule:
4242
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
43+
permissions:
44+
contents: read
45+
pages: write
46+
id-token: write
4347
uses: PSModule/Process-PSModule/.github/workflows/workflow.yml@v8
4448
with:
4549
Debug: true
@@ -95,12 +99,17 @@ Describe 'Get-ProcessPSModuleWorkflowInventory' {
9599
$result[0].Events | Should -Be @('pull_request', 'push', 'schedule', 'workflow_dispatch')
96100
$result[0].PushBranches | Should -Be @('main')
97101
$result[0].PullRequestTypes | Should -Be @('opened', 'synchronize')
102+
$result[0].PullRequestPaths | Should -BeNullOrEmpty
103+
$result[0].PullRequestPathsIgnore | Should -BeNullOrEmpty
98104
$result[0].ConcurrencyGroup | Should -Be '${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}'
99105
$result[0].CancelInProgress | Should -BeFalse
100106
$result[0].ProcessJobs[0].Reference | Should -Be 'v8'
101107
$result[0].ProcessJobs[0].MatchesTarget | Should -BeTrue
102108
$result[0].MatchesTarget | Should -BeTrue
103109
$result[0].ProcessJobs[0].Condition | Should -Match 'head.repo.full_name'
110+
$result[0].ProcessJobs[0].Permissions.contents | Should -Be 'read'
111+
$result[0].ProcessJobs[0].Permissions.pages | Should -Be 'write'
112+
$result[0].ProcessJobs[0].Permissions.'id-token' | Should -Be 'write'
104113
$result[0].ProcessJobs[0].Inputs.Keys | Should -Contain 'Debug'
105114
$result[0].ProcessJobs[0].SecretMappings.Keys | Should -Be @(
106115
'PSGALLERY_API_KEY'

0 commit comments

Comments
 (0)