mod: update notationcli and azure-kv plugin version #23
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
on: | |
push: | |
branches: | |
- main | |
jobs: | |
patch: | |
runs-on: ubuntu-latest | |
#TODO: What if the image has already been patched? How do we know? | |
strategy: | |
fail-fast: false | |
matrix: | |
# provide relevant list of images to scan on each run | |
images: ['s3cexampleacr.azurecr.io/azure-voting-app-rust:v0.1.0-alpha'] # add more for microservices TODO later | |
steps: | |
- name: Login to Azure | |
id: login | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Login to Azure Container Registry | |
run: | | |
az acr login --name ${{ vars.ACR_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Generate Trivy Report | |
uses: aquasecurity/trivy-action@69cbbc0cbbf6a2b0bab8dcf0e9f2d7ead08e87e4 | |
with: | |
scan-type: 'image' | |
format: 'json' | |
output: 'report.json' | |
ignore-unfixed: true | |
vuln-type: 'os' | |
image-ref: ${{ matrix.images }} | |
- name: Check Vuln Count | |
id: vuln_count | |
run: | | |
report_file="report.json" | |
vuln_count=$(jq '.Results | length' "$report_file") | |
echo "vuln_count=$vuln_count" >> $GITHUB_OUTPUT | |
- name: Extract Patched Tag | |
id: extract_tag | |
run: | | |
imageName=$(echo ${{ matrix.images }} | cut -d ':' -f1) | |
current_tag=$(echo ${{ matrix.images }} | cut -d ':' -f2) | |
if [[ $current_tag == *-[0-9] ]]; then | |
numeric_tag=$(echo "$current_tag" | awk -F'-' '{print $NF}') | |
non_numeric_tag=$(echo "$current_tag" | sed "s#-$numeric_tag##g") | |
incremented_tag=$((numeric_tag+1)) | |
new_tag="$non_numeric_tag-$incremented_tag" | |
else | |
new_tag="$current_tag-1" | |
fi | |
echo "patched_tag=$new_tag" >> $GITHUB_OUTPUT | |
echo "imageName=$imageName" >> $GITHUB_OUTPUT | |
- name: Copa Action | |
if: steps.vuln_count.outputs.vuln_count != '0' | |
id: copa | |
uses: project-copacetic/[email protected] | |
with: | |
image: ${{ matrix.images }} | |
image-report: 'report.json' | |
patched-tag: ${{ steps.extract_tag.outputs.patched_tag }} | |
buildkit-version: 'v0.11.6' | |
# optional, default is latest | |
copa-version: '0.3.0' | |
- name: Docker Push Patched Image | |
id: push | |
if: steps.login.conclusion == 'success' | |
run: | | |
# docker push ${{ steps.copa.outputs.patched-image }} | |
echo "DIGEST=$(docker push ${{ steps.copa.outputs.patched-image }} | grep -oE 'sha256:[a-f0-9]{64}')" >> $GITHUB_OUTPUT | |
- name: Setup Notation | |
if: steps.push.conclusion == 'success' | |
uses: notaryproject/notation-action/setup@v1 | |
with: | |
version: "1.0.0" | |
- name: Notation Sign | |
if: steps.push.conclusion == 'success' | |
uses: notaryproject/notation-action/sign@v1 | |
with: | |
plugin_name: azure-kv | |
plugin_url: https://github.com/Azure/notation-azure-kv/releases/download/v1.0.1/notation-azure-kv_1.0.1_linux_amd64.tar.gz | |
plugin_checksum: f8a75d9234db90069d9eb5660e5374820edf36d710bd063f4ef81e7063d3810b | |
key_id: ${{ vars.KEY_ID }} | |
target_artifact_reference: ${{ steps.extract_tag.outputs.imageName }}@${{ steps.push.outputs.DIGEST }} | |
signature_format: cose | |
plugin_config: |- | |
name=${{ vars.CERT_NAME }} | |
self_signed=false |