diff --git a/.github/workflows/trivy-release.yml b/.github/workflows/trivy-release.yml new file mode 100644 index 000000000..8981cea79 --- /dev/null +++ b/.github/workflows/trivy-release.yml @@ -0,0 +1,25 @@ +name: trivy security scans (release) +on: + schedule: + - cron: '0 17 * * *' + workflow_dispatch: + +jobs: + trivy-repo: + runs-on: ubuntu-latest + name: trivy scan (release composer/yarn dependencies) + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Run trivy scanner on repository + run: make test_trivy_repo TRIVY_TARGET_BRANCH=origin/release TRIVY_EXIT_CODE=1 + trivy-docker: + runs-on: ubuntu-latest + name: trivy scan (release docker image) + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Run trivy scanner on release docker image + run: make test_trivy_docker TRIVY_TARGET_DOCKER_IMAGE=ghcr.io/shaarli/shaarli:release diff --git a/Makefile b/Makefile index 8f8d335b3..487241578 100644 --- a/Makefile +++ b/Makefile @@ -199,6 +199,8 @@ TRIVY_VERSION=0.44.0 TRIVY_EXIT_CODE=1 # default docker image to scan with trivy TRIVY_TARGET_DOCKER_IMAGE=ghcr.io/shaarli/shaarli:latest +# branch on which test_trivy_repo should be run. leave undefined for the current branch +#TRIVY_TARGET_BRANCH=origin/release ### download trivy vulneravbility scanner download_trivy: @@ -211,5 +213,9 @@ test_trivy_docker: download_trivy ### run trivy vulnerability scanner on composer/yarn dependency trees test_trivy_repo: download_trivy +ifdef TRIVY_TARGET_BRANCH + git checkout $(TRIVY_TARGET_BRANCH) composer.lock + git checkout $(TRIVY_TARGET_BRANCH) yarn.lock +endif ./trivy --exit-code $(TRIVY_EXIT_CODE) fs composer.lock ./trivy --exit-code $(TRIVY_EXIT_CODE) fs yarn.lock diff --git a/README.md b/README.md index 348868d8a..8dc5fc515 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ _It is designed to be personal (single-user), fast and handy._ [![](https://img.shields.io/badge/release-v0.13.0-blue.svg)](https://github.com/shaarli/Shaarli/releases/tag/v0.13.0) [![](https://img.shields.io/badge/master-v0.13.x-blue.svg)](https://github.com/shaarli/Shaarli) [![](https://github.com/shaarli/Shaarli/actions/workflows/ci.yml/badge.svg)](https://github.com/shaarli/Shaarli/actions) +[![](https://github.com/shaarli/Shaarli/actions/workflows/trivy-release.yml/badge.svg)](https://github.com/shaarli/Shaarli/actions) [![Join the chat at https://gitter.im/shaarli/Shaarli](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/shaarli/Shaarli) [![Docker repository](https://img.shields.io/docker/pulls/shaarli/shaarli.svg)](https://github.com/shaarli/Shaarli/pkgs/container/shaarli)