Skip to content

Commit bb86887

Browse files
committed
verify-commits: Skip checks for commits older than trusted roots
1 parent 5497c14 commit bb86887

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

contrib/verify-commits/verify-commits.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,26 @@ def main():
114114
if current_commit == verified_root:
115115
print('There is a valid path from "{}" to {} where all commits are signed!'.format(initial_commit, verified_root))
116116
sys.exit(0)
117-
if current_commit == verified_sha512_root:
118-
if verify_tree:
117+
else:
118+
# Make sure this commit isn't older than trusted roots
119+
check_root_older_res = subprocess.run([GIT, "merge-base", "--is-ancestor", verified_root, current_commit])
120+
if check_root_older_res.returncode != 0:
121+
print(f"\"{current_commit}\" predates the trusted root, stopping!")
122+
sys.exit(0)
123+
124+
if verify_tree:
125+
if current_commit == verified_sha512_root:
119126
print("All Tree-SHA512s matched up to {}".format(verified_sha512_root), file=sys.stderr)
120-
verify_tree = False
121-
no_sha1 = False
127+
verify_tree = False
128+
no_sha1 = False
129+
else:
130+
# Skip the tree check if we are older than the trusted root
131+
check_root_older_res = subprocess.run([GIT, "merge-base", "--is-ancestor", verified_sha512_root, current_commit])
132+
if check_root_older_res.returncode != 0:
133+
print(f"\"{current_commit}\" predates the trusted SHA512 root, disabling tree verification.")
134+
verify_tree = False
135+
no_sha1 = False
136+
122137

123138
os.environ['BITCOIN_VERIFY_COMMITS_ALLOW_SHA1'] = "0" if no_sha1 else "1"
124139
allow_revsig = current_commit in revsig_allowed

0 commit comments

Comments
 (0)