Skip to content

Commit e77cd51

Browse files
add checkout for build step
1 parent b937fb2 commit e77cd51

File tree

3 files changed

+155
-64
lines changed

3 files changed

+155
-64
lines changed

.github/workflows/release.yaml

+50-55
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ on:
1616
env:
1717
# Use docker.io for Docker Hub if empty
1818
REGISTRY: ghcr.io
19-
# github.repository as <account>/<repo>
20-
IMAGE_NAME: ${{ github.repository }}
19+
# Format as <account>/<repo>
20+
# Must be lower case for container tools to parse correctly
21+
IMAGE_NAME: kong/insomnia-mockbin
2122
HAS_ACCESS_TO_GITHUB_TOKEN: ${{ github.repository_owner == 'Kong' }}
2223
# Local docker OCI archive name until the image is pushed to registry
2324
DOCKER_OCI_ARCHIVE: "docker-archive"
2425
# Always use Docker Hub for publishing image signatures
2526
## docker.io/kong/notary - Use Public Notary repository for release image signatures
2627
## docker.io/kong/notary-internal - Use Private Notary repository for internal image signatures
27-
NOTARY_REPOSITORY: format('{0}/{1}', 'docker.io', ${{ github.ref_type == 'tag' && 'kong/notary' || 'kong/notary-internal' }})
28+
NOTARY_REPOSITORY: ${{ github.ref_type == 'tag' && 'kong/notary' || 'kong/notary-internal' }}
2829

2930
jobs:
3031
check:
@@ -40,7 +41,7 @@ jobs:
4041
# Produces SBOM and CVE report
4142
# Helps understand vulnerabilities / license compliance across third party dependencies
4243
- id: sca-project
43-
uses: Kong/public-shared-actions/security-actions/sca@556e4d9756442828427007a7171683a99adf9a6a # v2.2.1
44+
uses: Kong/public-shared-actions/security-actions/sca@2f02738ecb1670f01391162e43fe3f5d4e7942a1 # v2.2.2
4445
with:
4546
dir: .
4647
upload-sbom-release-assets: true
@@ -56,6 +57,9 @@ jobs:
5657
image_tags: ${{ steps.meta.outputs.tags }}
5758
image_tag_version: ${{ steps.meta.outputs.version }}
5859
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v3
62+
5963
# Set up BuildKit Docker container builder to be able to build
6064
# multi-platform images and export cache
6165
# https://github.com/docker/setup-buildx-action
@@ -102,7 +106,6 @@ jobs:
102106
retention-days: 1
103107

104108
scan-images:
105-
name: Scan Images
106109
runs-on: ubuntu-latest
107110
permissions:
108111
contents: read
@@ -111,78 +114,54 @@ jobs:
111114
if: >
112115
github.repository_owner == 'Kong'
113116
&& needs.build-images.result == 'success'
114-
outputs:
115-
image_name: ${{ env.IMAGE_NAME }}
116-
image_manifest_sha: ${{ steps.image_manifest_metadata.outputs.sha }}
117-
notary_repository: ${{ env.NOTARY_REPOSITORY }}
118117
steps:
119118

