Skip to content

Commit f1e8d05

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 c7f003f commit f1e8d05

15 files changed

Lines changed: 71 additions & 44 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/codeql.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ jobs:
3434
sudo apt update
3535
sudo apt install -y git
3636
- name: Checkout
37-
uses: actions/checkout@v7
37+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
38+
with:
39+
persist-credentials: false
3840

3941
- name: Initialize CodeQL
40-
uses: github/codeql-action/init@v4.37.4
42+
uses: github/codeql-action/init@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
4143
with:
4244
languages: ${{ matrix.language }}
4345
queries: +security-and-quality
4446

4547
- name: Autobuild
46-
uses: github/codeql-action/autobuild@v4.37.4
48+
uses: github/codeql-action/autobuild@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
4749

4850
- name: Perform CodeQL Analysis
49-
uses: github/codeql-action/analyze@v4.37.4
51+
uses: github/codeql-action/analyze@f205ea1c3313d32999d8d6a48b4f6530d4437b38 # v4.37.4
5052
with:
5153
category: "/language:${{ matrix.language }}"

.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/python-unit-test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ jobs:
4343
sudo apt install -y git
4444
4545
- name: checkout PR
46-
uses: actions/checkout@v7
46+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
47+
with:
48+
persist-credentials: false
4749

4850
- name: Set up Python 2.7
4951
if: ${{ matrix.pyver_os.ver == '2.7' }}
@@ -53,7 +55,7 @@ jobs:
5355
5456
- name: Set up Python 3
5557
if: ${{ matrix.pyver_os.ver != '2.7' }}
56-
uses: actions/setup-python@v7
58+
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
5759
with:
5860
python-version: ${{ matrix.pyver_os.ver }}
5961

@@ -70,7 +72,7 @@ jobs:
7072
tox=tox
7173
virtualenv=virtualenv
7274
fi
73-
pip install "$tox" "$virtualenv" "git+https://github.com/linux-system-roles/tox-lsr@3.20.1"
75+
pip install "$tox" "$virtualenv" "git+https://github.com/linux-system-roles/tox-lsr@d594be24ed56e586a5796720d51c261e40c20496"
7476
# If you have additional OS dependency packages e.g. libcairo2-dev
7577
# then put them in .github/config/ubuntu-requirements.txt, one
7678
# package per line.
@@ -92,4 +94,4 @@ jobs:
9294
TOXENV="$toxenvs" lsr_ci_runtox
9395
9496
- name: Upload coverage reports to Codecov
95-
uses: codecov/codecov-action@v7
97+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7

0 commit comments

Comments
 (0)