From 8b0b9944d72bb4a552409aff61cc7181664d60ab Mon Sep 17 00:00:00 2001 From: "(Holloway) Chew, Kean Ho" Date: Fri, 22 Sep 2023 14:24:13 +0800 Subject: [PATCH] automataCI: added checksum safety against directory targets There may be possibilities of directories being as one of the package target (e.g. PyPi). Hence, the checksum function must have a safety check against such scenario. Let's do this. This patch adds safety check against directory-type targets during Release Job checkum executions. Co-authored-by: Galyna, Cory <124406765+corygalyna@users.noreply.github.com> Co-authored-by: (Holloway) Chew, Kean Ho Signed-off-by: (Holloway) Chew, Kean Ho --- automataCI/_release-functions_unix-any.sh | 5 +++++ automataCI/_release-functions_windows-any.ps1 | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/automataCI/_release-functions_unix-any.sh b/automataCI/_release-functions_unix-any.sh index e5d333ba..2ae004fa 100644 --- a/automataCI/_release-functions_unix-any.sh +++ b/automataCI/_release-functions_unix-any.sh @@ -73,6 +73,11 @@ RELEASE::run_checksum_seal() { # shasum all files for TARGET in "${PROJECT_PATH_ROOT}/${PROJECT_PATH_PKG}"/*; do + if [ -d "$TARGET" ]; then + OS::print_status warning "${TARGET} is a directory. Skipping...\n" + continue + fi + if [ ! -z "$PROJECT_RELEASE_SHA256" ]; then OS::print_status info "sha256 checksuming $TARGET\n" __value="$(SHASUM::create_file "$TARGET" "256")" diff --git a/automataCI/_release-functions_windows-any.ps1 b/automataCI/_release-functions_windows-any.ps1 index 29b5501c..bb5b67fa 100644 --- a/automataCI/_release-functions_windows-any.ps1 +++ b/automataCI/_release-functions_windows-any.ps1 @@ -76,6 +76,11 @@ function RELEASE-Run-Checksum-Seal { # shasum all files foreach ($TARGET in (Get-ChildItem -Path "${env:PROJECT_PATH_ROOT}\${env:PROJECT_PATH_PKG}")) { + if (Test-Path -PathType Container -Path "${TARGET}") { + OS-Print-Status warning "${TARGET} is a directory. Skipping..." + continue + } + if (-not ([string]::IsNullOrEmpty(${env:PROJECT_RELEASE_SHA256}))) { OS-Print-Status info "sha256 checksuming ${TARGET}" $__value = SHASUM-Checksum-File $TARGET.FullName "256"