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

feat: add security scanning on CI workflow #112

Merged
merged 91 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
141762f
feat: added security scanning on docker images with trivy
gabrielg2020 May 2, 2024
a7990f2
chore: tigger CI workflow
gabrielg2020 May 2, 2024
ff067a5
chore: tigger CI workflow
gabrielg2020 May 2, 2024
bd11a5c
fix: removed security scannning until tirvy-actions is on the allowed…
gabrielg2020 May 2, 2024
58934f8
feat: added security scanning on php dependencies with snyk
gabrielg2020 May 2, 2024
47cc738
chore: tigger CI workflow
gabrielg2020 May 2, 2024
a20ce5b
chore: tigger CI workflow
gabrielg2020 May 2, 2024
034cb6f
fix: auth snyk before scanning
gabrielg2020 May 2, 2024
c8dacc9
fix: correctly run the snyk command
gabrielg2020 May 2, 2024
05b6ebd
fix: checkout before scanning
gabrielg2020 May 2, 2024
bf9c3f0
fix: reverting last commit
gabrielg2020 May 2, 2024
51bf493
feat: changing way to get snyk working, installing package
gabrielg2020 May 2, 2024
511f8cf
fix: add checkout
gabrielg2020 May 2, 2024
55f7e75
feat: auth and run test
gabrielg2020 May 2, 2024
d7f2187
fix: change of plan, use snyk action set up
gabrielg2020 May 2, 2024
a8af7b7
fix: add the php snyk actions
gabrielg2020 May 2, 2024
1cb665e
fix: setup snyk with php
gabrielg2020 May 2, 2024
9fb8201
chore: checking if snyk is installed
gabrielg2020 May 2, 2024
b94b4a3
fix: using synk test to scan
gabrielg2020 May 2, 2024
8a9626d
fix: syntax error
gabrielg2020 May 2, 2024
658d5d7
fix: added secret to php.yaml
gabrielg2020 May 2, 2024
05a96aa
fix: using synk test to scan
gabrielg2020 May 2, 2024
9cdde37
feat: testing adding a sperate security workflow
gabrielg2020 May 2, 2024
e2d3dff
fix: track security.yaml
gabrielg2020 May 2, 2024
b2834be
feat: snyk tests run on security
gabrielg2020 May 2, 2024
ad4eadb
feat: adding checkout action
gabrielg2020 May 2, 2024
235f110
fix: remvoed snyk from php.yaml
gabrielg2020 May 3, 2024
2922a3a
fix: scheduled everymonday at 00:00UTC
gabrielg2020 May 3, 2024
5185277
fix: only run security checks on images that have changed
gabrielg2020 May 7, 2024
fb0b64f
fix: remove scheduling in security.yaml
gabrielg2020 May 7, 2024
9580d2c
chore: remove debugging echo
gabrielg2020 May 7, 2024
01b4bad
feat: add docker scanning with trivy
gabrielg2020 May 7, 2024
6f7d356
fix: add env variables to security.yaml
gabrielg2020 May 7, 2024
a23bf6d
fix: image-ref points to correct branch
gabrielg2020 May 7, 2024
b1e5f99
fix: image-ref points to the dockerfile
gabrielg2020 May 7, 2024
78f6f6a
fix: image-ref points to the built image in GHCR
gabrielg2020 May 7, 2024
e1e47ed
Merge branch 'main' into add-security-scanning-to-ci-VOL-5354
gabrielg2020 May 8, 2024
a272d83
chore: trying to find where the docker images are
gabrielg2020 May 8, 2024
b4dc58d
fix: clean up security.yaml
gabrielg2020 May 13, 2024
772a471
feat: adding scheduing to security.yaml
gabrielg2020 May 13, 2024
31e8949
Merge branch 'main' into add-security-scanning-to-ci-VOL-5354
gabrielg2020 May 15, 2024
78a3b57
fix: each repo scan in its own job
gabrielg2020 May 15, 2024
f1b71ea
fix: added working-directory
gabrielg2020 May 15, 2024
06cc80e
refactor: remove dependancy-scan, each check if scheduled run or not
gabrielg2020 May 15, 2024
4157ea9
fix: syntax error
gabrielg2020 May 15, 2024
6752585
refactor: chaning names
gabrielg2020 May 15, 2024
9729635
fix: track dependency-scan.yaml
gabrielg2020 May 15, 2024
58dae87
fix: remove ref
gabrielg2020 May 15, 2024
f0e8a97
refactor: chaning names and reverting changing
gabrielg2020 May 15, 2024
2ccfab7
fix: track security-app.yaml
gabrielg2020 May 15, 2024
1d0a345
chore: triggering ci
gabrielg2020 May 15, 2024
9d3a94f
feat: added terraform scanning
gabrielg2020 May 15, 2024
cc08ba1
fix: remove need to check if terraform scanning works
gabrielg2020 May 15, 2024
f5c437f
fix: uploading trivy scan
gabrielg2020 May 15, 2024
4c92d92
fix: continue on error
gabrielg2020 May 15, 2024
8c62a1a
fix: display trivy results
gabrielg2020 May 15, 2024
4c2d9e9
fix: upload to github code scanning
gabrielg2020 May 15, 2024
3aaae4f
fix: run on all branches
gabrielg2020 May 15, 2024
80bc2d9
fix: run on call
gabrielg2020 May 15, 2024
6b8ee19
fix: display trivy results
gabrielg2020 May 15, 2024
ce800c5
fix: trivy uploading to code scanning
gabrielg2020 May 15, 2024
7731c9e
feat: terraform scanning is now on schedule
gabrielg2020 May 16, 2024
069d3a8
refactor: clearn-up
gabrielg2020 May 16, 2024
b88d1a0
feat: add docker scanning with trivy
gabrielg2020 May 16, 2024
f3f0043
fix: changed trivy version
gabrielg2020 May 16, 2024
dff2fde
fix: try and find the image refs
gabrielg2020 May 16, 2024
eff0b68
fix: try and find the image refs
gabrielg2020 May 16, 2024
31ba671
fix: scanning with a diffrent image ref
gabrielg2020 May 16, 2024
86f3611
fix: remove echo
gabrielg2020 May 16, 2024
b7f6266
fix: changed trivy image ref
gabrielg2020 May 16, 2024
f6804de
ci: add local registry
gabrielg2020 May 16, 2024
471d2eb
ci: build and push to local registry
gabrielg2020 May 16, 2024
b356b4a
ci: add diver-opts to buildx setup
gabrielg2020 May 16, 2024
79e84e5
ci: revert docker.yaml
gabrielg2020 May 16, 2024
563e66b
ci: set working directory in terraform folder
gabrielg2020 May 16, 2024
9387bea
ci: fail when vunrability found
gabrielg2020 May 16, 2024
f2ef62c
ci: scan terrform directory within step
gabrielg2020 May 16, 2024
ed5a403
ci: exclude downloaded modules for terraform scanning
gabrielg2020 May 16, 2024
95df03b
ci: cat results
gabrielg2020 May 16, 2024
c82c3a7
ci: cat results
gabrielg2020 May 16, 2024
b3458bb
ci: exclude downloaded modules for terraform scanning
gabrielg2020 May 16, 2024
57f8e29
ci: upload sarif to gh code scanning
gabrielg2020 May 16, 2024
9e7cac4
fix: empty commit
gabrielg2020 May 16, 2024
5428a4d
fix: revert dockerfile back
gabrielg2020 May 20, 2024
9db4326
feat: upload results from app scan to github
gabrielg2020 May 20, 2024
2488de2
feat: upload results from app scan to github for api and selfserve
gabrielg2020 May 20, 2024
a3aabf5
feat: on fail, still uplaod to github. changed sarif upload paths
gabrielg2020 May 20, 2024
cc514bf
fix: revert dockerfile
gabrielg2020 May 20, 2024
157c8cb
ci: cleaned up and updated workflows
gabrielg2020 May 20, 2024
99513a5
fix: removed continue-on-error in security-app.yaml
gabrielg2020 May 20, 2024
05e1eb6
fix: removed all continue-on-error in security-app.yaml
gabrielg2020 May 20, 2024
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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,32 @@ jobs:
id-token: write
pull-requests: write
secrets: inherit