120119
- name: Download OCI docker TAR artifact
121120
uses: actions/download-artifact@v3
122121
with:
123122
name: ${{ env.DOCKER_OCI_ARCHIVE }}
124-
path: ${{ github.workspace }}/${{ env.DOCKER_OCI_ARCHIVE }}
125-
123+
path: ${{ github.workspace }}
126124
- name: Load OCI docker TAR artifact
127125
run: |
128-
docker load -i ${{ github.workspace }}/${{ env.DOCKER_OCI_ARCHIVE }}/${{ env.DOCKER_OCI_ARCHIVE }}.tar
126+
docker load -i ${{ github.workspace }}/${{ env.DOCKER_OCI_ARCHIVE }}.tar
129127
docker image ls
130128
131-
# Setup regctl to parse platform specific image digest from image manifest
132-
- name: Install regctl
133-
uses: regclient/actions/regctl-installer@main
134-
135-
- name: Parse architecture specific digest from image manifest
136-
id: image_manifest_metadata
137-
run: |
138-
IMAGE=${{ env.IMAGE_NAME }}:${{ needs.build-images.outputs.IMAGE_TAG_VERSION }}
139-
sha="$(regctl image digest "${IMAGE})"
140-
echo "sha=${sha}" >> $GITHUB_OUTPUT
141-
archs=${{ env.PLATFORMS }}
142-
for arch in $(echo "$archs" | sed -e 's/,/ /g'); do
143-
arch=${arch#*/}
144-
echo "Fetching digest for ${arch}..."
145-
sha="$(regctl image digest "${IMAGE}" --platform linux/${arch})"
146-
echo "${arch}_image_sha=${IMAGE}@${sha}"
147-
echo "${arch}_image_sha=${IMAGE}@${sha}" >> $GITHUB_OUTPUT
148-
done
149-
env:
150-
PLATFORMS: "linux/amd64" # Comma separated list of any platforms built
151-
152-
- name: Scan AMD64 Image digest
153-
if: ${{ steps.image_manifest_metadata.outputs.amd64_image_sha != '' }}
129+
- name: Scan the docker OCI Tar ball
154130
id: sbom_action_amd64
155-
uses: Kong/public-shared-actions/security-actions/scan-docker-image@556e4d9756442828427007a7171683a99adf9a6a
131+
uses: Kong/public-shared-actions/security-actions/scan-docker-image@2f02738ecb1670f01391162e43fe3f5d4e7942a1 # v2.2.2
156132
with:
157133
asset_prefix: image-${{ env.IMAGE_NAME }}-amd64
158-
image: ${{steps.image_manifest_metadata.outputs.image}}:${{ steps.image_manifest_metadata.outputs.amd64_image_sha }}
134+
image: ${{ env.DOCKER_OCI_ARCHIVE }}.tar
159135
upload-sbom-release-assets: true
160136

161137
release-images:
162-
name: Publish Images
163138
runs-on: ubuntu-latest
164139
permissions:
165140
contents: write
166-
packages: write # needed for signing the images
141+
packages: write # needed for publishing the images
142+
id-token: write # needed for keyless signing of the images
167143
needs: [check, build-images, scan-images]
168144
if: >
169145
github.repository_owner == 'Kong'
170-
&& github.event_name != 'pull_request'
171146
&& needs.scan-images.result == 'success'
147+
&& github.event_name != 'pull_request'
172148
env:
173149
IMAGE_TAGS: ${{ needs.build-images.outputs.image_tags }}
174-
IMAGE_MANIFEST_SHA: ${{ needs.scan-images.outputs.image_manifest_sha }}
150+
outputs:
151+
image_name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
152+
image_manifest_sha: ${{ steps.image_manifest_metadata.outputs.image_manifest_sha }}
153+
notary_repository: ${{ env.NOTARY_REPOSITORY }}
175154
steps:
176155

177156
- name: Download OCI docker TAR artifact
178157
uses: actions/download-artifact@v3
179158
with:
180159
name: ${{ env.DOCKER_OCI_ARCHIVE }}
181-
path: ${{ github.workspace }}/${{ env.DOCKER_OCI_ARCHIVE }}
160+
path: ${{ github.workspace }}
182161

183162
- name: Load OCI docker TAR artifact
184163
run: |
185-
docker load -i ${{ github.workspace }}/${{ env.DOCKER_OCI_ARCHIVE }}/${{ env.DOCKER_OCI_ARCHIVE }}.tar
164+
docker load -i ${{ github.workspace }}/${{ env.DOCKER_OCI_ARCHIVE }}.tar
186165
docker image ls
187166
188167
# Login against a Docker registry except on PR
@@ -198,21 +177,37 @@ jobs:
198177
id: publish_images
199178
run: |
200179
for tag in ${IMAGE_TAGS//,/ }; do \
201-
docker push $tag \
180+
docker push $tag; \
202181
done
203182
183+
# Setup regctl to parse platform specific image digest from image manifest
184+
- name: Install regctl
185+
uses: regclient/actions/regctl-installer@main
186+
187+
# The image manifest digest/sha is generated only after the image is published to registry
188+
- name: Parse architecture specific digest from image manifest
189+
id: image_manifest_metadata
190+
run: |
191+
IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-images.outputs.IMAGE_TAG_VERSION }}
192+
sha="$(regctl image digest "${IMAGE}")"
193+
echo "sha=${sha}" >> $GITHUB_OUTPUT
194+
195+
# Signing images requires image manifest digest
204196
- name: Sign images
205197
id: sign_images
206-
if: ${{ env.IMAGE_MANIFEST_SHA != '' }}
207-
uses: Kong/public-shared-actions/security-actions/sign-docker-image@556e4d9756442828427007a7171683a99adf9a6a # v2.2.1
198+
if: ${{ steps.image_manifest_metadata.outputs.sha != '' }}
199+
uses: Kong/public-shared-actions/security-actions/sign-docker-image@2f02738ecb1670f01391162e43fe3f5d4e7942a1 # v2.2.2
208200
with:
209-
image_digest: ${{ env.IMAGE_MANIFEST_SHA }}
201+
image_digest: ${{ steps.image_manifest_metadata.outputs.sha }}
210202
tags: ${{ env.IMAGE_TAGS }}
203+
image_registry_domain: ghcr.io
211204
registry_username: ${{ github.actor }}
212205
registry_password: ${{ secrets.GITHUB_TOKEN }}
213-
signature_registry_username: ${{ secrets.GHA_DOCKERHUB_PUSH_USER }}
214-
signature_registry_password: ${{ secrets.GHA_KONG_ORG_DOCKERHUB_PUSH_TOKEN }}
215-
signature_registry: ${{ env.NOTARY_REPOSITORY }}
206+
# Optional: Central notary repository for image signatures
207+
# signature_registry_domain: docker.io
208+
# signature_registry_username: ${{ secrets.GHA_DOCKERHUB_PUSH_USER }}
209+
# signature_registry_password: ${{ secrets.GHA_DOCKERHUB_PUSH_TOKEN }}
210+
# signature_registry: ${{ env.NOTARY_REPOSITORY }}
216211

