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 all commits
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
8 changes: 4 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

RUN export DEBIAN_FRONTEND=noninteractive \
&& curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg \
&& curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | tee /usr/share/keyrings/helm.gpg \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/yarn-archive-keyring.gpg \
&& apt-get install apt-transport-https --yes \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | tee /etc/apt/sources.list.d/helm-stable-debian.list \
&& apt-get update \
&& apt-get -y install --no-install-recommends \
&& apt-get install --yes --no-install-recommends \
bash-completion \
helm \
uuid-runtime

# Install cockroachdb so we have the client
RUN curl https://binaries.cockroachdb.com/cockroach-v22.1.8.linux-amd64.tgz | tar -xz \
&& sudo cp -i cockroach-v22.1.8.linux-amd64/cockroach /usr/local/bin/ \
&& cp -i cockroach-v22.1.8.linux-amd64/cockroach /usr/local/bin/ \
&& rm -rf cockroach-v*

USER vscode
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

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

- 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,14 +51,15 @@ 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
scanners: 'vuln,config,secret'
image-ref: ghcr.io/infratographer/permissions-api:latest
scanners: 'vuln,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'
exit-code: '1'

- name: Push
uses: docker/build-push-action@v4
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'
exit-code: '1'

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,secret'
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'table'
exit-code: '1'
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'