From 3430d05cdce820e11023ad85ae06c2e6413f4df4 Mon Sep 17 00:00:00 2001 From: Thilo Uttendorfer Date: Tue, 3 Oct 2023 11:58:37 +0200 Subject: [PATCH 1/5] Fix homebrew setup on ubuntu runners --- .github/workflows/main.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 835323b..0ee75ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: - name: Check out code uses: actions/checkout@v4 - name: Install BATS - run: "[[ -f /usr/local/bin/bats ]] && brew unlink bats || true ; brew install bats-core" + run: "[[ -f /home/linuxbrew/.linuxbrew/bin/brew ]] && eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\" || true ; [[ -f /usr/local/bin/bats ]] && brew unlink bats || true ; brew install bats-core" - name: Run BATS tests run: bats tests/ test-on-container-debian-ubuntu: diff --git a/README.md b/README.md index 3952c15..99e833a 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ The format is based on [Keep a Changelog][kac] and this project adheres to [Sema ## Contributing -Pull requests are welcome. The unit tests are written with https://github.com/bats-core/bats-core. Make use of the excellent tool `shellcheck` (https://www.shellcheck.net/). Run with `shellcheck -x -a aws-micro`. +Pull requests are welcome. The unit tests are written with https://github.com/bats-core/bats-core. Run with `bats tests/`. Make use of the excellent tool `shellcheck` (https://www.shellcheck.net/). Run with `shellcheck -x -a aws-micro`. ## License From 754e3b61e8bc54e014d9544b706da536460b44eb Mon Sep 17 00:00:00 2001 From: Thilo Uttendorfer Date: Tue, 3 Oct 2023 12:03:04 +0200 Subject: [PATCH 2/5] Fix bats on ubuntu --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ee75ad..673d4b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,7 +25,7 @@ jobs: - name: Install BATS run: "[[ -f /home/linuxbrew/.linuxbrew/bin/brew ]] && eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\" || true ; [[ -f /usr/local/bin/bats ]] && brew unlink bats || true ; brew install bats-core" - name: Run BATS tests - run: bats tests/ + run: "[[ -f /home/linuxbrew/.linuxbrew/bin/brew ]] && eval \"$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)\" || true ; bats tests/" test-on-container-debian-ubuntu: runs-on: ubuntu-latest container: ${{ matrix.container }} From d1b7293a28e24219c1975c44a002f566c512f36a Mon Sep 17 00:00:00 2001 From: Thilo Uttendorfer Date: Tue, 3 Oct 2023 13:44:56 +0200 Subject: [PATCH 3/5] Use checkout v3 for glibc compatibility --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 673d4b2..6da428c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,8 @@ jobs: container: ["ubuntu:22.04", "ubuntu:20.04", "ubuntu:18.04", "debian:12-slim", "debian:11-slim", "debian:10-slim"] steps: - name: Check out code - uses: actions/checkout@v4 + # use v3 for glibc compatibility with ubuntu:18.04 + uses: actions/checkout@v3 - name: Install dependencies and BATS run: "apt-get update && apt-get install -y openssl curl file bats xxd" - name: Run BATS tests From 3ad866e707fd5dd6596e6f9b7fa4719a371a039e Mon Sep 17 00:00:00 2001 From: Thilo Uttendorfer Date: Tue, 3 Oct 2023 18:02:17 +0200 Subject: [PATCH 4/5] Set digest explicitly to support rocky linux 9 --- utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.sh b/utils.sh index 7b51179..b990041 100644 --- a/utils.sh +++ b/utils.sh @@ -81,7 +81,7 @@ md5_base64() { sha256_hmac() { declare -r sig="$1" - openssl sha256 -mac HMAC -macopt "$sig" -hex | sed 's/.*(stdin)= //' + openssl sha256 -mac HMAC -sha256 -macopt "$sig" -hex | sed 's/.*(stdin)= //' } sha256() { From f2a541f554caf7b0b93e6588ff152bea7707edc6 Mon Sep 17 00:00:00 2001 From: Thilo Uttendorfer Date: Tue, 3 Oct 2023 18:11:44 +0200 Subject: [PATCH 5/5] Disable a few shellcheck warnings --- s3.sh | 3 +++ s3api.sh | 1 + sts.sh | 1 + 3 files changed, 5 insertions(+) diff --git a/s3.sh b/s3.sh index 2ee537d..a1d6513 100644 --- a/s3.sh +++ b/s3.sh @@ -33,6 +33,7 @@ s3_ls() { request_url="$(create_request_url "${service}" ls "${_arg_endpoint_url}" "${region}" "${bucket}" "${key}")" if [[ "${_arg_no_sign_request}" = "on" ]]; then + # shellcheck disable=SC2086 ${dryrun} curl ${curl_output} --fail "${request_url}" | "${formatter}" else headers=("host:$(get_host_from_request_url "$request_url")" "x-amz-content-sha256:${content_sha256}" "x-amz-date:${date}" "${security_token_header:-}") @@ -95,9 +96,11 @@ Error: Invalid argument type" # or (not yet implemented) if [[ "${_arg_no_sign_request}" = "on" ]]; then if [[ "${http_method}" == "PUT" ]]; then + # shellcheck disable=SC2086 ${dryrun} curl ${curl_output} --fail -X "${http_method}" "${request_url}" --data-binary "@${source}" -o /dev/null echo "upload: ${source} to s3://${bucket}/${key}" else + # shellcheck disable=SC2086 ${dryrun} curl ${curl_output} --fail "${request_url}" -o "${destination}" echo "download: ${source} to ${destination}" fi diff --git a/s3api.sh b/s3api.sh index 6b2b41e..e4fd873 100644 --- a/s3api.sh +++ b/s3api.sh @@ -17,6 +17,7 @@ s3api_create-bucket() { request_url="$(create_request_url "${service}" "" "${_arg_endpoint_url}" "${region}" "${bucket}" "")" if [[ "${_arg_no_sign_request}" = "on" ]]; then + # shellcheck disable=SC2086 ${dryrun} curl ${curl_output} --fail -X "${http_method}" "${request_url}" -H "Content-Length: 0" -o /dev/null else headers=("host:$(get_host_from_request_url "$request_url")" "x-amz-content-sha256:${content_sha256}" "x-amz-date:${date}" "${security_token_header:-}") diff --git a/sts.sh b/sts.sh index 4867844..22a2509 100644 --- a/sts.sh +++ b/sts.sh @@ -15,6 +15,7 @@ sts_assume-role() { content_sha256="$(sha256 "${body}")" if [[ "${_arg_no_sign_request}" = "on" ]]; then + # shellcheck disable=SC2086 ${dryrun} curl ${curl_output} --fail "${request_url}" --data "${body}" else headers=("host:$(get_host_from_request_url "$request_url")" "x-amz-date:${date}" "content-type:application/x-www-form-urlencoded;charset=utf-8" "${security_token_header:-}")