From 0e01325f3993ef2a06fe76208ab9572a6242adca Mon Sep 17 00:00:00 2001 From: jasonjung Date: Mon, 4 Nov 2024 14:55:47 -0800 Subject: [PATCH] fix: fix vhd_name env var for trivy scan --- .pipelines/templates/.builder-release-template.yaml | 1 + vhdbuilder/packer/test-scan-and-cleanup.sh | 1 + vhdbuilder/packer/trivy-scan.sh | 6 +++--- vhdbuilder/packer/vhd-scanning.sh | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 91546407a6e..ddd74852cf4 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -159,6 +159,7 @@ steps: SYSTEM_COLLECTIONURI: $(System.CollectionUri) SYSTEM_TEAMPROJECT: $(System.TeamProject) BUILD_RUN_NUMBER: $(Build.BuildNumber) + VHD_ARTIFACT_NAME: ${{ parameters.artifactName }} - task: PublishPipelineArtifact@0 condition: always() diff --git a/vhdbuilder/packer/test-scan-and-cleanup.sh b/vhdbuilder/packer/test-scan-and-cleanup.sh index 03e66eba548..a7afa545a54 100755 --- a/vhdbuilder/packer/test-scan-and-cleanup.sh +++ b/vhdbuilder/packer/test-scan-and-cleanup.sh @@ -13,6 +13,7 @@ required_env_vars=( "AZURE_MSI_RESOURCE_STRING" "UMSI_CLIENT_ID" "BUILD_RUN_NUMBER" + "VHD_ARTIFACT_NAME" ) for v in "${required_env_vars[@]}"; do diff --git a/vhdbuilder/packer/trivy-scan.sh b/vhdbuilder/packer/trivy-scan.sh index 2424ea41e69..7f244a7b3fd 100644 --- a/vhdbuilder/packer/trivy-scan.sh +++ b/vhdbuilder/packer/trivy-scan.sh @@ -18,7 +18,7 @@ ARCHITECTURE=${4} SIG_CONTAINER_NAME=${5} STORAGE_ACCOUNT_NAME=${6} ENABLE_TRUSTED_LAUNCH=${7} -VHD_NAME=${8} +VHD_ARTIFACT_NAME=${8} SKU_NAME=${9} KUSTO_ENDPOINT=${10} KUSTO_DATABASE=${11} @@ -144,7 +144,7 @@ retrycmd_if_failure 10 30 600 ./trivy --scanners vuln rootfs -f json --db-reposi if [[ -f ${TRIVY_REPORT_ROOTFS_JSON_PATH} ]]; then ./vuln-to-kusto-vhd scan-report \ --vhd-buildrunnumber=${BUILD_RUN_NUMBER} \ - --vhd-vhdname="${VHD_NAME}" \ + --vhd-vhdname="${VHD_ARTIFACT_NAME}" \ --vhd-ossku="${OS_SKU}" \ --vhd-osversion="${OS_VERSION}" \ --vhd-skuname="${SKU_NAME}" \ @@ -172,7 +172,7 @@ for CONTAINER_IMAGE in $IMAGE_LIST; do if [[ -f ${TRIVY_REPORT_IMAGE_JSON_PATH} ]]; then ./vuln-to-kusto-vhd scan-report \ --vhd-buildrunnumber=${BUILD_RUN_NUMBER} \ - --vhd-vhdname="${VHD_NAME}" \ + --vhd-vhdname="${VHD_ARTIFACT_NAME}" \ --vhd-ossku="${OS_SKU}" \ --vhd-osversion="${OS_VERSION}" \ --vhd-skuname="${SKU_NAME}" \ diff --git a/vhdbuilder/packer/vhd-scanning.sh b/vhdbuilder/packer/vhd-scanning.sh index 4e75bf67070..aa7d0934688 100755 --- a/vhdbuilder/packer/vhd-scanning.sh +++ b/vhdbuilder/packer/vhd-scanning.sh @@ -99,7 +99,7 @@ az vm run-command invoke \ "SIG_CONTAINER_NAME"=${SIG_CONTAINER_NAME} \ "STORAGE_ACCOUNT_NAME"=${STORAGE_ACCOUNT_NAME} \ "ENABLE_TRUSTED_LAUNCH"=${ENABLE_TRUSTED_LAUNCH} \ - "VHD_NAME"=${VHD_NAME} \ + "VHD_ARTIFACT_NAME"=${VHD_ARTIFACT_NAME} \ "SKU_NAME"=${SKU_NAME} \ "KUSTO_ENDPOINT"=${KUSTO_ENDPOINT} \ "KUSTO_DATABASE"=${KUSTO_DATABASE} \