Skip to content

chore: [StepSecurity] Harden GitHub Actions #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,29 @@ jobs:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Harden Runner
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
with:
python-version: ${{ matrix.python-version }}

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

- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@bfdd3570ce990073878bf10f6b2d79082de49492 # v2.2.0
with:
go-version: '1.16'

- name: Run HTTP conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'http'
Expand All @@ -33,7 +38,7 @@ jobs:
cmd: "'functions-framework --source tests/conformance/main.py --target write_http --signature-type http'"

- name: Run event conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'legacyevent'
Expand All @@ -42,7 +47,7 @@ jobs:
cmd: "'functions-framework --source tests/conformance/main.py --target write_legacy_event --signature-type event'"

- name: Run CloudEvents conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'cloudevent'
Expand All @@ -51,7 +56,7 @@ jobs:
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event --signature-type cloudevent'"

- name: Run HTTP conformance tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'http'
Expand All @@ -60,7 +65,7 @@ jobs:
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative'"

- name: Run CloudEvents conformance tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'cloudevent'
Expand All @@ -69,7 +74,7 @@ jobs:
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event_declarative'"

- name: Run HTTP concurrency tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'http'
Expand All @@ -78,7 +83,7 @@ jobs:
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative_concurrent'"

- name: Run Typed tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@c52662e612b2685a027b1c3e02224306517722fc # v1.6.0
with:
version: 'v1.6.0'
functionType: 'http'
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
name: Python Lint CI
on: [push, pull_request]
permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Harden Runner
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
- name: Install tox
run: python -m pip install tox
- name: Lint
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@ on:
release:
types: [published]

permissions:
contents: read

jobs:
build-and-pubish:
name: Build and Publish
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
with:
ref: ${{ github.event.release.tag_name }}
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
- name: Install build dependencies
run: python -m pip install -U setuptools build wheel
- name: Build distributions
run: python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@9b8e7336db3f96a2939a3e9fa827c62f466ca60d # master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
5 changes: 5 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
id-token: write

steps:
- name: Harden Runner
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Python Unit CI
on: [push, pull_request]
permissions:
contents: read

jobs:
test:
strategy:
Expand All @@ -8,10 +11,15 @@ jobs:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@18bf8ad2ca49c14cbb28b91346d626ccfb00c518 # v2.1.0
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@dc323e67f16fb5f7663d20ff7941f27f5809e9b6 # v2.6.0
- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v2
uses: actions/setup-python@75f3110429a8c05be0e1bf360334e4cced2b63fa # v2.3.3
with:
python-version: ${{ matrix.python }}
- name: Install tox
Expand Down