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

improve support fo sync linux/arm64 images #268

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1f8afa0
feat: replace dedicate workflow for each module sync with a matrix job
g-iannelli Nov 8, 2024
d0b6f2e
fix: rename sync-trivy workflow to trivy-db-sync
g-iannelli Nov 8, 2024
9005cb1
fix: use single_sync_v3 also for dry run job
g-iannelli Nov 8, 2024
191cca3
fix(cve): improve buildkit start error logging
g-iannelli Nov 8, 2024
58bd61b
chore(cve): scan multi arch images
g-iannelli Nov 8, 2024
ae4e422
chore(cve): patch multi arch images
g-iannelli Nov 8, 2024
e8b0798
fix(cve): wrong name to export image patched reports
g-iannelli Nov 11, 2024
33b7e4b
chore(cve): improve error handling
g-iannelli Nov 12, 2024
510af30
ci(sync): edit workflow trigger paths
g-iannelli Nov 12, 2024
ce750a8
docs(sync): update docs
g-iannelli Nov 13, 2024
2416a73
fix(cve): push patched image with skopeo to avoid tagging of single m…
g-iannelli Nov 14, 2024
9034c49
feat(cve): use github action caching for trivy databases
g-iannelli Nov 14, 2024
ed33e60
fix(dry-run): avoid triggering when edit cve-scan-patching stuffs
g-iannelli Nov 14, 2024
6e06926
fixup! feat(cve): use github action caching for trivy databases
g-iannelli Nov 14, 2024
c3fdd8e
fixup! feat(cve): use github action caching for trivy databases
g-iannelli Nov 14, 2024
46244cc
fixup! feat(cve): use github action caching for trivy databases
g-iannelli Nov 14, 2024
b344487
fix(cve): keep trivy scan cache
g-iannelli Nov 14, 2024
b9b670a
fixup! feat(cve): use github action caching for trivy databases
g-iannelli Nov 14, 2024
7922e32
fixup! feat(cve): use github action caching for trivy databases
g-iannelli Nov 14, 2024
e42aac2
feat(cve): cache kfs vendors manifests built
g-iannelli Nov 14, 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
174 changes: 127 additions & 47 deletions .github/workflows/cve-scan-and-patching.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ on:
- '!CVEs/MAINTENANCE.md'

jobs:
set_docker_config_env_var:
runs-on: ubuntu-latest
steps:
- name: set DOCKER_CONFIG
id: set_docker_config_env
run: |
echo "DOCKER_CONFIG=/tmp/${GITHUB_RUN_ID}/.docker" >> $GITHUB_OUTPUT
outputs:
docker_config: ${{ steps.set_docker_config_env.outputs.DOCKER_CONFIG }}
fetch_kfd_versions:
runs-on: ubuntu-latest
steps:
Expand All @@ -26,9 +35,56 @@ jobs:
kfd_versions_json: ${{ steps.set_output.outputs.KFD_VERSIONS_JSON }}
kfd_versions_list: ${{ steps.set_output.outputs.KFD_VERSIONS_JSON }}
today_date: ${{ steps.set_output.outputs.TODAY_DATE }}
install_tools:
runs-on: ubuntu-latest
needs:
- fetch_kfd_versions
steps:
- uses: actions/checkout@master
- name: cache tool used by jobs
id: cache_tools
uses: actions/cache@v4
with:
path: |
/tmp/.cache/trivy
/usr/local/bin/trivy
/usr/local/bin/furyctl
/usr/local/bin/buildctl
/usr/local/bin/copa
key: cve-scan-patching-tools-${{ needs.fetch_kfd_versions.outputs.today_date }}
- name: install tools required by jobs
if: steps.cache_tools.outputs.cache-hit != 'true'
run: |
sudo apt-get install wget apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
trivy --version
cp /usr/bin/trivy /usr/local/bin/trivy

wget https://github.com/sighupio/furyctl/releases/latest/download/furyctl-linux-amd64.tar.gz
tar -xzvf furyctl-linux-amd64.tar.gz -C /usr/local/bin/
furyctl version

wget https://github.com/moby/buildkit/releases/download/v0.16.0/buildkit-v0.16.0.linux-amd64.tar.gz
tar -xzvf buildkit-v0.16.0.linux-amd64.tar.gz -C /usr/local/bin/ --strip-components=1
buildctl --version

