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

feat: refactor ci, update deps, pin distroless #46

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/VULN-TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Vulnerabilities detected
labels: security
---
High or critical vulnerabilities detected. Scan results are below:

{{ env.RESULTS }}
6 changes: 4 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ on:
branches:
- master

permissions: {}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pr-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pr-actions

permissions: {}

on:
pull_request:
branches:
- 'master'

jobs:
ensure-sha-pinned:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@b88cd0aad2c36a63e42c71f81cb1958fed95ac87 # v3.0.10
with:
# slsa-github-generator requires using a semver tag for reusable workflows.
# See: https://github.com/slsa-framework/slsa-github-generator#referencing-slsa-builders-and-generators
allowlist: |
slsa-framework/slsa-github-generator
10 changes: 9 additions & 1 deletion .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- synchronize
- reopened

permissions: {}

jobs:
lint-chart:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -74,10 +76,10 @@ jobs:
strategy:
matrix:
kubernetes-version:
- "1.27"
- "1.28"
- "1.29"
- "1.30"
- "1.31"
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
Expand Down Expand Up @@ -222,3 +224,9 @@ jobs:

- name: Run chart-testing (install)
run: ct install --target-branch=master --chart-dirs chart

test-success:
runs-on: ubuntu-latest
needs: [test, e2e-tests]
steps:
- run: echo "all tests succeeded"
27 changes: 27 additions & 0 deletions .github/workflows/pr-goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pr-gorelaser

permissions: {}

on:
pull_request:
branches:
- 'master'

jobs:
validate-config:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Validate .goreleaser.yaml
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
with:
version: latest
args: check
env:
RUNNER_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.DOODLE_OSS_BOT}}
8 changes: 6 additions & 2 deletions .github/workflows/pr-label.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ name: pr-label
on:
pull_request:

permissions: {}

jobs:
size-label:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
permissions:
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: size-label
uses: "pascalgn/size-label-action@bbbaa0d5ccce8e2e76254560df5c64b82dac2e12"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
18 changes: 18 additions & 0 deletions .github/workflows/pr-stale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pr-stale
on:
schedule:
- cron: '30 1 * * *'

permissions: {}

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
with:
days-before-close: '120'
stale-pr-label: stale
repo-token: ${{ github.token }}
28 changes: 28 additions & 0 deletions .github/workflows/pr-trivy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: pr-trivy
on: pull_request

permissions: {}

jobs:
trivy:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit

- name: Trivy fs scan
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
with:
scan-type: 'fs'
ignore-unfixed: true
scanners: license,vuln,secret
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3
with:
sarif_file: 'trivy-results.sarif'
11 changes: 8 additions & 3 deletions .github/workflows/rebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ on:
issue_comment:
types: [created]

permissions: {}

jobs:
rebase:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase') && (github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
runs-on: ubuntu-latest
permissions:
contents: write # needed to force push
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit

- name: Checkout the latest code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 #1.8
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
env:
GITHUB_TOKEN: ${{ github.token }}
29 changes: 15 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ on:
tags:
- 'v*'

permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access
permissions: {}

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
packages: write # needed for ghcr access
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
Expand All @@ -31,8 +32,8 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
- uses: anchore/sbom-action/download-syft@d94f46e13c6c62f59525ac9a1e147a99dc0b9bf5 # v0.17.0
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0
- uses: anchore/sbom-action/download-syft@ab9d16d4b419c9d1a02df5213fa0ebe965ca5a57 # v0.17.1
- name: Create release and SBOM
if: startsWith(github.ref, 'refs/tags/v')
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
Expand All @@ -51,31 +52,31 @@ jobs:
id-token: write # Needed for keyless signing
steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0

- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 #v3.5

- name: Setup Cosign
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.0

- name: Login to Github Container Registry using helm
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin

- name: Package helm charts
run: |
packVersion=$(echo "${{ github.ref_name }}" | sed 's/^v//g')
helm package chart/swagger-hub-controller -d chart --version=$packVersion --app-version=${{ github.ref_name }}
helm package chart/keycloak-controller -d chart --version=$packVersion --app-version=${{ github.ref_name }}
- name: Publish helm charts to Github Container Registry
run: |
repository=$(echo "${{ github.repository_owner }}" | tr [:upper:] [:lower:])
helm push ${{ github.workspace }}/chart/swagger-hub-controller-*.tgz oci://ghcr.io/$repository/charts |& tee .digest
helm push ${{ github.workspace }}/chart/keycloak-controller-*.tgz oci://ghcr.io/$repository/charts |& tee .digest
cosign login --username ${GITHUB_ACTOR} --password ${{ secrets.GITHUB_TOKEN }} ghcr.io
cosign sign --yes ghcr.io/$repository/charts/swagger-hub-controller@$(cat .digest | awk -F "[, ]+" '/Digest/{print $NF}')
cosign sign --yes ghcr.io/$repository/charts/keycloak-controller@$(cat .digest | awk -F "[, ]+" '/Digest/{print $NF}')
79 changes: 79 additions & 0 deletions .github/workflows/report-on-vulnerabilities.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: report-on-vulnerabilities

permissions: {}

on:
workflow_dispatch: {}
schedule:
- cron: '0 6 * * *'

jobs:
scan:
runs-on: ubuntu-latest
outputs:
results: ${{ steps.parse-results.outputs.results }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit

- name: Scan for vulnerabilities
uses: aquasecurity/trivy-action@6e7b7d1fd3e4fef0c5fa8cce1229c54b2c9bd0d8 # 0.24.0
with:
image-ref: ghcr.io/doodlescheduling/swagger-hub-controller:latest
format: json
scanners: vuln,secret
ignore-unfixed: false
severity: HIGH,CRITICAL
output: scan.json

- name: Parse scan results
id: parse-results
continue-on-error: true
run: |
VULNS=$(cat scan.json | jq '[.Results[].Vulnerabilities | select(. != null) | .[]] | length')
if [[ $VULNS -eq 0 ]]
then
echo "No vulnerabilities found, halting"
echo "results=nothing" >> $GITHUB_OUTPUT
else
echo "Vulnerabilities found, creating issue"
echo "results=found" >> $GITHUB_OUTPUT
fi

- name: Upload vulnerability scan report
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
if: steps.parse-results.outputs.results == 'found'
with:
name: scan.json
path: scan.json
if-no-files-found: error

open-issue:
runs-on: ubuntu-latest
if: needs.scan.outputs.results == 'found'
needs: scan
permissions:
issues: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Download scan
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: scan.json
- name: Set scan output
id: set-scan-output
run: echo "results=$(cat scan.json)" >> $GITHUB_OUTPUT
- uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2.9.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESULTS: ${{ steps.set-scan-output.outputs.results }}
with:
filename: .github/ISSUE_TEMPLATE/VULN-TEMPLATE.md
Loading
Loading