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 20 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 @@
- 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 @@
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 @@
- { 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 @@
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 @@
# 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 @@
- '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 @@
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 @@
- '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 @@
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 @@
- '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 @@
- '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
40 changes: 9 additions & 31 deletions .github/workflows/scorecard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,48 @@

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '43 6 * * *'
push:
branches: [ "main" ]
pull_request: #TODO: rm after testing

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

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
uses: actions/[email protected]

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: GitHub-owned GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
uses: ossf/[email protected]

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:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20
uses: actions/upload-artifact@v3

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: GitHub-owned GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard (optional).
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9
uses: github/codeql-action/[email protected]

Check warning

Code scanning / Scorecard

Pinned-Dependencies

score is 0: GitHub-owned GitHubAction not pinned by hash Click Remediation section below to solve this issue
with:
sarif_file: results.sarif
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 @@
- main
- 'release-[0-9]+.[0-9]+'

permissions:
contents: read

jobs:
prepare:
name: Prepare
Expand All @@ -28,6 +31,8 @@
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