Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions .github/workflows/extension-provenance-signer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ name: Extension Provenance Signer

on:
workflow_call:
secrets:
RELEASE_APP_PRIVATE_KEY:
description: "Named binding for the environment-only release-governance key"
required: true
inputs:
source-ref:
description: "Immutable source commit to package and attest (full commit SHA of this run)"
Expand Down Expand Up @@ -37,6 +41,17 @@ jobs:
permissions:
contents: read
steps:
- name: Validate governance key delivery
shell: bash
env:
RELEASE_APP_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
run: |
set -euo pipefail
if [ -z "$RELEASE_APP_KEY" ]; then
echo '::error::Release governance key is unavailable; verify the named caller binding and environment secret'
exit 1
fi

- name: Generate governance-read Release App token
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
Expand Down
25 changes: 22 additions & 3 deletions scripts/tests/extension/ExtensionProvenanceSigner.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ BeforeAll {

Push-Location -LiteralPath $Fixture
try {
& $script:BashCommand -c 'chmod +x ./bin/*'
if ($LASTEXITCODE -ne 0) {
throw 'Unable to make fixture commands executable'
if (Test-Path -LiteralPath (Join-Path $Fixture 'bin')) {
& $script:BashCommand -c 'chmod +x ./bin/*'
if ($LASTEXITCODE -ne 0) {
throw 'Unable to make fixture commands executable'
}
}
$Output = & $script:BashCommand -c 'source ./environment.sh; export PATH="$PWD/bin:$PATH"; bash ./step.sh' 2>&1
return [pscustomobject]@{
Expand Down Expand Up @@ -250,13 +252,18 @@ Describe 'Immutable extension provenance signer' -Tag 'Unit' {
}

It 'Isolates the governance credential to checkout-free authorization' {
$script:Signer['on']['workflow_call']['secrets'].Keys | Should -Be @('RELEASE_APP_PRIVATE_KEY')
[bool]$script:Signer['on']['workflow_call']['secrets']['RELEASE_APP_PRIVATE_KEY']['required'] | Should -BeTrue
[string]$script:Signer['jobs']['authorize']['environment'] | Should -BeExactly 'release-governance'
[string]$script:Signer['jobs']['authorize']['permissions']['contents'] | Should -BeExactly 'read'
$Token = @($script:Signer['jobs']['authorize']['steps'] |
Where-Object { [string]$_['name'] -eq 'Generate governance-read Release App token' })[0]
$Token['with'].Contains('permission-administration') | Should -BeFalse
[string]$Token['with']['permission-contents'] | Should -BeExactly 'read'
[string]$Token['with']['private-key'] | Should -BeExactly '${{ secrets.RELEASE_APP_PRIVATE_KEY }}'
$StepNames = @($script:Signer['jobs']['authorize']['steps'] | ForEach-Object { [string]$_['name'] })
[array]::IndexOf($StepNames, 'Validate governance key delivery') |
Should -BeLessThan ([array]::IndexOf($StepNames, 'Generate governance-read Release App token'))
$AuthorizeText = Get-SignerStepText -JobName 'authorize'
$AuthorizeText | Should -Not -Match 'actions/checkout@|npm ci|Package-Extension\.ps1|gh release (upload|edit)'

Expand All @@ -266,6 +273,18 @@ Describe 'Immutable extension provenance signer' -Tag 'Unit' {
}
}

It 'Validates governance key presence without printing it: <Name>' -Skip:$script:SkipShellFixtureTests -ForEach @(
@{ Name = 'missing'; Key = ''; ExpectedExit = 1 }
@{ Name = 'present'; Key = 'fixture-key-never-a-real-secret'; ExpectedExit = 0 }
) {
$Step = @($script:Signer['jobs']['authorize']['steps'] |
Where-Object { [string]$_['name'] -eq 'Validate governance key delivery' })[0]
$Result = Invoke-BashFixtureStep -Body ([string]$Step['run']) -Environment @{ RELEASE_APP_KEY = $Key }
$Result.ExitCode | Should -Be $ExpectedExit
if ($ExpectedExit -eq 1) { $Result.Output | Should -Match 'Release governance key is unavailable' }
else { $Result.Output | Should -BeNullOrEmpty }
}

It 'Validates actor, draft, channel containment, and exact governance before checkout' {
$AuthorizeText = Get-SignerStepText -JobName 'authorize'
foreach ($Contract in @(
Expand Down
Loading