wget https://github.com/project-copacetic/copacetic/releases/download/v0.9.0/copa_0.9.0_linux_amd64.tar.gz
tar -xzvf copa_0.9.0_linux_amd64.tar.gz
chmod +x copa
sudo mv copa /usr/local/bin/
copa --version

cd CVEs
make trivy-download-db
scan_pre_patch:
runs-on: ubuntu-latest
needs: fetch_kfd_versions
needs:
- set_docker_config_env_var
- fetch_kfd_versions
- install_tools
continue-on-error: true
strategy:
# max-parallel: 3
Expand All @@ -43,24 +99,33 @@ jobs:
registry: registry.sighup.io
username: ${{ secrets.SIGHUP_REGISTRY_USERNAME }}
password: ${{ secrets.SIGHUP_REGISTRY_PASSWORD }}
- name: Install furyctl, trivy
run: |
sudo apt-get install wget apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
trivy --version

wget https://github.com/sighupio/furyctl/releases/latest/download/furyctl-linux-amd64.tar.gz
tar -xzvf furyctl-linux-amd64.tar.gz -C /usr/local/bin/
furyctl version
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- name: cache tools
uses: actions/cache@v4
with:
fail-on-cache-miss: true
path: |
/tmp/.cache/trivy
/usr/local/bin/trivy
/usr/local/bin/furyctl
/usr/local/bin/buildctl
/usr/local/bin/copa
key: cve-scan-patching-tools-${{ needs.fetch_kfd_versions.outputs.today_date }}
- name: cache KFD vendors built manifest for KFD ${{ matrix.kfd_version }}
uses: actions/cache@v4
with:
path: |
CVEs/${{ matrix.kfd_version }}/built.yaml
CVEs/${{ matrix.kfd_version }}/images.txt
key: kfd-${{ matrix.kfd_version }}-vendors-built-manifests
- name: Execute CVEs scan for KFD ${{ matrix.kfd_version }}
id: scan_pre_patch
run: |
cd CVEs
make trivy-download-db
make scan-pre-patch KFD_VERSIONS="${{ matrix.kfd_version }}"
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- name: publish CVE scan pre patch output files for KFD ${{ matrix.kfd_version }}
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -89,6 +154,9 @@ jobs:
patch:
runs-on: ubuntu-latest
needs:
- install_tools
- fetch_kfd_versions
- set_docker_config_env_var
- fetch_kfd_images_to_patch
continue-on-error: true
strategy:
Expand All @@ -103,51 +171,58 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- 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 buildkit, trivy and copa
run: |
sudo apt-get install wget apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
trivy --version

wget https://github.com/moby/buildkit/releases/download/v0.16.0/buildkit-v0.16.0.linux-amd64.tar.gz
tar -xzvf buildkit-v0.16.0.linux-amd64.tar.gz -C /usr/local/bin/ --strip-components=1
buildctl --version

