Skip to content
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

Harden CI #385

Merged
merged 22 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
37a9618
gh token permissions
louiseschmidtgen Apr 29, 2024
f37eb16
add security agent to runner
louiseschmidtgen Apr 29, 2024
178a4b2
fmt
louiseschmidtgen Apr 29, 2024
129fbe2
Merge remote-tracking branch 'origin/main' into KU-629/harden-CI
louiseschmidtgen Apr 30, 2024
8f6472f
gh token permissions
louiseschmidtgen Apr 29, 2024
cb4a9c5
add security agent to runner
louiseschmidtgen Apr 29, 2024
d68a6e9
fmt
louiseschmidtgen Apr 29, 2024
91342c0
Merge branch 'KU-629/harden-CI' of https://github.com/canonical/k8s-s…
louiseschmidtgen May 3, 2024
207b6c0
rm permissions
louiseschmidtgen May 15, 2024
5cbccce
rm permission restriction strict
louiseschmidtgen May 15, 2024
53fcacf
Merge remote-tracking branch 'origin/main' into KU-629/harden-CI
louiseschmidtgen May 15, 2024
46b58d0
rm harden runner from integration tests
louiseschmidtgen May 16, 2024
3600782
lets try with these allowed endpoints
louiseschmidtgen May 16, 2024
f6d955f
move code
louiseschmidtgen May 16, 2024
8da122d
rm harden runner for integration tests
louiseschmidtgen May 16, 2024
9d5b21a
test more runs
louiseschmidtgen May 16, 2024
601d26a
rm harden runner from strict integration
louiseschmidtgen May 16, 2024
e4e88cf
add write to ticks test
louiseschmidtgen May 16, 2024
338cb89
rm run workflow on PR for testing
louiseschmidtgen May 18, 2024
14af82e
tag pinnning and comments removed
louiseschmidtgen May 21, 2024
ee259bd
cleanup
louiseschmidtgen May 21, 2024
6c469be
Merge remote-tracking branch 'origin/main' into KU-629/harden-CI
louiseschmidtgen May 21, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/cla.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ on:
- main
- 'release-[0-9]+.[0-9]+'

permissions:
contents: read

jobs:
cla-check:
permissions:
pull-requests: write # for canonical/has-signed-canonical-cla to create & update comments
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
egress-policy: audit
- name: Check if CLA signed
uses: canonical/has-signed-canonical-cla@v1
17 changes: 17 additions & 0 deletions .github/workflows/cron-jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ on:
schedule:
- cron: '0 10 * * *'

permissions:
contents: read

jobs:
TICS:
permissions:
contents: read
security-events: write
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -14,6 +20,10 @@ jobs:
- { branch: main }

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
egress-policy: audit
- name: Checking out repo
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -67,6 +77,9 @@ jobs:
path: tics-logs.tar.gz

Trivy:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -77,6 +90,10 @@ jobs:
# Add branches to test here

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
egress-policy: audit
- name: Checking out repo
uses: actions/checkout@v4
with:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ on:
- 'autoupdate/release-[0-9]+.[0-9]+-strict'
pull_request:

permissions:
contents: read

jobs:
test:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # for marocchino/sticky-pull-request-comment to create or update PR comment
name: Unit Tests & Code Quality
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
egress-policy: audit
- name: Check out code
uses: actions/checkout@v4

Expand Down Expand Up @@ -86,6 +96,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
egress-policy: audit
- name: Check out code
uses: actions/checkout@v4

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ on:
- 'autoupdate/release-[0-9]+.[0-9]+-strict'
pull_request:

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-20.04

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
egress-policy: audit
- name: Checking out repo
uses: actions/checkout@v4
- name: Install lxd
Expand Down Expand Up @@ -71,10 +78,17 @@ jobs:
cd tests/integration && sg lxd -c 'tox -e integration'

security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
name: Security scan
runs-on: ubuntu-20.04
needs: build
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
egress-policy: audit
- name: Checking out repo
uses: actions/checkout@v4
- name: Fetch snap
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/nightly-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
schedule:
- cron: '0 0 * * *' # Runs every midnight

permissions:
contents: read

jobs:
test-integration:
name: Integration Test ${{ matrix.os }} ${{ matrix.arch }} ${{ matrix.releases }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ on:
- 'autoupdate/release-[0-9]+.[0-9]+-strict'
pull_request:

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
egress-policy: audit
- name: Check out code
uses: actions/checkout@v4
- name: Setup Python
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/sbom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ on:
- 'autoupdate/release-[0-9]+.[0-9]+-strict'
pull_request:

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
with:

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
egress-policy: audit
- name: Checking out repo
uses: actions/checkout@v4
- name: Setup Python
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
# actions: read
louiseschmidtgen marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: third-party GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
egress-policy: audit
- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Copy link
Contributor

@eaudetcobello eaudetcobello May 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use checkout@v4 (tag pinning) elsewhere, we should do the same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that, just have to silence it too 👍🏼

with:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/strict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- main
- 'release-[0-9]+.[0-9]+'

permissions:
contents: read

jobs:
prepare:
name: Prepare
Expand All @@ -28,6 +31,8 @@ jobs:
echo "strict=" >> $GITHUB_OUTPUT
fi
update:
permissions:
contents: write # for Git to git push

Check failure

Code scanning / Scorecard

Token-Permissions

score is 0: jobLevel 'contents' permission set to 'write' Remediation tip: Verify which permissions are needed and consider whether you can reduce them. Click Remediation section below for further remediation help
runs-on: ubuntu-20.04
needs: [ prepare ]
if: ${{ needs.prepare.outputs.strict }}
Expand Down
Loading