Skip to content

Commit f41bcbd

Browse files
[StepSecurity] ci: Harden GitHub Actions (#309)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io> Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
1 parent 6520a4d commit f41bcbd

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
go_path: ${{ steps.vars.outputs.go_path }}
3737
steps:
3838
- name: Checkout Repository
39-
uses: actions/checkout@v3
39+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
4040
- name: Setup Golang Environment
41-
uses: actions/setup-go@v3
41+
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
4242
with:
4343
go-version-file: go.mod
4444
cache: true
@@ -56,16 +56,16 @@ jobs:
5656
needs: vars
5757
steps:
5858
- name: Checkout Repository
59-
uses: actions/checkout@v3
59+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
6060
- name: Setup Golang Environment
61-
uses: actions/setup-go@v3
61+
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
6262
with:
6363
go-version-file: go.mod
6464
cache: true
6565
- name: Run Tests
6666
run: make unit-test
6767
- name: Upload Coverage Report
68-
uses: actions/upload-artifact@v3
68+
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
6969
with:
7070
name: cover-${{ github.run_id }}.html
7171
path: ${{ github.workspace }}/cover.html
@@ -77,9 +77,9 @@ jobs:
7777
needs: vars
7878
steps:
7979
- name: Checkout Repository
80-
uses: actions/checkout@v3
80+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
8181
- name: Setup Node.js Environment
82-
uses: actions/setup-node@v3
82+
uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
8383
with:
8484
node-version: 18
8585
- run: npm --prefix ${{ github.workspace }}/internal/nginx/modules install
@@ -91,17 +91,17 @@ jobs:
9191
needs: vars
9292
steps:
9393
- name: Checkout Repository
94-
uses: actions/checkout@v3
94+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
9595
with:
9696
fetch-depth: 0
9797
- name: Setup Golang Environment
98-
uses: actions/setup-go@v3
98+
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
9999
with:
100100
go-version-file: go.mod
101101
cache: true
102102

103103
- name: Publish release on tag
104-
uses: actions/github-script@v6
104+
uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
105105
continue-on-error: true
106106
with:
107107
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -127,11 +127,11 @@ jobs:
127127
if: startsWith(github.ref, 'refs/tags/')
128128

129129
- name: Download Syft
130-
uses: anchore/sbom-action/download-syft@v0.13.1
130+
uses: anchore/sbom-action/download-syft@06e109483e6aa305a2b2395eabae554e51530e1d # v0.13.1
131131
if: startsWith(github.ref, 'refs/tags/')
132132

133133
- name: Build binary
134-
uses: goreleaser/goreleaser-action@v3
134+
uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 # v3.2.0
135135
with:
136136
version: latest
137137
args: ${{ startsWith(github.ref, 'refs/tags/') && 'release' || 'build --snapshot' }} --rm-dist
@@ -143,7 +143,7 @@ jobs:
143143
AZURE_BUCKET_NAME: ${{ secrets.AZURE_BUCKET_NAME }}
144144

145145
- name: Cache Artifacts
146-
uses: actions/cache@v3
146+
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
147147
with:
148148
path: ${{ github.workspace }}/dist
149149
key: nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
@@ -154,28 +154,28 @@ jobs:
154154
needs: [vars, binary]
155155
steps:
156156
- name: Checkout Repository
157-
uses: actions/checkout@v3
157+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
158158
- name: Fetch Cached Artifacts
159-
uses: actions/cache@v3
159+
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
160160
with:
161161
path: ${{ github.workspace }}/dist
162162
key: nginx-kubernetes-gateway-${{ github.run_id }}-${{ github.run_number }}
163163
- name: Docker Buildx
164-
uses: docker/setup-buildx-action@v2
164+
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # v2.2.1
165165
- name: Setup QEMU
166-
uses: docker/setup-qemu-action@v2
166+
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
167167
with:
168168
platforms: arm64
169169
- name: Login to GitHub Container Registry
170-
uses: docker/login-action@v2
170+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
171171
if: ${{ github.event_name != 'pull_request' }}
172172
with:
173173
registry: ghcr.io
174174
username: ${{ github.repository_owner }}
175175
password: ${{ secrets.GITHUB_TOKEN }}
176176
- name: Docker meta
177177
id: meta
178-
uses: docker/metadata-action@v4
178+
uses: docker/metadata-action@57396166ad8aefe6098280995947635806a0e6ea # v4.1.1
179179
with:
180180
images: |
181181
name=ghcr.io/nginxinc/nginx-kubernetes-gateway
@@ -186,7 +186,7 @@ jobs:
186186
type=ref,event=branch,suffix=-rc,enable=${{ startsWith(github.ref, 'refs/heads/release') }}
187187
188188
- name: Build Docker Image
189-
uses: docker/build-push-action@v3
189+
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 # v3.2.0
190190
with:
191191
file: build/Dockerfile
192192
context: '.'
@@ -202,20 +202,20 @@ jobs:
202202
no-cache: ${{ github.event_name != 'pull_request' }}
203203

204204
- name: Run Trivy vulnerability scanner
205-
uses: aquasecurity/trivy-action@0.8.0
205+
uses: aquasecurity/trivy-action@9ab158e8597f3b310480b9a69402b419bc03dbd5 # 0.8.0
206206
continue-on-error: true
207207
with:
208208
image-ref: ghcr.io/nginxinc/nginx-kubernetes-gateway:${{ steps.meta.outputs.version }}
209209
format: 'sarif'
210210
output: 'trivy-results-nginx-kubernetes-gateway.sarif'
211211
ignore-unfixed: 'true'
212212
- name: Upload Trivy scan results to GitHub Security tab
213-
uses: github/codeql-action/upload-sarif@v2
213+
uses: github/codeql-action/upload-sarif@678fc3afe258fb2e0cdc165ccf77b85719de7b3c # v2.1.33
214214
continue-on-error: true
215215
with:
216216
sarif_file: 'trivy-results-nginx-kubernetes-gateway.sarif'
217217
- name: Upload Scan Results
218-
uses: actions/upload-artifact@v3
218+
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
219219
continue-on-error: true
220220
with:
221221
name: 'trivy-results-nginx-kubernetes-gateway.sarif'

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v2
45+
uses: github/codeql-action/init@678fc3afe258fb2e0cdc165ccf77b85719de7b3c # v2.1.33
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
5353
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5454
# If this step fails, then you should remove it and run the build manually (see below)
5555
- name: Autobuild
56-
uses: github/codeql-action/autobuild@v2
56+
uses: github/codeql-action/autobuild@678fc3afe258fb2e0cdc165ccf77b85719de7b3c # v2.1.33
5757

5858
# ℹ️ Command-line programs to run using the OS shell.
5959
# 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
6767
# make release
6868

6969
- name: Perform CodeQL Analysis
70-
uses: github/codeql-action/analyze@v2
70+
uses: github/codeql-action/analyze@678fc3afe258fb2e0cdc165ccf77b85719de7b3c # v2.1.33

.github/workflows/fossa.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
runs-on: ubuntu-20.04
1919
steps:
2020
- name: Checkout Repository
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
2222
- name: Scan
23-
uses: fossas/fossa-action@v1
23+
uses: fossas/fossa-action@f61a4c0c263690f2ddb54b9822a719c25a7b608f # v1.3.1
2424
with:
2525
api-key: ${{ secrets.FOSSA_TOKEN }}

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ jobs:
2727
runs-on: ubuntu-20.04
2828
steps:
2929
- name: Checkout Repository
30-
uses: actions/checkout@v3
30+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
3131
- name: Setup Golang Environment
32-
uses: actions/setup-go@v3
32+
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
3333
with:
3434
go-version-file: go.mod
3535
- name: Lint Code
36-
uses: golangci/golangci-lint-action@v3.3.1
36+
uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3.3.1
3737
with:
3838
args: --timeout 10m0s
3939
only-new-issues: true
@@ -43,10 +43,10 @@ jobs:
4343
runs-on: ubuntu-20.04
4444
steps:
4545
- name: Checkout Repository
46-
uses: actions/checkout@v2
46+
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
4747
- name: Run Prettier on NJS code
4848
id: prettier-run
49-
uses: rutajdash/prettier-cli-action@v1.0.0
49+
uses: rutajdash/prettier-cli-action@30325c923a7b131ab8b6c99e0aff38afaddb9643 # v1.0.0
5050
with:
5151
config_path: ${{ github.workspace }}/internal/nginx/modules/.prettierrc
5252
file_pattern: ${{ github.workspace }}/internal/nginx/modules/**/*.js

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
name: Create Draft Release
2626
runs-on: ubuntu-20.04
2727
steps:
28-
- uses: actions/setup-node@v3
28+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3.5.1
2929
- run: npm install semver
30-
- uses: actions/github-script@v6
30+
- uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
3131
continue-on-error: true
3232
with:
3333
script: |

0 commit comments

Comments
 (0)