Skip to content

Commit cdb3cda

Browse files
[StepSecurity] ci: Harden GitHub Actions
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
1 parent 3dbe17c commit cdb3cda

10 files changed

+127
-47
lines changed

.github/workflows/codacy-analysis.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
# Checkout the repository to the GitHub Actions runner
31+
- name: Harden the runner (Audit all outbound calls)
32+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
33+
with:
34+
egress-policy: audit
35+
3136
- name: Checkout code
32-
uses: actions/checkout@v4
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3338

3439
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
3540
- name: Run Codacy Analysis CLI
3641
continue-on-error: true
37-
uses: codacy/codacy-analysis-cli-action@v4.4.5
42+
uses: codacy/codacy-analysis-cli-action@97bf5df3c09e75f5bcd72695998f96ebd701846e # v4.4.5
3843
with:
3944
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
4045
# You can also omit the token and run the tools that support default configurations
@@ -51,6 +56,6 @@ jobs:
5156
# Upload the SARIF file generated in the previous step
5257
- name: Upload SARIF results file
5358
continue-on-error: true
54-
uses: github/codeql-action/upload-sarif@v3
59+
uses: github/codeql-action/upload-sarif@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
5560
with:
5661
sarif_file: results.sarif

.github/workflows/codeql.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,17 @@ jobs:
4242
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4343

4444
steps:
45+
- name: Harden the runner (Audit all outbound calls)
46+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
47+
with:
48+
egress-policy: audit
49+
4550
- name: Checkout repository
46-
uses: actions/checkout@v4
51+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4752

4853
# Initializes the CodeQL tools for scanning.
4954
- name: Initialize CodeQL
50-
uses: github/codeql-action/init@v3
55+
uses: github/codeql-action/init@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
5156
with:
5257
languages: ${{ matrix.language }}
5358
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -61,7 +66,7 @@ jobs:
6166
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6267
# If this step fails, then you should remove it and run the build manually (see below)
6368
- name: Autobuild
64-
uses: github/codeql-action/autobuild@v3
69+
uses: github/codeql-action/autobuild@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
6570

6671
# ℹ️ Command-line programs to run using the OS shell.
6772
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -74,6 +79,6 @@ jobs:
7479
# ./location_of_script_within_repo/buildscript.sh
7580

7681
- name: Perform CodeQL Analysis
77-
uses: github/codeql-action/analyze@v3
82+
uses: github/codeql-action/analyze@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
7883
with:
7984
category: "/language:${{matrix.language}}"

.github/workflows/greetings.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ jobs:
1010
greeting:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/first-interaction@v1
13+
- name: Harden the runner (Audit all outbound calls)
14+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
15+
with:
16+
egress-policy: audit
17+
18+
- uses: actions/first-interaction@3c71ce730280171fd1cfb57c00c774f8998586f7 # v1
1419
continue-on-error: true
1520
with:
1621
repo-token: ${{ secrets.PAT_TOKEN }}

.github/workflows/issue-comment-job-example.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ jobs:
1313
if: ${{ github.event.issue.pull_request }}
1414
runs-on: ubuntu-latest
1515
steps:
16+
- name: Harden the runner (Audit all outbound calls)
17+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
18+
with:
19+
egress-policy: audit
20+
1621
- run: |
1722
echo A comment on PR $NUMBER
1823
env:
1924
NUMBER: ${{ github.event.issue.number }}
2025
2126
- name: Checkout
22-
uses: actions/checkout@v4
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2328
with:
2429
submodules: true
2530
fetch-depth: 0
@@ -98,13 +103,18 @@ jobs:
98103
if: ${{ !github.event.issue.pull_request }}
99104
runs-on: ubuntu-latest
100105
steps:
106+
- name: Harden the runner (Audit all outbound calls)
107+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
108+
with:
109+
egress-policy: audit
110+
101111
- run: |
102112
echo A comment on issue $NUMBER
103113
env:
104114
NUMBER: ${{ github.event.issue.number }}
105115
106116
- name: Checkout
107-
uses: actions/checkout@v4
117+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
108118
with:
109119
submodules: true
110120
fetch-depth: 0

.github/workflows/manual-triggered-job-example.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ jobs:
1717
platform: [ubuntu-latest, windows-latest, macos-latest]
1818

1919
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
22+
with:
23+
egress-policy: audit
24+
2025
- name: Checkout
21-
uses: actions/checkout@v4
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2227
with:
2328
submodules: true
2429
fetch-depth: 0

.github/workflows/matrix-example.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ jobs:
1616
outputs:
1717
matrix: ${{ steps.changed-files.outputs.all_changed_files }}
1818
steps:
19+
- name: Harden the runner (Audit all outbound calls)
20+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
21+
with:
22+
egress-policy: audit
23+
1924
- name: Checkout
20-
uses: actions/checkout@v4
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2126
with:
2227
fetch-depth: 0
2328
- name: Get changed files
@@ -38,8 +43,13 @@ jobs:
3843
max-parallel: 4
3944
fail-fast: false
4045
steps:
46+
- name: Harden the runner (Audit all outbound calls)
47+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
48+
with:
49+
egress-policy: audit
50+
4151
- name: Checkout
42-
uses: actions/checkout@v4
52+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4353
- name: Test
4454
run: |
4555
echo ${{ matrix.files }}

.github/workflows/multi-job-example.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ jobs:
1818
outputs:
1919
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
2020
steps:
21+
- name: Harden the runner (Audit all outbound calls)
22+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
23+
with:
24+
egress-policy: audit
25+
2126
- name: Checkout
22-
uses: actions/checkout@v4
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2328
with:
2429
fetch-depth: 0
2530
- name: Get changed files
@@ -33,6 +38,11 @@ jobs:
3338
runs-on: ubuntu-latest
3439
needs: [changed-files]
3540
steps:
41+
- name: Harden the runner (Audit all outbound calls)
42+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
43+
with:
44+
egress-policy: audit
45+
3646
- name: List all changed files
3747
run: |
3848
echo '${{ needs.changed-files.outputs.all_changed_files }}'
@@ -44,8 +54,13 @@ jobs:
4454
outputs:
4555
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
4656
steps:
57+
- name: Harden the runner (Audit all outbound calls)
58+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
59+
with:
60+
egress-policy: audit
61+
4762
- name: Checkout
48-
uses: actions/checkout@v4
63+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4964
with:
5065
fetch-depth: 0
5166
- name: Get changed files
@@ -62,6 +77,11 @@ jobs:
6277
runs-on: ubuntu-latest
6378
needs: [changed-files-rest-api]
6479
steps:
80+
- name: Harden the runner (Audit all outbound calls)
81+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
82+
with:
83+
egress-policy: audit
84+
6585
- name: List all changed files
6686
run: |
6787
echo '${{ needs.changed-files-rest-api.outputs.all_changed_files }}'

0 commit comments

Comments
 (0)