Skip to content

Commit f9a3243

Browse files
pavithiran34mkulke
authored andcommitted
fix: Add shellcheck workflow and fix script issues
Add automated shellcheck validation via GitHub Actions and fix shellcheck issues in 5 shell scripts quotes, error handling Signed-off-by: pavithiran34 <[email protected]>
1 parent 19b727a commit f9a3243

6 files changed

Lines changed: 58 additions & 18 deletions

File tree

.github/workflows/shellcheck.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# https://github.com/marketplace/actions/shellcheck
2+
name: Check shell scripts
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
types:
8+
- opened
9+
- edited
10+
- reopened
11+
- synchronize
12+
13+
permissions: {}
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
shellcheck:
21+
name: shellcheck
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- name: Harden the runner (Audit all outbound calls)
25+
uses: step-security/harden-runner@f808768d1510423e83855289c910610ca9b43176 # v2.17.0
26+
with:
27+
egress-policy: audit
28+
29+
- name: Checkout the code
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
with:
32+
fetch-depth: 0
33+
persist-credentials: false
34+
35+
- name: Run ShellCheck
36+
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
37+
with:
38+
ignore_paths: "**/vendor/**"
39+

attestation-agent/ci/occlum.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
rm -rf occlum_instance && mkdir occlum_instance && cd occlum_instance
1+
#!/bin/bash
2+
rm -rf occlum_instance && mkdir occlum_instance && cd occlum_instance || exit
23

34
occlum init && rm -rf image
45

attestation-agent/coco_keyprovider/tools/generate_keys.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,38 @@ dump_keys() {
3131

3232
generate_keys() {
3333
repo=
34-
if [ -z $1 ]; then
34+
if [ -z "$1" ]; then
3535
repo="default"
3636
else
37-
repo=$1
37+
repo="$1"
3838
fi
3939

40-
create_keys 10 $repo
40+
create_keys 10 "$repo"
4141
dump_keys
4242
}
4343

4444
export_key() {
45-
local json_file=$1
46-
local uri=$2
47-
local output_path=$3
45+
local json_file="$1"
46+
local uri="$2"
47+
local output_path="$3"
4848

49-
cat $json_file | jq ".\"$uri\"" -r | base64 -d > $output_path
49+
cat "$json_file" | jq ".\"$uri\"" -r | base64 -d > "$output_path"
5050
}
5151

5252
main() {
53-
local dir=$(cd "$(dirname "$0")";pwd)
54-
local operation=$1
53+
local operation="$1"
5554
if [ -z "$operation" ]; then
5655
usage
5756
fi
5857

59-
if [ "$operation" = "generate" ] ;then
60-
generate_keys $2
58+
if [ "$operation" = "generate" ] ;then
59+
generate_keys "$2"
6160
elif [ "$operation" = "export" ] ;then
62-
if [ -z $4 ] ; then
61+
if [ -z "$4" ] ; then
6362
echo "[FAILED] Unmatched parameters"
6463
usage
6564
fi
66-
export_key $2 $3 $4
65+
export_key "$2" "$3" "$4"
6766
else
6867
echo "[FAILED] Unknown operation $operation"
6968
usage

image-rs/scripts/build_confidential_data_hub.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ set -o pipefail
1212
[ -n "${BASH_VERSION:-}" ] && set -o errtrace
1313
[ -n "${DEBUG:-}" ] && set -o xtrace
1414

15-
source $HOME/.cargo/env
15+
# shellcheck disable=SC1091
16+
source "$HOME/.cargo/env"
1617

1718
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
1819
CDH_DIR=$SCRIPT_DIR/../../confidential-data-hub
1920

20-
pushd $CDH_DIR
21+
pushd "$CDH_DIR"
2122

2223
make RESOURCE_PROVIDER=none KMS_PROVIDER=none RPC="${RPC}" LIBC=gnu
2324
make DESTDIR="${SCRIPT_DIR}/${RPC}" install LIBC=gnu

image-rs/scripts/install_offline_fs_kbc_files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -o errtrace
1212

1313
[ -n "${DEBUG:-}" ] && set -o xtrace
1414

15-
script_dir=$(dirname $(readlink -f $0))
15+
script_dir=$(dirname "$(readlink -f "$0")")
1616
test_resource_json_name="${2:-aa-offline_fs_kbc-resources.json}"
1717
resource_json_name="aa-offline_fs_kbc-resources.json"
1818
keys_json_name="aa-offline_fs_kbc-keys.json"

image-rs/scripts/install_test_signatures.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -o errtrace
1212

1313
[ -n "${DEBUG:-}" ] && set -o xtrace
1414

15-
script_dir="$(dirname $(readlink -f $0))"
15+
script_dir="$(dirname "$(readlink -f "$0")")"
1616
test_artifacts_dir="${script_dir}/../test_data/simple-signing-scheme"
1717
rootfs_quay_verification_directory="/etc/containers/quay_verification"
1818

0 commit comments

Comments
 (0)