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

Use Trivy more effectively #68

Merged
merged 5 commits into from
Apr 12, 2023
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
16 changes: 13 additions & 3 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Scan repo
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
scanners: 'vuln,config,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'

- name: Registry login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
- name: Get Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
Expand All @@ -40,10 +50,10 @@ jobs:
load: true
tags: ${{ steps.metadata.outputs.tags }}

- name: Run Trivy vulnerability scanner
- name: Scan image
uses: aquasecurity/trivy-action@master
with:
image-ref: ghcr.io/infratographer/permissions-api/permissions-api:latest
image-ref: ghcr.io/infratographer/permissions-api:latest
scanners: 'vuln,config,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Trivy Scan

on:
pull_request:
workflow_dispatch:

jobs:
image-scan:
name: image-scan
runs-on: ubuntu-latest

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

- name: Registry login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker metadata
id: metadata
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=sha

- name: Build
uses: docker/build-push-action@v4
with:
context: .
push: false
load: true
tags: ${{ steps.metadata.outputs.tags }}

- name: Scan image
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.metadata.outputs.tags }}
scanners: 'vuln,config,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'

repo-scan:
name: repo-scan
runs-on: ubuntu-latest

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

- name: Scan repo
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
scanners: 'vuln,config,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'
9 changes: 0 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,3 @@ jobs:
push: false
load: true
tags: ${{ steps.metadata.outputs.tags }}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ steps.metadata.outputs.tags }}
scanners: 'vuln,config,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'