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

github: split security scanning into re-usable jobs #1033

Merged
merged 1 commit into from Aug 15, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/common-codeql.yaml
@@ -0,0 +1,19 @@
name: CodeQL scanning
on:
workflow_call:

jobs:
codeql-scan:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
@@ -1,15 +1,18 @@
name: Security Scanning

name: Trivy scanning
on:
push:
branches: [ "master", "release-*" ]
tags: [ 'v*' ]
pull_request:
branches: [ "master", "release-*" ]
workflow_call:
inputs:
upload-to-github-security-tab:
default: false
required: false
type: boolean
export-csv:
default: false
required: false
type: boolean

jobs:
trivy-scan-code:
name: Trivy scan
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -36,6 +39,7 @@ jobs:
format: table

- name: Convert report to sarif
if: ${{ inputs.upload-to-github-security-tab }}
uses: aquasecurity/trivy-action@master
with:
scan-type: convert
Expand All @@ -45,7 +49,14 @@ jobs:
format: sarif
output: trivy-report.sarif

- name: Upload sarif report to GitHub Security tab
if: ${{ inputs.upload-to-github-security-tab }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-report.sarif

- name: Convert report to csv
if: ${{ inputs.export-csv }}
uses: aquasecurity/trivy-action@master
with:
scan-type: convert
Expand All @@ -56,39 +67,9 @@ jobs:
template: "@.github/workflows/trivy-csv.tpl"
output: trivy-report.csv

- name: Upload sarif report to GitHub Security tab
if: ${{ github.event_name != 'pull_request' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: trivy-report.sarif

- name: Upload CSV report as an artifact
if: ${{ inputs.export-csv }}
uses: actions/upload-artifact@v3
with:
name: trivy-report
path: trivy-report.csv

codeQL-scanning:
runs-on: ubuntu-latest
environment:
name: dev
url: https://github.com

steps:
- name: Checkout
uses: actions/checkout@master

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: go

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

- name: Upload result to GitHub Code Scanning
if: ${{ github.event_name != 'pull_request' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: codeql.sarif
wait-for-processing: true
6 changes: 6 additions & 0 deletions .github/workflows/verify.yml
Expand Up @@ -39,3 +39,9 @@ jobs:
build-docs:
name: Verify docs build and gh-pages update
uses: "./.github/workflows/common-build-docs.yaml"

trivy-scan:
uses: "./.github/workflows/common-trivy.yaml"

codeql-scan:
uses: "./.github/workflows/common-codeql.yaml"