wget https://github.com/project-copacetic/copacetic/releases/download/v0.8.0/copa_0.8.0_linux_amd64.tar.gz
tar -xzvf copa_0.8.0_linux_amd64.tar.gz
chmod +x copa
sudo mv copa /usr/local/bin/
copa --version
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- # Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64
- name: cache tools
uses: actions/cache@v4
with:
fail-on-cache-miss: true
path: |
/tmp/.cache/trivy
/usr/local/bin/trivy
/usr/local/bin/furyctl
/usr/local/bin/buildctl
/usr/local/bin/copa
key: cve-scan-patching-tools-${{ needs.fetch_kfd_versions.outputs.today_date }}
- name: Execute CVEs patching
id: patching
run: |
IMAGE_TO_PATCH=${{ matrix.image_to_patch }}
IMAGE_TO_PATCH_NORMALIZED=${IMAGE_TO_PATCH//[:\/]/_}
cd CVEs
mkdir -p reports
make trivy-download-db
DOCKER_CONFIG="${DOCKER_CONFIG}" make patch DRY_RUN=0 IMAGE_TO_PATCH="${IMAGE_TO_PATCH}" PATCH_REPORT_OUTPUT_FILE="reports/${IMAGE_TO_PATCH_NORMALIZED}.patched.md"

make patch DRY_RUN=0 \
IMAGE_TO_PATCH="${IMAGE_TO_PATCH}" \
PATCH_REPORT_OUTPUT_FILE="reports/${IMAGE_TO_PATCH_NORMALIZED}.patched.md"
echo "IMAGE_TO_PATCH_NORMALIZED=${IMAGE_TO_PATCH_NORMALIZED}" >> "$GITHUB_OUTPUT"
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- name: publish CVE patching report for ${{ matrix.image_to_patch }}
uses: actions/upload-artifact@v4
with:
name: patch-report-${{ steps.patching.outputs.IMAGE_TO_PATCH_NORMALIZED }}.md
if-no-files-found: ignore
path: |
CVEs/reports/*.patched.md
CVEs/reports/*.patched.*.md
scan_post_patch:
runs-on: ubuntu-latest
needs:
- install_tools
- set_docker_config_env_var
- fetch_kfd_versions
- patch
continue-on-error: true
Expand All @@ -163,25 +238,30 @@ jobs:
registry: registry.sighup.io
username: ${{ secrets.SIGHUP_REGISTRY_USERNAME }}
password: ${{ secrets.SIGHUP_REGISTRY_PASSWORD }}
- name: Install trivy
run: |
sudo apt-get install wget apt-transport-https gnupg
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb generic main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy
trivy --version
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- name: download CVE scan pre patch output files
uses: actions/download-artifact@v4
with:
path: CVEs
- name: cache tools
uses: actions/cache@v4
with:
fail-on-cache-miss: true
path: |
/tmp/.cache/trivy
/usr/local/bin/trivy
/usr/local/bin/furyctl
/usr/local/bin/buildctl
/usr/local/bin/copa
key: cve-scan-patching-tools-${{ needs.fetch_kfd_versions.outputs.today_date }}
- name: Execute CVEs scan post patch for KFD ${{ matrix.kfd_version }}
id: scan_post_patch
run: |
cd CVEs
find .
make trivy-download-db
make scan-post-patch KFD_VERSIONS="${{ matrix.kfd_version }}"
env:
DOCKER_CONFIG: ${{ needs.set_docker_config_env_var.outputs.docker_config}}
- name: publish CVE scan post patch output files for KFD ${{ matrix.kfd_version }}
uses: actions/upload-artifact@v4
with:
Expand All @@ -207,7 +287,7 @@ jobs:
with:
name: cve-patch-reports-by-image
path: |
reports/*.patched.md
reports/*.patched.*.md
- uses: geekyeggo/delete-artifact@v5
with:
name: |
Expand Down
30 changes: 27 additions & 3 deletions .github/workflows/dry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,43 @@ name: "Dry run"

on:
push:
paths:
- '.github/workflows/dry.yml'
- '.github/workflows/sync.yml'
- 'modules/**'
- '!README.md'
- '!single_sync.sh'
- '!single_sync_v2.sh'
- 'single_sync_v3.sh'

jobs:
fetch_modules_to_sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set output
id: set_output
run: |
MODULES_TO_SYNC_JSON=$(find modules -type d -mindepth 1 -maxdepth 1 | cut -d/ -f2 | sort | jq -R | jq -cs . )
echo "MODULES_TO_SYNC_JSON=${MODULES_TO_SYNC_JSON}" >> $GITHUB_OUTPUT
outputs:
modules_to_sync: ${{ steps.set_output.outputs.MODULES_TO_SYNC_JSON }}
sync:
runs-on: ubuntu-latest
needs: fetch_modules_to_sync
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.fetch_modules_to_sync.outputs.modules_to_sync) }}
steps:
- uses: actions/checkout@master
- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to SIGHUP new Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: registry.sighup.io
username: ${{ secrets.SIGHUP_REGISTRY_USERNAME }}
Expand All @@ -28,4 +52,4 @@ jobs:
run: |
yq --version
docker run --rm quay.io/skopeo/stable:v1.13 --version
./sync.sh --dry-run
./single_sync_v3.sh modules/${{ matrix.module }}/images.yml true
35 changes: 0 additions & 35 deletions .github/workflows/sync-auth.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/sync-aws.yml

This file was deleted.

Loading
Loading