Skip to content

Commit 21eb505

Browse files
[StepSecurity] ci: Harden GitHub Actions (#173)
Signed-off-by: StepSecurity Bot <bot@stepsecurity.io>
1 parent 0d4e43e commit 21eb505

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ on:
99
schedule:
1010
- cron: '0 15 * * 5'
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
analyze:
17+
permissions:
18+
actions: read # for github/codeql-action/init to get workflow details
19+
contents: read # for actions/checkout to fetch code
20+
security-events: write # for github/codeql-action/autobuild to send a status report
1421
name: Analyze
1522
runs-on: ubuntu-latest
1623

@@ -24,8 +31,13 @@ jobs:
2431
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
2532

2633
steps:
34+
- name: Harden Runner
35+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
36+
with:
37+
egress-policy: audit
38+
2739
- name: Checkout repository
28-
uses: actions/checkout@v4
40+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2941
with:
3042
# We must fetch at least the immediate parents so that if this is
3143
# a pull request then we can checkout the head.
@@ -38,7 +50,7 @@ jobs:
3850

3951
# Initializes the CodeQL tools for scanning.
4052
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@v3
53+
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
4254
with:
4355
languages: ${{ matrix.language }}
4456
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -49,7 +61,7 @@ jobs:
4961
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5062
# If this step fails, then you should remove it and run the build manually (see below)
5163
- name: Autobuild
52-
uses: github/codeql-action/autobuild@v3
64+
uses: github/codeql-action/autobuild@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
5365

5466
# ℹ️ Command-line programs to run using the OS shell.
5567
# 📚 https://git.io/JvXDl
@@ -63,4 +75,4 @@ jobs:
6375
# make release
6476

6577
- name: Perform CodeQL Analysis
66-
uses: github/codeql-action/analyze@v3
78+
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8

.github/workflows/go.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
name: Go
22
on: [push, pull_request]
3+
permissions:
4+
contents: read
5+
36
jobs:
47

58
build:
69
name: Build
710
runs-on: ubuntu-latest
811
steps:
9-
- uses: actions/checkout@v4
10-
- uses: actions/setup-go@v5
12+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
13+
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
1114
with:
1215
go-version: 'stable'
1316

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
goos: [freebsd, linux, windows]
1818
goarch: [amd64, arm64]
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2121

2222
- name: Set APP_VERSION env
2323
run: echo APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
2424
- name: Set BUILD_TIME env
2525
run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV}
2626

27-
- uses: wangyoucao577/go-release-action@v1
27+
- uses: wangyoucao577/go-release-action@481a2c1a0f1be199722e3e9b74d7199acafc30a8 # v1.53
2828
with:
2929
github_token: ${{ secrets.GITHUB_TOKEN }}
3030
goos: ${{ matrix.goos }}

0 commit comments

Comments
 (0)