security-app:
name: Security App
needs:
- orchestrator
strategy:
matrix:
project:
- api
- selfserve
- internal
exclude:
- project: ${{ (needs.orchestrator.outputs.should-build-api || needs.orchestrator.outputs.should-build-api-docker) && 'ignored' || 'api' }}
- project: ${{ (needs.orchestrator.outputs.should-build-selfserve || needs.orchestrator.outputs.should-build-selfserve-docker) && 'ignored' || 'selfserve' }}
- project: ${{ (needs.orchestrator.outputs.should-build-internal || needs.orchestrator.outputs.should-build-internal-docker) && 'ignored' || 'internal' }}
uses: ./.github/workflows/security-app.yaml
with:
project: ${{ matrix.project }}
permissions:
contents: read
gabrielg2020 marked this conversation as resolved.
Show resolved Hide resolved
security-events: write
secrets: inherit

security-terraform:
name: Security Terraform
uses: ./.github/workflows/security-terraform.yaml
permissions:
contents: read
security-events: write
103 changes: 103 additions & 0 deletions .github/workflows/security-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Security App

on:
workflow_call:
inputs:
ref:
type: string
default: 5.3.0
required: false
project:
type: string
required: true
schedule:
# Weekly on Monday at 00:00 UTC
- cron: 0 0 * * 1

