Skip to content

[RS-XX]: Update download-artifact and upload-artifact versions, as th… #108

[RS-XX]: Update download-artifact and upload-artifact versions, as th…

[RS-XX]: Update download-artifact and upload-artifact versions, as th… #108

# Copyright 2023 Airbus
#
# 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: Build ACQ-Simulator
on:
push:
paths:
- 'rs-container/docker_acqsimulator/**'
- 'rs-container/docker_s3_ipf_acq/**'
- '.github/workflows/build-acqsimulator.yaml'
branches:
- '!main'
- 'release/**'
- 'develop**'
workflow_call:
secrets:
WERUM_ARTIFACTORY_USER:
description: 'Username to log into Artifactory'
required: true
WERUM_ARTIFACTORY_PASSWORD:
description: 'Password to log into Artifactory'
required: true
GITGUARDIAN_API_KEY:
description: 'API Key for GitGuardian'
required: true
workflow_dispatch:
env:
REGISTRY_BASE: artifactory.coprs.esa-copernicus.eu
ARTIFACTORY_PROJECT: rs-docker-private
USERNAME: ${{ secrets.WERUM_ARTIFACTORY_USER }}
PASSWORD: ${{ secrets.WERUM_ARTIFACTORY_PASSWORD }}
jobs:
build-acq-simulator:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF} | cut -d / -f3-)"
id: extract_branch
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Buildx
uses: docker/setup-buildx-action@v1
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all history so multiple commits can be scanned
- name: GitGuardian scan
uses: GitGuardian/ggshield-action@master
env:
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
- name: Login to Github Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY_BASE }}/${{ env.ARTIFACTORY_PROJECT }}
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY_BASE }}/${{ env.ARTIFACTORY_PROJECT }}/rs-core-acqsimulator
- name: Copy over scripts from docker_s3_ipf_acq
run: |
cp "${GITHUB_WORKSPACE}/rs-container/docker_s3_ipf_acq/files/S3ACQWrapperScript.sh" "${GITHUB_WORKSPACE}/rs-container/docker_acqsimulator/files/S3ACQWrapperScript.sh"
cp "${GITHUB_WORKSPACE}/rs-container/docker_s3_ipf_acq/files/convertL0OrderISP.py" "${GITHUB_WORKSPACE}/rs-container/docker_acqsimulator/files/convertL0OrderISP.py"
cp "${GITHUB_WORKSPACE}/rs-container/docker_s3_ipf_acq/files/convertL0OrderTF.py" "${GITHUB_WORKSPACE}/rs-container/docker_acqsimulator/files/convertL0OrderTF.py"
- name: Build image
uses: docker/build-push-action@v2
with:
load: true
context: ./rs-container/docker_acqsimulator
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BRANCH=${{ steps.extract_branch.outputs.branch }}
- name: Scan image
uses: anchore/scan-action@v2
id: scan
with:
image: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
acs-report-enable: true
severity-cutoff: critical
- name: Upload Anchore scan SARIF report
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
- name: Upload Anchore scan json report
uses: actions/upload-artifact@v4
with:
name: vulnerabilities-acqsimulator
path: ${{ steps.scan.outputs.vulnerabilities }}
- name: Push image
run: |
docker push ${{ fromJSON(steps.meta.outputs.json).tags[0] }};
generate-reports-acqsimulator:
needs: build-acq-simulator
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Download json report from build jobs
uses: actions/download-artifact@v4
with:
name: vulnerabilities-acqsimulator
- name: Generate CSV and intermediate HTML report
run: |
echo "SEVERITY;ID;PACKAGE;VERSION;LINK" > vulnerabilities.csv
cat vulnerabilities.json | jq -r '.matches[] | "\(.vulnerability.severity);\(.vulnerability.id);\(.artifact.name);\(.artifact.version);\(.vulnerability.links[0])"' >> vulnerabilities.csv
echo -e '<table>\n<thead>\n<tr class="header">\n<th><p>SEVERITY</p></th>\n<th><p>ID</p></th>\n<th><p>PACKAGE</p></th>\n<th><p>VERSION</p></th>\n</tr>\n</thead>\n<tbody>' > vulnerabilities.html
cat vulnerabilities.json | jq -r '.matches[] | "<tr>;<td><p>\(.vulnerability.severity)</p></td>;<td><p><a href=\"\(.vulnerability.links[0])\">\(.vulnerability.id)</a></p></td>;<td><p>\(.artifact.name)</p></td>;<td><p>\(.artifact.version)</p></td>;</tr>"' | tr -s ';' '\n' | sed 's!><p>Negligible! style="background-color:#FFFFFF;"><p>Negligible!g' | sed 's!><p>Low! style="background-color:#FFFC9E;"><p>Low!g' | sed 's!><p>Medium! style="background-color:#FE996B;"><p>Medium!g' | sed 's!><p>High! style="background-color:#FD6864;"><p>High!g' | sed 's!><p>Critical! style="background-color:#FE0000;"><p>Critical!g' >> vulnerabilities.html
echo -e '</tbody>\n</table>' >> vulnerabilities.html
- name: Convert HTLM to PDF
uses: docker://ghcr.io/coprs/reference-system:dependencies_wkhtmltopdf
with:
args: vulnerabilities.html vulnerabilities.pdf
- name: Upload Anchore scan reports
uses: actions/upload-artifact@v4
with:
name: vulnerabilities-acqsimulator
path: |
vulnerabilities.csv
vulnerabilities.pdf