Skip to content

Commit e62942d

Browse files
committed
ci: use commit hash for github action, add persist-credentials false [citest_skip]
The latest security guidance is to use the full commit hash, which is immutable, instead of a tag or version, which can be mutable, for the reference to a version of a github action. There are known attacks which inserted unauthorized code in a version tag and moved the tag. This prevents this sort of attack, at the cost of more maintenance burden, but dependabot will largely take care of this for us. Each version or tag has been replaced with the corresponding commit hash - in some cases, this is not the latest commit on the main branch, so I would expect to see some dependabot updates in the near future. I thought it was safer to do it this way - preserve existing behavior/functionality - rather than replace and upgrade to a newer version at the same time. The coderabbit `Pin the Galaxy action's container image.` issue is tracked at robertdebock/galaxy-action#16 This also adds `persist-credentials: false` to the actions/checkout tasks so that any credentials used by that task will not persist for subsequent tasks, for those workflows that do not need the credentials for subsequent tasks. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent 17af6aa commit e62942d

14 files changed

Lines changed: 63 additions & 38 deletions

.github/workflows/ansible-lint.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ jobs:
3939
sudo apt install -y git
4040
4141
- name: Checkout repo
42-
uses: actions/checkout@v7
42+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
43+
with:
44+
persist-credentials: false
4345

4446
- name: Install tox, tox-lsr
4547
run: |
4648
set -euxo pipefail
47-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.20.1"
49+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496"
4850
4951
- name: Set up Python
50-
uses: actions/setup-python@v7
52+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
5153
with:
5254
python-version: ${{ matrix.versions.python }}
5355

.github/workflows/ansible-managed-var-comment.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ jobs:
2828
sudo apt install -y git
2929
3030
- name: Checkout repo
31-
uses: actions/checkout@v7
31+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
32+
with:
33+
persist-credentials: false
3234

3335
- name: Install tox, tox-lsr
3436
run: |
3537
set -euxo pipefail
36-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.20.1"
38+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496"
3739
3840
- name: Run ansible-plugin-scan
3941
run: |

.github/workflows/ansible-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ jobs:
4242
sudo apt install -y git
4343
4444
- name: Checkout repo
45-
uses: actions/checkout@v7
45+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
46+
with:
47+
persist-credentials: false
4648

4749
- name: Install tox, tox-lsr
4850
run: |
4951
set -euxo pipefail
50-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.20.1"
52+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496"
5153
5254
- name: Set up Python
53-
uses: actions/setup-python@v7
55+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
5456
with:
5557
python-version: ${{ matrix.versions.python }}
5658

.github/workflows/build_docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
sudo apt install -y git
2626
2727
- name: Check out code
28-
uses: actions/checkout@v7
28+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
2929
with:
3030
fetch-depth: 0
3131
- name: Ensure the docs branch
@@ -48,12 +48,12 @@ jobs:
4848
fi
4949
5050
- name: Checkout the docs branch
51-
uses: actions/checkout@v7
51+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
5252
with:
5353
ref: docs
5454

5555
- name: Fetch README.md and .pandoc_template.html5 template from the workflow branch
56-
uses: actions/checkout@v7
56+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
5757
with:
5858
sparse-checkout: |
5959
README.md

.github/workflows/changelog_to_tag.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
sudo apt install -y git
2323
2424
- name: checkout PR
25-
uses: actions/checkout@v7
25+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
26+
with:
27+
persist-credentials: false
2628

2729
- name: Get tag and message from the latest CHANGELOG.md commit
2830
id: tag
@@ -69,23 +71,23 @@ jobs:
6971
echo "tagname=$_tagname" >> "$GITHUB_OUTPUT"
7072
echo "branch=$_branch" >> "$GITHUB_OUTPUT"
7173
- name: Create tag
72-
uses: mathieudutour/github-tag-action@v6.2
74+
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
7375
with:
7476
github_token: ${{ secrets.GITHUB_TOKEN }}
7577
custom_tag: ${{ steps.tag.outputs.tagname }}
7678
tag_prefix: ''
7779

