mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 23:30:10 +01:00
s3_upload: improve url validation and error message
Ensure s3_upload correctly validates the S3 folder url by requiring it to end with /. This prevents wrong uploads to invalid paths, such as file urls. Also improve the error message. Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34255>
This commit is contained in:
parent
248edb43c3
commit
7959250d1e
4 changed files with 8 additions and 5 deletions
|
|
@ -230,7 +230,7 @@ cleanup
|
|||
# upload artifacts (lava jobs)
|
||||
if [ -n "$S3_RESULTS_UPLOAD" ]; then
|
||||
tar --zstd -cf results.tar.zst results/;
|
||||
s3_upload results.tar.zst https://"$S3_RESULTS_UPLOAD"/
|
||||
s3_upload results.tar.zst "https://${S3_RESULTS_UPLOAD}/"
|
||||
fi
|
||||
|
||||
# We still need to echo the hwci: mesa message, as some scripts rely on it, such
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ cp artifacts/ci-common/init-*.sh results/job-rootfs-overlay/
|
|||
cp "$SCRIPTS_DIR"/setup-test-env.sh results/job-rootfs-overlay/
|
||||
|
||||
tar zcf job-rootfs-overlay.tar.gz -C results/job-rootfs-overlay/ .
|
||||
s3_upload job-rootfs-overlay.tar.gz "https://${JOB_ARTIFACTS_BASE}"
|
||||
s3_upload job-rootfs-overlay.tar.gz "https://${JOB_ARTIFACTS_BASE}/"
|
||||
|
||||
# Prepare env vars for upload.
|
||||
section_switch variables "Environment variables passed through to device:"
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ replay_s3_upload_images() {
|
|||
__DESTINATION_FILE_PATH="$__S3_TRACES_PREFIX/${line##*-}"
|
||||
fi
|
||||
|
||||
s3_upload "$RESULTS_DIR/$__PREFIX/$line" "https://${__S3_PATH}/${__DESTINATION_FILE_PATH%/*}"
|
||||
s3_upload "$RESULTS_DIR/$__PREFIX/$line" "https://${__S3_PATH}/${__DESTINATION_FILE_PATH%/*}/"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,9 +288,12 @@ export -f get_tag_file
|
|||
s3_upload() {
|
||||
x_off
|
||||
local file=$1 s3_folder_url=$2
|
||||
if [ ! -f "$file" ] || [[ "$s3_folder_url" != https://* ]]
|
||||
if [ ! -f "$file" ] || [[ "$s3_folder_url" != https://*/ ]]
|
||||
then
|
||||
echo "s3_upload used incorrectly: first argument is the file, second argument is the s3 folder url"
|
||||
echo "Error: s3_upload incorrect usage."
|
||||
echo "Usage: s3_upload <file> <s3_folder_url>"
|
||||
echo " - <file> must exist."
|
||||
echo " - <s3_folder_url> must start with 'https://' and end with '/'."
|
||||
exit 1
|
||||
fi
|
||||
curl --fail --retry-all-errors --retry 4 --retry-delay 60 \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue