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

build: Add vulnerability scan with Trivy #225

Merged
merged 2 commits into from
Jan 14, 2025
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
Next Next commit
build: Add flow with Trivy
  • Loading branch information
SnigL committed Jan 14, 2025
commit ad581a5cbfacea26eb404531e3d6a19bbc7b5b0b
19 changes: 19 additions & 0 deletions generic/vulnerability-scan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Vulnerability Scanning Composite Action

Runs a vulnerability scan using [Trivy](https://github.com/aquasecurity/trivy-action) on the supplied Docker image. The action will fail if any Critical issues are found.

## Usage

```yaml
env:
IMAGE: eu.gcr.io/extenda/hiiretail-service

jobs:
...
vulnerability-scan:
runs-on: ubuntu-latest
steps:
- uses: extenda/shared-workflows/generic/vulnerability-scan@build/add-trivy-workflow
with:
docker-image: ${{ env.IMAGE }}:${{ github.sha }}
```
25 changes: 25 additions & 0 deletions generic/vulnerability-scan/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: vulnerability-scan
description: Runs a vulnerability scan on the built image
inputs:
docker-image:
description: The docker image
required: true

runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build image
shell: bash
run: docker build -t ${{ inputs.docker-image }} .

- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: ${{ inputs.docker-image }}
format: 'table'
severity: 'CRITICAL'
exit-code: '1'
Loading