Skip to content

Commit 720f300

Browse files
committed
Fix shellshock warnings and amend based on reviews
Remove multiple shellshock warnings and update naming based on review comments.
1 parent 0a146e6 commit 720f300

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

ci/verify-locked-down-signatures.sh

+15-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -eu
33
shopt -s nullglob
44

55
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
readonly SCRIPT_DIR
67

78
# In the CI environment we would like to import trusted public keys from a file,
89
# but not in our build environment
@@ -34,8 +35,9 @@ done
3435

3536
if [[ "$import_gpg_keys" == "true" ]]; then
3637
GNUPGHOME=$(mktemp -d)
37-
for key in $SCRIPT_DIR/keys/*; do
38-
gpg --import $key
38+
export GNUPGHOME
39+
for key in "$SCRIPT_DIR"/keys/*; do
40+
gpg --import "$key"
3941
done
4042
fi
4143

@@ -47,23 +49,24 @@ fi
4749
# that follows the `paths` key.
4850
# It uses `tr` in order to turn the multi-lined file into a single-line that sed can parse
4951
# correctly. This is done by replacing all new-lines with a `;`
50-
SEPARATOR=';'
51-
locked_down_files=$(cat $SCRIPT_DIR/../.github/workflows/verify-locked-down-signatures.yml \
52-
| tr '\n' $SEPARATOR \
52+
readonly SEPARATOR=';'
53+
locked_down_paths=$(\
54+
< "$SCRIPT_DIR/../.github/workflows/verify-locked-down-signatures.yml" tr '\n' $SEPARATOR \
5355
| sed "s/.*paths:$SEPARATOR\(\(\s*-\s[a-zA-Z\/\.-]*$SEPARATOR\)*\).*/\1/" \
5456
| tr $SEPARATOR '\n' \
5557
| awk '{print $2}')
58+
readonly locked_down_paths
5659

5760
unsigned_commits_exist=0
58-
for locked_file in $locked_down_files; do
61+
for locked_path in $locked_down_paths;
62+
do
63+
locked_path_commit_hashes=$(git rev-list --oneline "$whitelisted_commit"..HEAD \
64+
"$SCRIPT_DIR/../$locked_path" | awk '{print $1}')
5965

60-
locked_file_commit_hashes=$(git rev-list --oneline $whitelisted_commit..HEAD \
61-
$SCRIPT_DIR/../$locked_file | awk '{print $1}')
62-
63-
for commit in $locked_file_commit_hashes;
66+
for commit in $locked_path_commit_hashes;
6467
do
65-
if ! $(git verify-commit $commit 2> /dev/null); then
66-
echo Commit $commit which changed $locked_file is not signed.
68+
if ! git verify-commit "$commit" 2> /dev/null; then
69+
echo "Commit $commit which changed $locked_path is not signed."
6770
unsigned_commits_exist=1
6871
fi
6972
done

0 commit comments

Comments
 (0)