Skip to content

Commit

Permalink
fix(trivy): add trivy-db and trivy-java-db sync
Browse files Browse the repository at this point in the history
  • Loading branch information
g-iannelli committed Sep 26, 2024
1 parent b821298 commit b78623e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
52 changes: 38 additions & 14 deletions .github/workflows/sync-trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,43 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Login to SIGHUP new Registry
uses: docker/login-action@v3
with:
registry: registry.sighup.io
username: ${{ secrets.SIGHUP_REGISTRY_USERNAME }}
password: ${{ secrets.SIGHUP_REGISTRY_PASSWORD }}
- name: Install yq
- name: Install skopeo
run: |
sudo apt-get update && sudo apt-get install -yqq wget
sudo wget -q https://github.com/mikefarah/yq/releases/download/v4.19.1/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Iterate
sudo apt-get update && sudo apt-get install -yqq skopeo
# As trivy-db and trivy-java-db are OCI artefacts, docker pull doesn't work
- name: Sync Trivy DBs
run: |
yq --version
docker run --rm quay.io/skopeo/stable:v1.13 --version
./single_sync.sh modules/trivy/images.yml false
skopeo login --username ${{ secrets.SIGHUP_REGISTRY_USERNAME }} registry.sighup.io -p ${{ secrets.SIGHUP_REGISTRY_PASSWORD }}
set -x
sync_attempt=0
trivy_db_break=0
trivy_java_db_break=0
while [ $((sync_attempt)) -lt 10 ]
do
if [ $((trivy_db_break)) -eq 0 ]
then
if skopeo copy docker://ghcr.io/aquasecurity/trivy-db:2 docker://registry.sighup.io/fury-secured/aquasecurity/trivy-db:2
then
trivy_db_break=1
fi
fi
if [ $((trivy_java_db_break)) -eq 0 ]
then
if skopeo copy docker://ghcr.io/aquasecurity/trivy-java-db:1 docker://registry.sighup.io/fury-secured/aquasecurity/trivy-java-db:1
then
trivy_java_db_break=1
fi
fi
if [ $((trivy_db_break)) -eq 1 ] && [ $((trivy_java_db_break)) -eq 1 ]
then
break
fi
sync_attempt=$((sync_attempt + 1))
sleep 120
done
15 changes: 0 additions & 15 deletions modules/trivy/images.yml

This file was deleted.

0 comments on commit b78623e

Please sign in to comment.