|
2 | 2 | set -eu
|
3 | 3 | shopt -s nullglob
|
4 | 4 | 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" |
9 | 7 | # 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 |
12 | 38 |
|
13 | 39 | unsigned_commits_exist=0
|
14 | 40 | LOCKED_DOWN_FILES=$(cat $SCRIPT_DIR/locked_down_files.txt)
|
15 | 41 | for locked_file in $LOCKED_DOWN_FILES;
|
16 | 42 | 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}') |
18 | 44 | for commit in $locked_file_commit_hashes;
|
19 | 45 | do
|
20 | 46 | 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. |
22 | 48 | unsigned_commits_exist=1
|
23 | 49 | fi
|
24 | 50 | done
|
|
0 commit comments