7880
- name: Create Release
7981
id: create_release
80-
uses: ncipollo/release-action@v1
82+
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1
8183
with:
8284
tag: ${{ steps.tag.outputs.tagname }}
8385
name: Version ${{ steps.tag.outputs.tagname }}
8486
bodyFile: ./.tagmsg.txt
8587
makeLatest: true
8688

8789
- name: Publish role to Galaxy
88-
uses: robertdebock/galaxy-action@1.2.1
90+
uses: robertdebock/galaxy-action@7d89099e09f4385ec4b53eb58c0d120f1ad806dd # 1.2.1
8991
with:
9092
galaxy_api_key: ${{ secrets.galaxy_api_key }}
9193
git_branch: ${{ steps.tag.outputs.branch }}

.github/workflows/codespell.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v7
16+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
17+
with:
18+
persist-credentials: false
1719

1820
- name: Codespell
19-
uses: codespell-project/actions-codespell@v2
21+
uses: codespell-project/actions-codespell@406322ec52dd7b488e48c1c4b82e2a8b3a1bf630 # v2

.github/workflows/markdownlint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
sudo apt install -y git
2929
3030
- name: Check out code
31-
uses: actions/checkout@v7
31+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
32+
with:
33+
persist-credentials: false
3234

3335
# CHANGELOG.md is generated automatically from PR titles and descriptions
3436
# It might have issues but they are not critical

.github/workflows/pr-title-lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ jobs:
1818
commit-checks:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v7
21+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
2222
with:
23+
persist-credentials: false
2324
fetch-depth: 0
2425

2526
- name: Install pr_title_lint.py

.github/workflows/qemu-kvm-integration-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ jobs:
5252

5353
steps:
5454
- name: Checkout repo
55-
uses: actions/checkout@v7
55+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
56+
with:
57+
persist-credentials: false
5658

5759
- name: Check if platform is supported
5860
id: check_platform
@@ -111,7 +113,7 @@ jobs:
111113
python3 -m pip install --upgrade pip
112114
sudo apt update
113115
sudo apt install -y --no-install-recommends git ansible-core genisoimage qemu-system-x86
114-
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.20.1"
116+
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496"
115117
116118
- name: Check for podman version 5 or higher
117119
id: check_podman_version
@@ -128,7 +130,7 @@ jobs:
128130
129131
- name: Ensure use of podman 5
130132
if: steps.check_platform.outputs.supported && steps.check_podman_version.outputs.need_podman_update == 1
131-
uses: redhat-actions/podman-install@main
133+
uses: redhat-actions/podman-install@3b6c60c447c93960c0b76faa0c66c6694bc71350 # main
132134

133135
- name: Configure tox-lsr
134136
if: steps.check_platform.outputs.supported
@@ -212,7 +214,7 @@ jobs:
212214
213215
- name: Upload test logs on failure
214216
if: failure()
215-
uses: actions/upload-artifact@v7
217+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
216218
with:
217219
name: "logs-${{ matrix.scenario.image }}-${{ matrix.scenario.env }}"
218220
path: |
@@ -238,7 +240,7 @@ jobs:
238240
239241
- name: Set commit status as success with a description that platform is skipped
240242
if: ${{ steps.check_platform.outputs.supported == '' }}
241-
uses: myrotvorets/set-commit-status-action@master
243+
uses: myrotvorets/set-commit-status-action@2774e1f040c82ed70a76b4b5cd53bb11ffaedd0a # master
242244
with:
243245
status: success
244246
context: "${{ github.workflow }} / scenario (${{ matrix.scenario.image }}, ${{ matrix.scenario.env }}) (pull_request)"

.github/workflows/shellcheck.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ jobs:
3030
sudo apt install -y git
3131
3232
- name: Checkout repo
33-
uses: actions/checkout@v7
33+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
34+
with:
35+
persist-credentials: false
3436

3537
- name: Run ShellCheck
3638
id: shellcheck_id
37-
uses: ludeeus/action-shellcheck@master
39+
uses: ludeeus/action-shellcheck@00b27aa7cb85167568cb48a3838b75f4265f2bca # master
3840

3941
- name: Show file paths scanned
4042
run: |

0 commit comments

Comments
 (0)