Skip to content

Commit 3ac1abd

Browse files
chore: [StepSecurity] Harden GitHub Actions (#177)
1 parent 6ac80aa commit 3ac1abd

File tree

5 files changed

+56
-17
lines changed

5 files changed

+56
-17
lines changed

.github/workflows/codeql.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
# The branches below must be a subset of the branches above
88
branches: [ "master" ]
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
analyze:
1215
name: Analyze
@@ -24,12 +27,17 @@ jobs:
2427
working-directory: ['invoker', 'functions-framework-api', 'function-maven-plugin']
2528

2629
steps:
30+
- name: Harden Runner
31+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
32+
with:
33+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
34+
2735
- name: Checkout repository
28-
uses: actions/checkout@v3
36+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
2937

3038
# Initializes the CodeQL tools for scanning.
3139
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@v2
40+
uses: github/codeql-action/init@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
3341
with:
3442
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3543
languages: java
@@ -43,12 +51,12 @@ jobs:
4351

4452
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
4553
- name: Autobuild
46-
uses: github/codeql-action/autobuild@v2
54+
uses: github/codeql-action/autobuild@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
4755
with:
4856
working-directory: ${{ matrix.working-directory }}
4957

5058

5159
- name: Perform CodeQL Analysis
52-
uses: github/codeql-action/analyze@v2
60+
uses: github/codeql-action/analyze@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
5361
with:
5462
category: ${{ matrix.working-directory }}

.github/workflows/conformance.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ jobs:
1515
# 13.x
1616
]
1717
steps:
18-
- uses: actions/checkout@v2
18+
- name: Harden Runner
19+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
20+
with:
21+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
22+
23+
- uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
1924

2025
- name: Set up JDK ${{ matrix.java }}
21-
uses: actions/setup-java@v1
26+
uses: actions/setup-java@d202f5dbf7256730fb690ec59f6381650114feb2 # v1.4.3
2227
with:
2328
java-version: ${{ matrix.java }}
2429

2530
- name: Setup Go
26-
uses: actions/setup-go@v2
31+
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # v2.2.0
2732
with:
2833
go-version: '1.16'
2934

@@ -34,7 +39,7 @@ jobs:
3439
run: (cd invoker/ && mvn install)
3540

3641
- name: Run HTTP conformance tests
37-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
42+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
3843
with:
3944
version: 'v1.6.0'
4045
functionType: 'http'
@@ -43,7 +48,7 @@ jobs:
4348
startDelay: 10
4449

4550
- name: Run background event conformance tests
46-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
51+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
4752
with:
4853
version: 'v1.6.0'
4954
functionType: 'legacyevent'
@@ -53,7 +58,7 @@ jobs:
5358
startDelay: 10
5459

5560
- name: Run cloudevent conformance tests
56-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
61+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
5762
with:
5863
version: 'v1.6.0'
5964
functionType: 'cloudevent'
@@ -63,7 +68,7 @@ jobs:
6368
startDelay: 10
6469

6570
- name: Run HTTP concurrency conformance tests
66-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
71+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
6772
with:
6873
version: 'v1.6.0'
6974
functionType: 'http'

.github/workflows/lint.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ on:
55
- master
66
pull_request:
77
workflow_dispatch:
8+
permissions:
9+
contents: read
10+
811
jobs:
912
lint:
1013
runs-on: ubuntu-latest
1114
steps:
12-
- uses: actions/checkout@v2
15+
- name: Harden Runner
16+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
17+
with:
18+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
19+
20+
- uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
1321
- name: Set up JDK
14-
uses: actions/setup-java@v1
22+
uses: actions/setup-java@d202f5dbf7256730fb690ec59f6381650114feb2 # v1.4.3
1523
with:
1624
java-version: 11.x
1725
- name: Build API with Maven
@@ -25,10 +33,15 @@ jobs:
2533
formatting:
2634
runs-on: ubuntu-latest
2735
steps:
28-
- uses: actions/checkout@v3 # v2 minimum required
36+
- name: Harden Runner
37+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
38+
with:
39+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
40+
41+
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 # v2 minimum required
2942
- name: Run formatter
3043
id: formatter
31-
uses: axel-op/googlejavaformat-action@v3
44+
uses: axel-op/googlejavaformat-action@dbff853fb823671ec5781365233bf86543b13215 # v3
3245
with:
3346
args: "--replace"
3447
skip-commit: true

.github/workflows/scorecard.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
id-token: write
2525

2626
steps:
27+
- name: Harden Runner
28+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
29+
with:
30+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
31+
2732
- name: "Checkout code"
2833
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
2934
with:

.github/workflows/unit.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
branches:
55
- master
66
pull_request:
7+
permissions:
8+
contents: read
9+
710
jobs:
811
build:
912
runs-on: ubuntu-latest
@@ -14,9 +17,14 @@ jobs:
1417
17.x
1518
]
1619
steps:
17-
- uses: actions/checkout@v2
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
22+
with:
23+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
24+
25+
- uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
1826
- name: Set up JDK ${{ matrix.java }}
19-
uses: actions/setup-java@v2
27+
uses: actions/setup-java@f0bb91606209742fe3ea40199be2f3ef195ecabf # v2.5.0
2028
with:
2129
java-version: ${{ matrix.java }}
2230
distribution: temurin

0 commit comments

Comments
 (0)