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

ci: Add Snyk security scans #170

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .github/workflows/on-push-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ on:
jobs:
tests:
uses: ./.github/workflows/tests.yaml
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/on-push-main-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
tests:
uses: ./.github/workflows/tests.yaml
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

generate-changelog:
needs: tests
Expand All @@ -35,3 +37,58 @@ jobs:
radix-environment: 'test'
secrets:
APP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.APP_SERVICE_ACCOUNT_TOKEN }}


snyk-monitoring-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to monitor for python vulnerabilities
uses: snyk/actions/python-3.10@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
args: --severity-threshold=high --file=api/pyproject.toml

snyk-monitoring-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to monitor for node vulnerabilities
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: monitor
args: --severity-threshold=high --file=web/package.json

snyk-monitor-web-container:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build a Docker image
run: docker build -t web ./web
- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: web
command: monitor
args: --file=./web/Dockerfile

snuyk-monitor-api-container:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build a Docker image
run: docker build -t api ./api
- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: web
command: monitor
args: --file=./api/Dockerfile
2 changes: 2 additions & 0 deletions .github/workflows/release-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
jobs:
tests:
uses: ./.github/workflows/tests.yaml
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

publish-production:
needs: tests
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
CR_SECRET:
description: "Secret to authenticate if using an other container registry than Github"
required: false
SNYK_TOKEN:
description: "Token used to authenticate with Snyk"
required: true

env:
IMAGE_REGISTRY: ghcr.io
Expand Down Expand Up @@ -50,6 +53,14 @@ jobs:
docker pull $API_IMAGE
docker build --target development --tag api-development ./api # TODO: --cache-from $API_IMAGE

- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: api-development
args: --file=api/Dockerfile

- name: BDD Integration tests
if: ${{ false }} # disable for now
run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml run api behave
Expand All @@ -68,6 +79,42 @@ jobs:
docker pull $WEB_IMAGE
docker build --cache-from $WEB_IMAGE --target development --tag web-dev ./web

- name: Run Snyk to check Docker image for vulnerabilities
uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: web-dev
args: --severity-threshold=high --file=web/Dockerfile


python-security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for Python vulnerabilities
uses: snyk/actions/python-3.10@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high --file=api/pyproject.toml

node-security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install dependencies
working-directory: ./web
run: |
npm install
- name: Run Snyk to check for Node vulnerabilities
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=high --file=web/package.json


test-docs:
name: test-docs
runs-on: ubuntu-latest
Expand Down