Skip to content

Commit a02fb0f

Browse files
authored
Update workflows and enhance security (#5537)
This commit updates the workflow files and also fixes some security issues which were reported by using zizmor https://github.com/woodruffw/zizmor Signed-off-by: BlackDex <[email protected]>
1 parent 1109293 commit a02fb0f

File tree

5 files changed

+134
-81
lines changed

5 files changed

+134
-81
lines changed

.github/workflows/build.yml

+46-30
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Build
2+
permissions: {}
23

34
on:
45
push:
@@ -13,6 +14,7 @@ on:
1314
- "diesel.toml"
1415
- "docker/Dockerfile.j2"
1516
- "docker/DockerSettings.yaml"
17+
1618
pull_request:
1719
paths:
1820
- ".github/workflows/build.yml"
@@ -28,34 +30,37 @@ on:
2830

2931
jobs:
3032
build:
33+
name: Build and Test ${{ matrix.channel }}
34+
permissions:
35+
actions: write
36+
contents: read
3137
# We use Ubuntu 22.04 here because this matches the library versions used within the Debian docker containers
3238
runs-on: ubuntu-22.04
3339
timeout-minutes: 120
3440
# Make warnings errors, this is to prevent warnings slipping through.
3541
# This is done globally to prevent rebuilds when the RUSTFLAGS env variable changes.
3642
env:
37-
RUSTFLAGS: "-D warnings"
43+
RUSTFLAGS: "-Dwarnings"
3844
strategy:
3945
fail-fast: false
4046
matrix:
4147
channel:
4248
- "rust-toolchain" # The version defined in rust-toolchain
4349
- "msrv" # The supported MSRV
4450

45-
name: Build and Test ${{ matrix.channel }}
46-
4751
steps:
48-
# Checkout the repo
49-
- name: "Checkout"
50-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
51-
# End Checkout the repo
52-
53-
5452
# Install dependencies
5553
- name: "Install dependencies Ubuntu"
5654
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends openssl build-essential libmariadb-dev-compat libpq-dev libssl-dev pkg-config
5755
# End Install dependencies
5856

57+
# Checkout the repo
58+
- name: "Checkout"
59+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
60+
with:
61+
persist-credentials: false
62+
fetch-depth: 0
63+
# End Checkout the repo
5964

6065
# Determine rust-toolchain version
6166
- name: Init Variables
@@ -75,7 +80,7 @@ jobs:
7580

7681
# Only install the clippy and rustfmt components on the default rust-toolchain
7782
- name: "Install rust-toolchain version"
78-
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # master @ Dec 14, 2024, 5:49 AM GMT+1
83+
uses: dtolnay/rust-toolchain@c5a29ddb4d9d194e7c84ec8c3fba61b1c31fee8c # master @ Jan 30, 2025, 8:16 PM GMT+1
7984
if: ${{ matrix.channel == 'rust-toolchain' }}
8085
with:
8186
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
@@ -85,19 +90,21 @@ jobs:
8590

8691
# Install the any other channel to be used for which we do not execute clippy and rustfmt
8792
- name: "Install MSRV version"
88-
uses: dtolnay/rust-toolchain@a54c7afa936fefeb4456b2dd8068152669aa8203 # master @ Dec 14, 2024, 5:49 AM GMT+1
93+
uses: dtolnay/rust-toolchain@c5a29ddb4d9d194e7c84ec8c3fba61b1c31fee8c # master @ Jan 30, 2025, 8:16 PM GMT+1
8994
if: ${{ matrix.channel != 'rust-toolchain' }}
9095
with:
9196
toolchain: "${{steps.toolchain.outputs.RUST_TOOLCHAIN}}"
9297
# End Install the MSRV channel to be used
9398

9499
# Set the current matrix toolchain version as default
95100
- name: "Set toolchain ${{steps.toolchain.outputs.RUST_TOOLCHAIN}} as default"
101+
env:
102+
RUST_TOOLCHAIN: ${{steps.toolchain.outputs.RUST_TOOLCHAIN}}
96103
run: |
97104
# Remove the rust-toolchain.toml
98105
rm rust-toolchain.toml
99106
# Set the default
100-
rustup default ${{steps.toolchain.outputs.RUST_TOOLCHAIN}}
107+
rustup default "${RUST_TOOLCHAIN}"
101108
102109
# Show environment
103110
- name: "Show environment"
@@ -161,7 +168,7 @@ jobs:
161168
id: clippy
162169
if: ${{ !cancelled() && matrix.channel == 'rust-toolchain' }}
163170
run: |
164-
cargo clippy --features sqlite,mysql,postgresql,enable_mimalloc -- -D warnings
171+
cargo clippy --features sqlite,mysql,postgresql,enable_mimalloc
165172
# End Run cargo clippy
166173

167174

@@ -178,22 +185,31 @@ jobs:
178185
# This is useful so all test/clippy/fmt actions are done, and they can all be addressed
179186
- name: "Some checks failed"
180187
if: ${{ failure() }}
188+
env:
189+
TEST_DB_M_L: ${{ steps.test_sqlite_mysql_postgresql_mimalloc_logger.outcome }}
190+
TEST_DB_M: ${{ steps.test_sqlite_mysql_postgresql_mimalloc.outcome }}
191+
TEST_DB: ${{ steps.test_sqlite_mysql_postgresql.outcome }}
192+
TEST_SQLITE: ${{ steps.test_sqlite.outcome }}
193+
TEST_MYSQL: ${{ steps.test_mysql.outcome }}
194+
TEST_POSTGRESQL: ${{ steps.test_postgresql.outcome }}
195+
CLIPPY: ${{ steps.clippy.outcome }}
196+
FMT: ${{ steps.formatting.outcome }}
181197
run: |
182-
echo "### :x: Checks Failed!" >> $GITHUB_STEP_SUMMARY
183-
echo "" >> $GITHUB_STEP_SUMMARY
184-
echo "|Job|Status|" >> $GITHUB_STEP_SUMMARY
185-
echo "|---|------|" >> $GITHUB_STEP_SUMMARY
186-
echo "|test (sqlite,mysql,postgresql,enable_mimalloc,query_logger)|${{ steps.test_sqlite_mysql_postgresql_mimalloc_logger.outcome }}|" >> $GITHUB_STEP_SUMMARY
187-
echo "|test (sqlite,mysql,postgresql,enable_mimalloc)|${{ steps.test_sqlite_mysql_postgresql_mimalloc.outcome }}|" >> $GITHUB_STEP_SUMMARY
188-
echo "|test (sqlite,mysql,postgresql)|${{ steps.test_sqlite_mysql_postgresql.outcome }}|" >> $GITHUB_STEP_SUMMARY
189-
echo "|test (sqlite)|${{ steps.test_sqlite.outcome }}|" >> $GITHUB_STEP_SUMMARY
190-
echo "|test (mysql)|${{ steps.test_mysql.outcome }}|" >> $GITHUB_STEP_SUMMARY
191-
echo "|test (postgresql)|${{ steps.test_postgresql.outcome }}|" >> $GITHUB_STEP_SUMMARY
192-
echo "|clippy (sqlite,mysql,postgresql,enable_mimalloc)|${{ steps.clippy.outcome }}|" >> $GITHUB_STEP_SUMMARY
193-
echo "|fmt|${{ steps.formatting.outcome }}|" >> $GITHUB_STEP_SUMMARY
194-
echo "" >> $GITHUB_STEP_SUMMARY
195-
echo "Please check the failed jobs and fix where needed." >> $GITHUB_STEP_SUMMARY
196-
echo "" >> $GITHUB_STEP_SUMMARY
198+
echo "### :x: Checks Failed!" >> "${GITHUB_STEP_SUMMARY}"
199+
echo "" >> "${GITHUB_STEP_SUMMARY}"
200+
echo "|Job|Status|" >> "${GITHUB_STEP_SUMMARY}"
201+
echo "|---|------|" >> "${GITHUB_STEP_SUMMARY}"
202+
echo "|test (sqlite,mysql,postgresql,enable_mimalloc,query_logger)|${TEST_DB_M_L}|" >> "${GITHUB_STEP_SUMMARY}"
203+
echo "|test (sqlite,mysql,postgresql,enable_mimalloc)|${TEST_DB_M}|" >> "${GITHUB_STEP_SUMMARY}"
204+
echo "|test (sqlite,mysql,postgresql)|${TEST_DB}|" >> "${GITHUB_STEP_SUMMARY}"
205+
echo "|test (sqlite)|${TEST_SQLITE}|" >> "${GITHUB_STEP_SUMMARY}"
206+
echo "|test (mysql)|${TEST_MYSQL}|" >> "${GITHUB_STEP_SUMMARY}"
207+
echo "|test (postgresql)|${TEST_POSTGRESQL}|" >> "${GITHUB_STEP_SUMMARY}"
208+
echo "|clippy (sqlite,mysql,postgresql,enable_mimalloc)|${CLIPPY}|" >> "${GITHUB_STEP_SUMMARY}"
209+
echo "|fmt|${FMT}|" >> "${GITHUB_STEP_SUMMARY}"
210+
echo "" >> "${GITHUB_STEP_SUMMARY}"
211+
echo "Please check the failed jobs and fix where needed." >> "${GITHUB_STEP_SUMMARY}"
212+
echo "" >> "${GITHUB_STEP_SUMMARY}"
197213
exit 1
198214
199215
@@ -202,5 +218,5 @@ jobs:
202218
- name: "All checks passed"
203219
if: ${{ success() }}
204220
run: |
205-
echo "### :tada: Checks Passed!" >> $GITHUB_STEP_SUMMARY
206-
echo "" >> $GITHUB_STEP_SUMMARY
221+
echo "### :tada: Checks Passed!" >> "${GITHUB_STEP_SUMMARY}"
222+
echo "" >> "${GITHUB_STEP_SUMMARY}"

.github/workflows/hadolint.yml

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
name: Hadolint
2+
permissions: {}
23

3-
on: [
4-
push,
5-
pull_request
6-
]
4+
on: [ push, pull_request ]
75

86
jobs:
97
hadolint:
108
name: Validate Dockerfile syntax
9+
permissions:
10+
contents: read
1111
runs-on: ubuntu-24.04
1212
timeout-minutes: 30
13-
steps:
14-
# Checkout the repo
15-
- name: Checkout
16-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
17-
# End Checkout the repo
1813

14+
steps:
1915
# Start Docker Buildx
2016
- name: Setup Docker Buildx
2117
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
@@ -37,6 +33,12 @@ jobs:
3733
env:
3834
HADOLINT_VERSION: 2.12.0
3935
# End Download hadolint
36+
# Checkout the repo
37+
- name: Checkout
38+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
39+
with:
40+
persist-credentials: false
41+
# End Checkout the repo
4042

4143
# Test Dockerfiles with hadolint
4244
- name: Run hadolint

0 commit comments

Comments
 (0)