Skip to content

Commit

Permalink
Merge pull request #48 from ScilifelabDataCentre/trivy
Browse files Browse the repository at this point in the history
Add Trivy workflow
  • Loading branch information
LianeHughes authored Mar 10, 2023
2 parents 36f28f0 + b50fecf commit 45fb9e4
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/trivy-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Trivy: Scan of current branch
# Trivy is a comprehensive and versatile security scanner.
# Trivy has scanners that look for security issues, and targets where it can find those issues.
# https://github.com/aquasecurity/trivy
#
# This runs on every push for every branch
# ----------------------------------------

name: Trivy - branch scan
on:
pull_request:
push:
branches:
- master

jobs:
scan:
permissions:
contents: read
security-events: write
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
scan-type: "fs"
ignore-unfixed: true
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
category: trivy-branch
44 changes: 44 additions & 0 deletions .github/workflows/trivy-scheduled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Trivy: Scan of current branch
# Trivy is a comprehensive and versatile security scanner.
# Trivy has scanners that look for security issues, and targets where it can find those issues.
# https://github.com/aquasecurity/trivy
#
# This runs on scheduled time (08:30 and 12:30)for the develop image
# ------------------------------------------------------------------

name: Trivy - scheduled scan

on:
workflow_dispatch:
branches:
- master
schedule:
- cron: '30 8,12 * * *'

jobs:
scan:
permissions:
contents: read
security-events: write
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Ensure lowercase name
run: echo REPOSITORY_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV

- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'ghcr.io/${{ env.REPOSITORY_OWNER }}/dsw-appendix:latest'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
category: trivy-cron

0 comments on commit 45fb9e4

Please sign in to comment.