jobs:
dependency-scan-api:
if: github.event_name == 'schedule' || inputs.project == 'api'
name: API
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/api
env:
# Temporary until this repository becomes a mono-repository: https://dvsa.atlassian.net/browse/VOL-4961.
REMOTE_REPOSITORY: dvsa/olcs-backend
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REMOTE_REPOSITORY }}
path: app/api
- name: Setup Snyk
uses: snyk/actions/setup@master
- name: Scan api repository
run: snyk test --sarif-file-output=snyk-results.sarif
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
continue-on-error: true

- name: Upload Results to GitHub Code Scanning
if: ${{ always() }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: app/api/snyk-results.sarif

dependency-scan-selfserve:
if: github.event_name == 'schedule' || inputs.project == 'selfserve'
name: Selfserve
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/selfserve
env:
# Temporary until this repository becomes a mono-repository: https://dvsa.atlassian.net/browse/VOL-4961.
REMOTE_REPOSITORY: dvsa/olcs-selfserve
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REMOTE_REPOSITORY }}
path: app/selfserve
- name: Setup Snyk
uses: snyk/actions/setup@master
- name: Scan selfserve repository
run: snyk test --sarif-file-output=snyk-results.sarif
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
continue-on-error: true

- name: Upload Results to GitHub Code Scanning
if: ${{ always() }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: app/selfserve/snyk-results.sarif

dependency-scan-internal:
if: github.event_name == 'schedule' || inputs.project == 'internal'
name: Internal
runs-on: ubuntu-latest
defaults:
run:
working-directory: app/internal
env:
# Temporary until this repository becomes a mono-repository: https://dvsa.atlassian.net/browse/VOL-4961.
REMOTE_REPOSITORY: dvsa/olcs-internal
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REMOTE_REPOSITORY }}
path: app/internal
- name: Setup Snyk
uses: snyk/actions/setup@master
- name: Scan internal repository
run: snyk test --sarif-file-output=snyk-results.sarif
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
continue-on-error: true
gabrielg2020 marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload Results to GitHub Code Scanning
if: ${{ always() }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: app/internal/snyk-results.sarif
33 changes: 33 additions & 0 deletions .github/workflows/security-terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Security Terraform

on:
workflow_call:
schedule:
# Weekly on Monday at 00:00 UTC
- cron: 0 0 * * 1

env:
TRIVY_TF_EXCLUDE_DOWNLOADED_MODULES: true

jobs:
terraform-scan:
name: Terraform Scan
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Scan Terraform
uses: aquasecurity/trivy-action@master
with:
exit-code: 1
scan-ref: "infra/terraform"
scan-type: "config"
format: "sarif"
output: "trivy-results.sarif"

- name: Upload Results to GitHub Code Scanning
if: ${{ always() }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"