Skip to content

Conversation

@wilsonianb
Copy link
Collaborator

workingDirectory: ${{ github.event.inputs.directory }}
command: deploy --no-bundle --name=${{ github.event.inputs.appId }} --dispatch-namespace ${{ github.event.inputs.dispatchNamespace }} ${{ steps.get-script.outputs.WORKER_SCRIPT }}

attest:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this a separate job creates a second set of webhook events

webhooks.on("workflow_job.in_progress", async (data) => {

webhooks.on("workflow_job.completed", async (data) => {

Comment on lines 141 to 144
- name: Attest Build Provenance
uses: actions/attest-build-provenance@v1
with:
subject-path: ${{ needs.deploy.outputs.WORKER_SCRIPT }}
Copy link
Collaborator Author

@wilsonianb wilsonianb Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run: |
uri="git+https://github.com/${{ github.event.inputs.repo }}@refs/heads/${{ github.event.inputs.branch }}"
resolved_dependencies=$(jq -n --arg uri "$uri" --arg commit "${{ github.event.inputs.commit }}" '[{"uri": $uri, "digest": {"gitCommit": $commit}}]')
predicate=$(echo '${{ steps.generate-build-provenance-predicate.outputs.predicate }}' | jq -c '.buildDefinition.externalParameters.resolvedDependencies = $resolved_dependencies' --argjson resolved_dependencies "$resolved_dependencies")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overriding the existing .buildDefinition.resolvedDependencies resulted in

Error: Failed to persist attestation: Invalid Argument - values do not match: git+https://github.com/wilsonianb/php-worker-hello-world@refs/heads/master != git+https://github.com/codius/codius-workers@refs/heads/preview - https://docs.github.com/rest/repos/repos#create-an-attestation

which appears to originate in
https://github.com/actions/toolkit/blob/6c4e082c181a51609197e536ef5255a0c9baeef7/packages/attest/src/store.ts#L28-L42

Specifying the worker's repo in an added resolvedDependencies field under externalParameters appears to work.
However, it isn't displayed in either the GitHub attestation or Rekor entry

It can be found by parsing the attestation file:

jq -r '.dsseEnvelope.payload' codius-codius-workers-attestation-1774723.sigstore.json | base64 -d | jq .

https://slsa.dev/spec/v1.0/provenance#builddefinition

Report appId in separate workflow job.
Add workflow_run.completed webhook handler.
Add githubWorkflowRunId index in apps table.
@wilsonianb wilsonianb marked this pull request as ready for review August 26, 2024 23:04
@wilsonianb wilsonianb merged commit 59cec53 into main Aug 26, 2024
@wilsonianb wilsonianb deleted the provenance branch August 26, 2024 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add build provenance attestation for deployed workers

2 participants