Skip to content

Commit 29564c3

Browse files
author
user
committed
Make verification script buildserver friendly
Add better argument parsing for locked down files verification script which accepts --whitelist <commit> and --import-gpg-keys arguments. The default settings are supposed to work on the build server without importing the gpg keys from the trusted_keys.pub file and running with a hardcoded whitelist commit. Make the CI workflow use these arguments as it is supposed to in .github.
1 parent 5d41b8a commit 29564c3

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

.github/workflows/verify-locked-down-signatures.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
# Prepare enough depth for diffs with master
2121
git fetch --depth="$(( commits + 1 ))" origin ${{ github.head_ref }} master
2222
fi
23-
ci/verify-locked-down-signatures.sh origin/master
23+
ci/verify-locked-down-signatures.sh --import-gpg-keys --whitelist origin/master

ci/verify-locked-down-signatures.sh

+34-8
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,49 @@
22
set -eu
33
shopt -s nullglob
44
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5-
# Import the trusted keys that we verify with
6-
GNUPGHOME=$(mktemp -d)
7-
gpg --import --armor $SCRIPT_DIR/trusted_keys.pub
8-
5+
# In the CI environment we would like to import trusted public keys from a file, but not in our build environment
6+
import_gpg_keys="false"
97
# The policy of enforcing lockfiles to be signed was not in place before this commit and as such some of the commits before are not signed
10-
# The whitelisted commit can be set in order to allow github actions to only check since origin/master
11-
WHITELIST_COMMIT=${1:-"origin/master"}
8+
# The whitelisted commit can be set in order to allow github actions to only check changes since origin/master
9+
whitelisted_commit="5d41b8a1d9745fbb3ff81ea6ea2eb8f202ca7ed0"
10+
11+
while [ ! $# -eq 0 ]; do
12+
case "$1" in
13+
"--import-gpg-keys")
14+
import_gpg_keys="true"
15+
;;
16+
"--whitelist")
17+
whitelisted_commit="$2"
18+
shift
19+
;;
20+
-*)
21+
echo "Unknown option \"$1\"
22+
The options are --import-gpg-keys and --whitelist"
23+
exit 1
24+
;;
25+
*)
26+
echo "Unknown argument
27+
The options are --import-gpg-keys and --whitelist"
28+
exit 1
29+
;;
30+
esac
31+
shift
32+
done
33+
34+
if [[ "$import_gpg_keys" == "true" ]]; then
35+
GNUPGHOME=$(mktemp -d)
36+
gpg --import --armor $SCRIPT_DIR/trusted_keys.pub
37+
fi
1238

1339
unsigned_commits_exist=0
1440
LOCKED_DOWN_FILES=$(cat $SCRIPT_DIR/locked_down_files.txt)
1541
for locked_file in $LOCKED_DOWN_FILES;
1642
do
17-
locked_file_commit_hashes=$(git rev-list --oneline $WHITELIST_COMMIT..HEAD $SCRIPT_DIR/../$locked_file | awk '{print $1}')
43+
locked_file_commit_hashes=$(git rev-list --oneline $whitelisted_commit..HEAD $SCRIPT_DIR/../$locked_file | awk '{print $1}')
1844
for commit in $locked_file_commit_hashes;
1945
do
2046
if ! $(git verify-commit $commit 2> /dev/null); then
21-
echo Commit $commit changed $locked_file and is not signed.
47+
echo Commit $commit which changed $locked_file is not signed.
2248
unsigned_commits_exist=1
2349
fi
2450
done

0 commit comments

Comments
 (0)