mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
ffe950bbc7
1ac454a3844b9b8389de0f660fa9455c0efa7140 Enable ShellCheck rules (Hennadii Stepanov) Pull request description: Enable some simple ShellCheck rules. Note for reviewers: `bash` and `shellcheck` on macOS are different from ones on Ubuntu. For local tests the latest `shellcheck` version 0.6.0 should be used (see #15166). ACKs for top commit: practicalswift: utACK 1ac454a3844b9b8389de0f660fa9455c0efa7140 dongcarl: utACK 1ac454a fanquake: ACK 1ac454a3844b9b8389de0f660fa9455c0efa7140 Tree-SHA512: 8d0a3a5c09fe1a0c22120178f5e6b80f81f746f8c3356b7701ff301c117acb2edea8fe08f08fb54ed73f94b1617515fb239fa28e7ab4121f74872e6494b6f20e
66 lines
2.4 KiB
Bash
Executable File
66 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (c) 2014-2016 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
export LC_ALL=C
|
|
INPUT=$(cat /dev/stdin)
|
|
VALID=false
|
|
REVSIG=false
|
|
IFS='
|
|
'
|
|
if [ "$BITCOIN_VERIFY_COMMITS_ALLOW_SHA1" = 1 ]; then
|
|
GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
|
|
else
|
|
# Note how we've disabled SHA1 with the --weak-digest option, disabling
|
|
# signatures - including selfsigs - that use SHA1. While you might think that
|
|
# collision attacks shouldn't be an issue as they'd be an attack on yourself,
|
|
# in fact because what's being signed is a commit object that's
|
|
# semi-deterministically generated by untrusted input (the pull-req) in theory
|
|
# an attacker could construct a pull-req that results in a commit object that
|
|
# they've created a collision for. Not the most likely attack, but preventing
|
|
# it is pretty easy so we do so as a "belt-and-suspenders" measure.
|
|
GPG_RES=""
|
|
for LINE in $(gpg --version); do
|
|
case "$LINE" in
|
|
"gpg (GnuPG) 1.4.1"*|"gpg (GnuPG) 2.0."*)
|
|
echo "Please upgrade to at least gpg 2.1.10 to check for weak signatures" > /dev/stderr
|
|
GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null)"
|
|
;;
|
|
# We assume if you're running 2.1+, you're probably running 2.1.10+
|
|
# gpg will fail otherwise
|
|
# We assume if you're running 1.X, it is either 1.4.1X or 1.4.20+
|
|
# gpg will fail otherwise
|
|
esac
|
|
done
|
|
[ "$GPG_RES" = "" ] && GPG_RES="$(printf '%s\n' "$INPUT" | gpg --trust-model always --weak-digest sha1 "$@" 2>/dev/null)"
|
|
fi
|
|
for LINE in $GPG_RES; do
|
|
case "$LINE" in
|
|
"[GNUPG:] VALIDSIG "*)
|
|
while read KEY; do
|
|
[ "${LINE#?GNUPG:? VALIDSIG * * * * * * * * * }" = "$KEY" ] && VALID=true
|
|
done < ./contrib/verify-commits/trusted-keys
|
|
;;
|
|
"[GNUPG:] REVKEYSIG "*)
|
|
[ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1
|
|
REVSIG=true
|
|
GOODREVSIG="[GNUPG:] GOODSIG ${LINE#* * *}"
|
|
;;
|
|
"[GNUPG:] EXPKEYSIG "*)
|
|
[ "$BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG" != 1 ] && exit 1
|
|
REVSIG=true
|
|
GOODREVSIG="[GNUPG:] GOODSIG ${LINE#* * *}"
|
|
;;
|
|
esac
|
|
done
|
|
if ! $VALID; then
|
|
exit 1
|
|
fi
|
|
if $VALID && $REVSIG; then
|
|
printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null | grep "^\[GNUPG:\] \(NEWSIG\|SIG_ID\|VALIDSIG\)"
|
|
echo "$GOODREVSIG"
|
|
else
|
|
printf '%s\n' "$INPUT" | gpg --trust-model always "$@" 2>/dev/null
|
|
fi
|