Skip to content

Commit 433f322

Browse files
chore: [StepSecurity] Harden GitHub Actions (GoogleCloudPlatform#218)
1 parent 7868dc1 commit 433f322

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

.github/workflows/conformance.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,29 @@ jobs:
77
matrix:
88
python-version: ['3.8', '3.9', '3.10', '3.11']
99
steps:
10+
- name: Harden Runner
11+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
12+
with:
13+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
14+
1015
- name: Checkout code
11-
uses: actions/checkout@v2
16+
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
1217

1318
- name: Setup Python
14-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
1520
with:
1621
python-version: ${{ matrix.python-version }}
1722

1823
- name: Install the framework
1924
run: python -m pip install -e .
2025

2126
- name: Setup Go
22-
uses: actions/setup-go@v2
27+
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # v2.2.0
2328
with:
2429
go-version: '1.16'
2530

2631
- name: Run HTTP conformance tests
27-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
32+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
2833
with:
2934
version: 'v1.6.0'
3035
functionType: 'http'
@@ -33,7 +38,7 @@ jobs:
3338
cmd: "'functions-framework --source tests/conformance/main.py --target write_http --signature-type http'"
3439

3540
- name: Run event conformance tests
36-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
41+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
3742
with:
3843
version: 'v1.6.0'
3944
functionType: 'legacyevent'
@@ -42,7 +47,7 @@ jobs:
4247
cmd: "'functions-framework --source tests/conformance/main.py --target write_legacy_event --signature-type event'"
4348

4449
- name: Run CloudEvents conformance tests
45-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
50+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
4651
with:
4752
version: 'v1.6.0'
4853
functionType: 'cloudevent'
@@ -51,7 +56,7 @@ jobs:
5156
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event --signature-type cloudevent'"
5257

5358
- name: Run HTTP conformance tests declarative
54-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
59+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
5560
with:
5661
version: 'v1.6.0'
5762
functionType: 'http'
@@ -60,7 +65,7 @@ jobs:
6065
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative'"
6166

6267
- name: Run CloudEvents conformance tests declarative
63-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
68+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
6469
with:
6570
version: 'v1.6.0'
6671
functionType: 'cloudevent'
@@ -69,7 +74,7 @@ jobs:
6974
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event_declarative'"
7075

7176
- name: Run HTTP concurrency tests declarative
72-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
77+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
7378
with:
7479
version: 'v1.6.0'
7580
functionType: 'http'
@@ -78,7 +83,7 @@ jobs:
7883
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative_concurrent'"
7984

8085
- name: Run Typed tests declarative
81-
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
86+
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
8287
with:
8388
version: 'v1.6.0'
8489
functionType: 'http'

.github/workflows/lint.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
name: Python Lint CI
22
on: [push, pull_request]
3+
permissions:
4+
contents: read
5+
36
jobs:
47
lint:
58
runs-on: ubuntu-latest
69
steps:
7-
- uses: actions/checkout@v2
10+
- name: Harden Runner
11+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
12+
with:
13+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
14+
15+
- uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
816
- name: Setup Python
9-
uses: actions/setup-python@v2
17+
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
1018
- name: Install tox
1119
run: python -m pip install tox
1220
- name: Lint

.github/workflows/release.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
build-and-pubish:
912
name: Build and Publish
1013
runs-on: ubuntu-latest
1114
steps:
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+
1220
- name: Checkout
13-
uses: actions/checkout@v2
21+
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
1422
with:
1523
ref: ${{ github.event.release.tag_name }}
1624
- name: Install Python
17-
uses: actions/setup-python@v2
25+
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
1826
- name: Install build dependencies
1927
run: python -m pip install -U setuptools build wheel
2028
- name: Build distributions
2129
run: python -m build
2230
- name: Publish
23-
uses: pypa/gh-action-pypi-publish@master
31+
uses: pypa/gh-action-pypi-publish@9b8e7336db3f96a2939a3e9fa827c62f466ca60d # master
2432
with:
2533
user: __token__
2634
password: ${{ secrets.PYPI_API_TOKEN }}

.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.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Python Unit CI
22
on: [push, pull_request]
3+
permissions:
4+
contents: read
5+
36
jobs:
47
test:
58
strategy:
@@ -8,10 +11,15 @@ jobs:
811
platform: [ubuntu-latest, macos-latest, windows-latest]
912
runs-on: ${{ matrix.platform }}
1013
steps:
14+
- name: Harden Runner
15+
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
16+
with:
17+
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
18+
1119
- name: Checkout
12-
uses: actions/checkout@v2
20+
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
1321
- name: Use Python ${{ matrix.python }}
14-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
1523
with:
1624
python-version: ${{ matrix.python }}
1725
- name: Install tox

0 commit comments

Comments
 (0)