217212
release-images-provenance:
218213
needs: ["check", "build-images", "scan-images", "release-images"]
@@ -224,11 +219,11 @@ jobs:
224219
actions: read # For getting workflow run info to build provenance
225220
packages: write # Required for publishing provenance. Issue: https://github.com/slsa-framework/slsa-github-generator/tree/main/internal/builders/container#known-issues
226221
with:
227-
image: ${{ needs.scan-images.outputs.image_name }} # Image repository without tag. Eg: kong/insomnia-mockbins
228-
digest: ${{ needs.scan-images.outputs.image_manifest_sha }} # Image manifest digest for the published docker image/TAR
229-
provenance-repository: ${{ needs.scan-images.outputs.notary_repository }}
222+
image: ${{ needs.release-images.outputs.image_name }} # Image repository without tag. Eg: kong/insomnia-mockbins
223+
digest: ${{ needs.release-images.outputs.image_manifest_sha }} # Image manifest digest for the published docker image/TAR
224+
#provenance-repository: ${{ needs.release-images.outputs.notary_repository }}
230225
secrets:
231226
registry-username: ${{ github.actor }}
232227
registry-password: ${{ secrets.GITHUB_TOKEN }}
233-
provenance-registry-username: ${{ secrets.GHA_DOCKERHUB_PUSH_USER }}
234-
provenance-registry-password: ${{ secrets.GHA_KONG_ORG_DOCKERHUB_PUSH_TOKEN }}
228+
# provenance-registry-username: ${{ secrets.GHA_DOCKERHUB_PUSH_USER }}
229+
# provenance-registry-password: ${{ secrets.GHA_KONG_ORG_DOCKERHUB_PUSH_TOKEN }}

.github/workflows/sast.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ jobs:
3030

3131
steps:
3232
- uses: actions/checkout@v4
33-
- uses: Kong/public-shared-actions/security-actions/semgrep@23929cfda574afc77b018c51794454b6dc99ca57 # v2.2.1
33+
- uses: Kong/public-shared-actions/security-actions/semgrep@2f02738ecb1670f01391162e43fe3f5d4e7942a1 # v2.2.2

README.md

