Skip to content

Commit acc2559

Browse files
authored
chore: set explicit workflow permissions and pin down actions (#495)
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent 7192434 commit acc2559

6 files changed

Lines changed: 43 additions & 14 deletions

File tree

.github/workflows/create-github-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ on:
99
jobs:
1010
create-github-release:
1111
runs-on: ubuntu-24.04
12+
permissions:
13+
contents: write # needed to create releases and upload assets
1214

1315
steps:
1416
- name: Create a GitHub release
15-
uses: softprops/action-gh-release@v2
17+
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
1618
with:
1719
generate_release_notes: true
1820
draft: false

.github/workflows/find-vulnerabilities.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ on:
1010
jobs:
1111
scan-codebase:
1212
runs-on: ubuntu-24.04
13+
permissions:
14+
contents: read
15+
1316
name: Inspect packages with ScanCode.io
1417
steps:
15-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1619
with:
1720
path: scancode-inputs
1821
sparse-checkout: pyproject.toml
1922
sparse-checkout-cone-mode: false
23+
persist-credentials: false # do not keep the token around
2024

2125
- name: Fail on known vulnerabilities
22-
uses: aboutcode-org/scancode-action@main
26+
uses: aboutcode-org/scancode-action@8adbf888f487c3cdf6c15386035769cd03a94c66
2327
with:
2428
pipelines: "inspect_packages:StaticResolver,find_vulnerabilities"
2529
check-compliance: true

.github/workflows/pr-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-24.04
1515
name: Detects and automatically closes low-quality and AI slop PRs
1616
steps:
17-
- uses: peakoss/anti-slop@v0
17+
- uses: peakoss/anti-slop@e158eeefe5c43e1d3ba8533b84e0e35d9d6761de
1818
with:
1919
# Number of check failures needed before failure actions are triggered
2020
max-failures: 3

.github/workflows/publish-docker-image.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@ jobs:
2222
permissions:
2323
contents: read
2424
packages: write
25+
attestations: write
26+
id-token: write
2527

2628
steps:
2729
- name: Checkout repository
28-
uses: actions/checkout@v4
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
with:
32+
persist-credentials: false # do not keep the token around
2933

3034
# Uses the `docker/login-action` action to log in to the Container registry using
3135
# the account and password that will publish the packages.
3236
- name: Log in to the Container registry
33-
uses: docker/login-action@v3
37+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
3438
with:
3539
registry: ${{ env.REGISTRY }}
3640
username: ${{ github.actor }}
@@ -42,7 +46,7 @@ jobs:
4246
# The `images` value provides the base name for the tags and labels.
4347
- name: Extract metadata (tags, labels) for Docker
4448
id: meta
45-
uses: docker/metadata-action@v5
49+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
4650
with:
4751
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4852

@@ -53,11 +57,22 @@ jobs:
5357
# It uses the `tags` and `labels` parameters to tag and label the image with
5458
# the output from the "meta" step.
5559
- name: Build and push Docker image
56-
uses: docker/build-push-action@v5
60+
id: push
61+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
5762
with:
5863
context: .
5964
push: true
6065
tags: |
6166
${{ steps.meta.outputs.tags }}
6267
${{ env.REGISTRY }}/aboutcode-org/dejacode:latest
6368
labels: ${{ steps.meta.outputs.labels }}
69+
70+
# This step generates an artifact attestation for the image, which is an
71+
# unforgeable statement about where and how it was built.
72+
# It increases supply chain security for people who consume the image.
73+
- name: Generate artifact attestation
74+
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
75+
with:
76+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
77+
subject-digest: ${{ steps.push.outputs.digest }}
78+
push-to-registry: true

.github/workflows/run-unit-tests-docker.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ on:
1010
jobs:
1111
run-unit-tests:
1212
runs-on: ubuntu-24.04
13+
permissions:
14+
contents: read
1315

1416
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4
17+
- name: Checkout
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
persist-credentials: false # do not keep the token around
1721

1822
- name: Generate the .env file and the SECRET_KEY
1923
run: make envfile

.github/workflows/run-unit-tests.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ env:
1616
jobs:
1717
run-unit-tests:
1818
runs-on: ubuntu-24.04
19+
permissions:
20+
contents: read
1921

2022
services:
2123
postgres:
22-
image: postgres:16
24+
image: postgres:16.13
2325
env:
2426
POSTGRES_DB: ${{ env.DATABASE_NAME }}
2527
POSTGRES_USER: ${{ env.DATABASE_USER }}
@@ -35,10 +37,12 @@ jobs:
3537

3638
steps:
3739
- name: Checkout
38-
uses: actions/checkout@v4
40+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
41+
with:
42+
persist-credentials: false # do not keep the token around
3943

4044
- name: Set up Python
41-
uses: actions/setup-python@v5
45+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
4246
with:
4347
python-version: "3.14"
4448

@@ -59,7 +63,7 @@ jobs:
5963
run: make check
6064

6165
- name: Start Redis
62-
uses: supercharge/redis-github-action@1.8.1
66+
uses: supercharge/redis-github-action@bc274cb7238cd63a45029db04ee48c07a72609fd # v1.8.1
6367

6468
- name: Build the documentation
6569
run: make docs

0 commit comments

Comments
 (0)