File tree 6 files changed +39
-24
lines changed
6 files changed +39
-24
lines changed Original file line number Diff line number Diff line change
1
+ Tooling for verification of PGP signed commits
2
+ ----------------------------------------------
3
+
4
+ This is an incomplete work in progress, but currently includes a pre-push hook
5
+ script (` pre-push-hook.sh ` ) for maintainers to ensure that their own commits
6
+ are PGP signed (nearly always merge commits), as well as a script to verify
7
+ commits against a trusted keys list.
8
+
9
+
10
+ Using verify-commits.sh safely
11
+ ------------------------------
12
+
13
+ Remember that you can't use an untrusted script to verify itself. This means
14
+ that checking out code, then running ` verify-commits.sh ` against ` HEAD ` is
15
+ _ not_ safe, because the version of ` verify-commits.sh ` that you just ran could
16
+ be backdoored. Instead, you need to use a trusted version of verify-commits
17
+ prior to checkout to make sure you're checking out only code signed by trusted
18
+ keys:
19
+
20
+ git fetch origin && \
21
+ ./contrib/verify-commits/verify-commits.sh origin/master && \
22
+ git checkout origin/master
23
+
24
+ Note that the above isn't a good UI/UX yet, and needs significant improvements
25
+ to make it more convenient and reduce the chance of errors; pull-reqs
26
+ improving this process would be much appreciated.
Original file line number Diff line number Diff line change 1
- 586a29253dabec3ca0f1ccba9091daabd16b8411
2
- eddaba7b5692288087a926da5733e86b47274e4e
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
- INPUT=$( < /dev/stdin)
2
+ INPUT=$( cat /dev/stdin)
3
3
VALID=false
4
4
REVSIG=false
5
- IFS=$' \n '
5
+ IFS='
6
+ '
6
7
for LINE in $( echo " $INPUT " | gpg --trust-model always " $@ " 2> /dev/null) ; do
7
8
case " $LINE " in
8
9
" [GNUPG:] VALIDSIG " * )
@@ -13,10 +14,9 @@ for LINE in $(echo "$INPUT" | gpg --trust-model always "$@" 2>/dev/null); do
13
14
" [GNUPG:] REVKEYSIG " * )
14
15
[ " $BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG " != 1 ] && exit 1
15
16
while read KEY; do
16
- case " $LINE " in " [GNUPG:] REVKEYSIG ${KEY: 24 : 40 } " * )
17
+ case " $LINE " in " [GNUPG:] REVKEYSIG ${KEY# ???????????????????????? } " * )
17
18
REVSIG=true
18
- GOODREVSIG=" [GNUPG:] GOODSIG ${KEY: 24: 40} "
19
- ;;
19
+ GOODREVSIG=" [GNUPG:] GOODSIG ${KEY# ????????????????????????} "
20
20
esac
21
21
done < ./contrib/verify-commits/trusted-keys
22
22
;;
Original file line number Diff line number Diff line change 1
- 165e323d851cc87213c7673c6f278e87a6f2e752
1
+ 82bcf405f6db1d55b684a1f63a4aabad376cdad7
Original file line number Diff line number Diff line change 1
1
71A3B16735405025D447E8F274810B012346C9A6
2
- 1F4410F6A89268CE3197A84C57896D2FF8F0B657
3
- 01CDF4627A3B88AAE4A571C87588242FBE38D3A8
4
- AF8BE07C7049F3A26B239D5325B3083201782B2F
5
- 81291FA67D2C379A006A053FEAB5AF94D9E9ABE7
6
2
3F1888C6DCA92A6499C4911FDBA1A67379A1A931
7
3
32EE5C4C3FA15CCADB46ABE529D4BCB6416F53EC
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
+ # Not technically POSIX-compliant due to use of "local", but almost every
3
+ # shell anyone uses today supports it, so its probably fine
2
4
3
5
DIR=$( dirname " $0 " )
4
-
5
- echo " Please verify all commits in the following list are not evil:"
6
- git log " $DIR "
6
+ [ " /${DIR#/ } " != " $DIR " ] && DIR=$( dirname " $( pwd) /$0 " )
7
7
8
8
VERIFIED_ROOT=$( cat " ${DIR} /trusted-git-root" )
9
-
10
- IS_REVSIG_ALLOWED () {
11
- while read LINE; do
12
- [ " $LINE " = " $1 " ] && return 0
13
- done < " ${DIR} /allow-revsig-commits"
14
- return 1
15
- }
9
+ REVSIG_ALLOWED=$( cat " ${DIR} /allow-revsig-commits" )
16
10
17
11
HAVE_FAILED=false
18
12
IS_SIGNED () {
19
13
if [ $1 = $VERIFIED_ROOT ]; then
20
14
return 0;
21
15
fi
22
- if IS_REVSIG_ALLOWED " $1 " ; then
16
+ if [ " ${REVSIG_ALLOWED #* $1 } " != " $REVSIG_ALLOWED " ] ; then
23
17
export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG=1
24
18
else
25
19
export BITCOIN_VERIFY_COMMITS_ALLOW_REVSIG=0
26
20
fi
27
21
if ! git -c " gpg.program=${DIR} /gpg.sh" verify-commit $1 > /dev/null 2>&1 ; then
28
22
return 1;
29
23
fi
30
- local PARENTS=$( git show -s --format=format:%P $1 )
24
+ local PARENTS
25
+ PARENTS=$( git show -s --format=format:%P $1 )
31
26
for PARENT in $PARENTS ; do
32
27
if IS_SIGNED $PARENT > /dev/null; then
33
28
return 0;
You can’t perform that action at this time.
0 commit comments