+104-8
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ Insomnia Mockbin is used internally and maintained by [Kong](https://github.com/
66

77
## Table of contents
88

9-
- [Features](#features)
10-
- [Installation](#installation)
11-
- [Requirements](#requirements)
12-
- [Running with Node](#running-with-node)
9+
- [Insomnia Mockbin ](#insomnia-mockbin--)
10+
- [Table of contents](#table-of-contents)
11+
- [Features](#features)
12+
- [Installation](#installation)
13+
- [Requirements](#requirements)
14+
- [Running with Node](#running-with-node)
1315
- [Running with Docker Compose](#running-with-docker-compose)
14-
- [Documentation](#documentation)
15-
- [Bugs and feature requests](#bugs-and-feature-requests)
16-
- [Contributing](#contributing)
17-
- [License](#license)
16+
- [Documentation](#documentation)
17+
- [API Docs](#api-docs)
18+
- [Software Bill of materials](#software-bill-of-materials)
19+
- [Verify a container image siganture](#verify-a-container-image-siganture)
20+
- [Verify a container image provenance](#verify-a-container-image-provenance)
21+
- [Bugs and feature requests](#bugs-and-feature-requests)
22+
- [Contributing](#contributing)
23+
- [License](#license)
24+
- [TODO](#todo)
1825

1926
## Features
2027

@@ -67,8 +74,97 @@ docker compose up
6774

6875
## Documentation
6976

77+
### API Docs
78+
7079
Read the full API documentation, please review the [API Docs](https://github.com/Kong/mockbin/tree/master/docs).
7180

81+
### Software Bill of materials
82+
83+
Kong Insomnia Mockbin produces SBOMs for the below categories:
84+
85+
- For docker container images
86+
- For source code repository
87+
88+
The SBOMs are available to download at:
89+
90+
- Github Release / Tag Assets
91+
- Github workflow assets for other workflow runs
92+
93+
### Verify a container image siganture
94+
95+
Docker container images are now signed using cosign with signatures published to a [Github Container registry](https://ghcr.io) with `insomnia-mockbin` repository.
96+
97+
Steps to verify signatures for signed Kong Insomnia Mockbin Docker container images in two different ways:
98+
99+
A minimal example, used to verify an image without leveraging any annotations. For the minimal example, you only need Docker details, a GitHub repo name, and a GitHub workflow filename.
100+
101+
```code
102+
cosign verify \
103+
ghcr.io/kong/insomnia-mockbin:<tag>@sha256:<digest> \
104+
--certificate-oidc-issuer='https://token.actions.githubusercontent.com' \
105+
--certificate-identity-regexp='https://github.com/Kong/insomnia-mockbin/.github/workflows/release.yaml'
106+
```
107+
108+
A complete example, leveraging optional annotations for increased trust. For the complete example, you need the same details as the minimal example, as well as any of the optional annotations you wish to verify:
109+
110+
```code
111+
cosign verify \
112+
ghcr.io/kong/insomnia-mockbin:<tag>@sha256:<digest> \
113+
--certificate-oidc-issuer='https://token.actions.githubusercontent.com' \
114+
--certificate-identity-regexp='https://github.com/Kong/insomnia-mockbin/.github/workflows/release.yaml' \
115+
-a repo='Kong/insomnia-mockbin' \
116+
-a workflow='Package & Release'
117+
```
118+
119+
### Verify a container image provenance
120+
121+
Kong Insomnia Mockbin produces build provenance for docker container images for `Github tags`, which can be verified using cosign / slsa-verifier with attestations published to a [Github Container registry](https://ghcr.io) with `insomnia-mockbin` repository.
122+
123+
Steps to verify provenance for signed Kong Insomnia Mockbin Docker container images:
124+
125+
1. Fetch the image `<manifest_digest>` using regctl:
126+
127+
```code
128+
regctl image digest ghcr.io/kong/insomnia-mockbin:<tag>
129+
```
130+
131+
2. A minimal example, used to verify an image without leveraging any annotations. For the minimal example, you only need Docker Image manifest, a GitHub repo name.
132+
133+
```code
134+
cosign verify-attestation \
135+
ghcr.io/kong/insomnia-mockbin:<tag>@sha256:<manifest_digest> \
136+
--type='slsaprovenance' \
137+
--certificate-oidc-issuer='https://token.actions.githubusercontent.com' \
138+
--certificate-identity-regexp='^https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v[0-9]+.[0-9]+.[0-9]+$'
139+
```
140+
141+
```code
142+
slsa-verifier verify-image \
143+
ghcr.io/kong/insomnia-mockbin:<tag>@sha256:<manifest_digest> \
144+
--print-provenance \
145+
--source-uri 'github.com/Kong/insomnia-mockbin'
146+
```
147+
148+
3. A complete example, leveraging optional annotations for increased trust. For the complete example, you need the same details as the minimal example, as well as any of the optional annotations you wish to verify:
149+
150+
```code
151+
cosign verify-attestation \
152+
ghcr.io/kong/insomnia-mockbin:<tag>@sha256:<manifest_digest> \
153+
--type='slsaprovenance' \
154+
--certificate-oidc-issuer='https://token.actions.githubusercontent.com' \
155+
--certificate-identity-regexp='^https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v[0-9]+.[0-9]+.[0-9]+$' \
156+
--certificate-github-workflow-repository='Kong/insomnia-mockbin' \
157+
--certificate-github-workflow-name='Package & Release'
158+
```
159+
160+
```code
161+
slsa-verifier verify-image \
162+
ghcr.io/kong/insomnia-mockbin:<tag>@sha256:<manifest_digest> \
163+
--print-provenance \
164+
--source-uri 'github.com/Kong/insomnia-mockbin' \
165+
--source-tag '<tag>'
166+
```
167+
72168
## Bugs and feature requests
73169
74170
Have a bug or a feature request? Please first read the [issue guidelines](CONTRIBUTING.md#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](/issues).

0 commit comments

Comments
 (0)