Weekly CVE tests #72
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# THIS FILE IS GENERATED, PLEASE DO NOT EDIT. | |
# | |
# Copyright 2022 Flant JSC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: 'Weekly CVE tests' | |
on: | |
schedule: | |
- cron: '0 23 * * 5' | |
workflow_dispatch: | |
concurrency: | |
group: cve-daily | |
jobs: | |
skip_tests_repos: | |
name: Skip tests repos | |
runs-on: ubuntu-latest | |
if: ${{ true || github.repository == 'deckhouse/deckhouse' }} | |
steps: | |
- name: Do nothing | |
run: echo "Empty action to fulfil Github requirements." | |
fetch_tags_for_test: | |
name: Fetch release channel tags | |
runs-on: ubuntu-latest | |
needs: | |
- skip_tests_repos | |
steps: | |
# <template: checkout_full_step> | |
- name: Checkout sources | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# </template: checkout_full_step> | |
- name: Generate tag => channel matrix | |
id: tag_matrix | |
run: echo "tag_matrix=$(tools/cve/tag_map.sh)" >> $GITHUB_OUTPUT | |
outputs: | |
tag_matrix: ${{ steps.tag_matrix.outputs.tag_matrix }} | |
test_cve_report_main: | |
name: Main | |
needs: | |
- skip_tests_repos | |
runs-on: [ self-hosted, regular ] | |
env: | |
IMAGE: "dev-registry.deckhouse.io/sys/deckhouse-oss" | |
TAG: "main" | |
steps: | |
# <template: checkout_full_step> | |
- name: Checkout sources | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# </template: checkout_full_step> | |
# <template: login_dev_registry_step> | |
- name: Check dev registry credentials | |
id: check_dev_registry | |
env: | |
HOST: ${{secrets.DECKHOUSE_DEV_REGISTRY_HOST}} | |
run: | | |
if [[ -n $HOST ]]; then | |
echo "has_credentials=true" >> $GITHUB_OUTPUT | |
echo "web_registry_path=${{secrets.DECKHOUSE_DEV_REGISTRY_HOST }}/deckhouse/site" >> $GITHUB_OUTPUT | |
fi | |
- name: Login to dev registry | |
uses: docker/[email protected] | |
if: ${{ steps.check_dev_registry.outputs.has_credentials == 'true' }} | |
with: | |
registry: ${{ secrets.DECKHOUSE_DEV_REGISTRY_HOST }} | |
username: ${{ secrets.DECKHOUSE_DEV_REGISTRY_USER }} | |
password: ${{ secrets.DECKHOUSE_DEV_REGISTRY_PASSWORD }} | |
logout: false | |
# </template: login_dev_registry_step> | |
# <template: login_readonly_registry_step> | |
- name: Check readonly registry credentials | |
id: check_readonly_registry | |
env: | |
HOST: ${{secrets.DECKHOUSE_REGISTRY_READ_HOST}} | |
run: | | |
if [[ -n $HOST ]]; then | |
echo "has_credentials=true" >> $GITHUB_OUTPUT | |
echo "web_registry_path=${{secrets.DECKHOUSE_REGISTRY_READ_HOST }}/deckhouse/site" >> $GITHUB_OUTPUT | |
fi | |
- name: Login to readonly registry | |
uses: docker/[email protected] | |
if: ${{ steps.check_readonly_registry.outputs.has_credentials == 'true' }} | |
with: | |
registry: ${{ secrets.DECKHOUSE_REGISTRY_READ_HOST }} | |
username: ${{ secrets.DECKHOUSE_REGISTRY_READ_USER }} | |
password: ${{ secrets.DECKHOUSE_REGISTRY_READ_PASSWORD }} | |
logout: false | |
# </template: login_readonly_registry_step> | |
# <template: link_bin_step> | |
- name: Link binary cache | |
id: link_bin_step | |
run: | | |
ln -s ~/deckhouse-bin-cache bin | |
# </template: link_bin_step> | |
# <template: cve_tests> | |
- name: Checking out candi/image_versions.yml | |
run: | | |
echo "⚓️ 📤 Checking out candi/image_versions.yml from ${TAG}..." | |
git checkout --force "${TAG}" -- candi/image_versions.yml | |
- name: Run base images CVE tests on ${{env.TAG}} | |
run: | | |
echo "⚓️ 🏎 Running CVE tests on ${TAG}..." | |
make cve-base-images | |
- name: Run Deckhouse images CVE tests on ${{env.TAG}} | |
run: | | |
echo "⚓️ 🏎 Running Deckhouse images CVE tests on ${TAG}..." | |
make cve-report | |
- name: Rename report artifacts | |
if: success() | |
run: | | |
mv "out/base-images.html" "out/${TAG}_base-images.html" | |
mv "out/d8-images.html" "out/${TAG}_d8-images.html" | |
- name: Create fail artifact | |
if: failure() | |
run: | | |
echo "Trivy tests for ${TAG} have failed." > "out/${TAG}_test-failed.txt" | |
- name: Upload report artifacts | |
if: success() | |
uses: actions/[email protected] | |
with: | |
name: cve-reports | |
path: | | |
out/${{ env.TAG }}_base-images.html | |
out/${{ env.TAG }}_d8-images.html | |
- name: Upload fail artifact | |
if: failure() | |
uses: actions/[email protected] | |
with: | |
name: cve-reports | |
path: | | |
out/${{ env.TAG }}_test-failed.txt | |
# </template: cve_tests> | |
# <template: unlink_bin_step> | |
- name: Unlink binary cache | |
id: unlink_bin_step | |
if: always() | |
run: | | |
rm bin | |
# </template: unlink_bin_step> | |
test_cve_report_channels: | |
name: ${{ matrix.tag }} | |
needs: | |
- fetch_tags_for_test | |
strategy: | |
fail-fast: false | |
matrix: | |
tag: ${{ fromJson(needs.fetch_tags_for_test.outputs.tag_matrix) }} | |
runs-on: [ self-hosted, regular ] | |
steps: | |
# <template: checkout_full_step> | |
- name: Checkout sources | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
# </template: checkout_full_step> | |
# <template: login_dev_registry_step> | |
- name: Check dev registry credentials | |
id: check_dev_registry | |
env: | |
HOST: ${{secrets.DECKHOUSE_DEV_REGISTRY_HOST}} | |
run: | | |
if [[ -n $HOST ]]; then | |
echo "has_credentials=true" >> $GITHUB_OUTPUT | |
echo "web_registry_path=${{secrets.DECKHOUSE_DEV_REGISTRY_HOST }}/deckhouse/site" >> $GITHUB_OUTPUT | |
fi | |
- name: Login to dev registry | |
uses: docker/[email protected] | |
if: ${{ steps.check_dev_registry.outputs.has_credentials == 'true' }} | |
with: | |
registry: ${{ secrets.DECKHOUSE_DEV_REGISTRY_HOST }} | |
username: ${{ secrets.DECKHOUSE_DEV_REGISTRY_USER }} | |
password: ${{ secrets.DECKHOUSE_DEV_REGISTRY_PASSWORD }} | |
logout: false | |
# </template: login_dev_registry_step> | |
# <template: login_readonly_registry_step> | |
- name: Check readonly registry credentials | |
id: check_readonly_registry | |
env: | |
HOST: ${{secrets.DECKHOUSE_REGISTRY_READ_HOST}} | |
run: | | |
if [[ -n $HOST ]]; then | |
echo "has_credentials=true" >> $GITHUB_OUTPUT | |
echo "web_registry_path=${{secrets.DECKHOUSE_REGISTRY_READ_HOST }}/deckhouse/site" >> $GITHUB_OUTPUT | |
fi | |
- name: Login to readonly registry | |
uses: docker/[email protected] | |
if: ${{ steps.check_readonly_registry.outputs.has_credentials == 'true' }} | |
with: | |
registry: ${{ secrets.DECKHOUSE_REGISTRY_READ_HOST }} | |
username: ${{ secrets.DECKHOUSE_REGISTRY_READ_USER }} | |
password: ${{ secrets.DECKHOUSE_REGISTRY_READ_PASSWORD }} | |
logout: false | |
# </template: login_readonly_registry_step> | |
# <template: link_bin_step> | |
- name: Link binary cache | |
id: link_bin_step | |
run: | | |
ln -s ~/deckhouse-bin-cache bin | |
# </template: link_bin_step> | |
- name: Set repo and tag for matrix run | |
env: | |
matrix_tag: ${{ matrix.tag }} | |
run: | | |
echo "IMAGE=registry.deckhouse.io/deckhouse/fe" >> $GITHUB_ENV | |
echo "TAG=$(echo "${matrix_tag}" | grep -Eo "^\S+")" >> $GITHUB_ENV | |
# <template: cve_tests> | |
- name: Checking out candi/image_versions.yml | |
run: | | |
echo "⚓️ 📤 Checking out candi/image_versions.yml from ${TAG}..." | |
git checkout --force "${TAG}" -- candi/image_versions.yml | |
- name: Run base images CVE tests on ${{env.TAG}} | |
run: | | |
echo "⚓️ 🏎 Running CVE tests on ${TAG}..." | |
make cve-base-images | |
- name: Run Deckhouse images CVE tests on ${{env.TAG}} | |
run: | | |
echo "⚓️ 🏎 Running Deckhouse images CVE tests on ${TAG}..." | |
make cve-report | |
- name: Rename report artifacts | |
if: success() | |
run: | | |
mv "out/base-images.html" "out/${TAG}_base-images.html" | |
mv "out/d8-images.html" "out/${TAG}_d8-images.html" | |
- name: Create fail artifact | |
if: failure() | |
run: | | |
echo "Trivy tests for ${TAG} have failed." > "out/${TAG}_test-failed.txt" | |
- name: Upload report artifacts | |
if: success() | |
uses: actions/[email protected] | |
with: | |
name: cve-reports | |
path: | | |
out/${{ env.TAG }}_base-images.html | |
out/${{ env.TAG }}_d8-images.html | |
- name: Upload fail artifact | |
if: failure() | |
uses: actions/[email protected] | |
with: | |
name: cve-reports | |
path: | | |
out/${{ env.TAG }}_test-failed.txt | |
# </template: cve_tests> | |
# <template: unlink_bin_step> | |
- name: Unlink binary cache | |
id: unlink_bin_step | |
if: always() | |
run: | | |
rm bin | |
# </template: unlink_bin_step> | |
# send-email-report: | |
# name: Send weekly report | |
# needs: | |
# - test_cve_report_main | |
# | |
# - test_cve_report_channels | |
# | |
# if: success() || failure() | |
# runs-on: [ self-hosted, regular ] | |
# steps: | |
# - name: Clear output directory | |
# run: | | |
# rm -rf out/ | |
# - name: Download reports artifact | |
# uses: actions/download-artifact@v2 | |
# with: | |
# name: cve-reports | |
# path: out/ | |
# - name: Create report archive | |
# working-directory: out/ | |
# run: | | |
# zip -r cve-reports.zip ./* | |
# - name: Send report | |
# env: | |
# MAIL_API_TOKEN: ${{ secrets.MAIL_API_TOKEN }} | |
# MAIL_API_URL: ${{ secrets.MAIL_API_URL }} | |
# MAIL_API_TRIVY_SENDER: ${{ secrets.MAIL_API_TRIVY_SENDER }} | |
# MAIL_API_TRIVY_RECEIVER: ${{ secrets.MAIL_API_TRIVY_RECEIVER }} | |
# run: | | |
# curl -s --user "${MAIL_API_TOKEN}" \ | |
# "${MAIL_API_URL}" \ | |
# -F from="${MAIL_API_TRIVY_SENDER}" \ | |
# -F to="${MAIL_API_TRIVY_RECEIVER}" \ | |
# -F subject='Trivy reports' \ | |
# -F text='Hello! There are Weekly Trivy scan reports attached to this message.' \ | |
# -F attachment=@out/cve-reports.zip | |
# - name: Clear output directory | |
# run: | | |
# rm -rf out/ |