MCPcopy Create free account
hub / github.com/apache/solr / configure_pgp

Function configure_pgp

dev-tools/scripts/releaseWizard.py:1193–1301  ·  view source on GitHub ↗
(gpg_todo)

Source from the content-addressed store, hash-verified

1191
1192
1193def configure_pgp(gpg_todo):
1194 print("Based on your Apache ID we'll lookup your key online\n"
1195 "and through this complete the 'gpg' prerequisite task.\n")
1196 gpg_state = gpg_todo.get_state()
1197 id = str(input("Please enter your Apache id: (ENTER=skip) "))
1198 if id.strip() == '':
1199 return False
1200
1201 committer_pgp = CommitterPgp(id.strip())
1202 gpg_id = committer_pgp.get_short_fingerprint()
1203 gpg_fingerprint = committer_pgp.get_fingerprint()
1204 if gpg_id is not None:
1205 print("Found gpg key id %s on file at Apache" % gpg_id)
1206 else:
1207 print(textwrap.dedent("""\
1208 Could not find your GPG key from Apache servers.
1209 Please make sure you have registered your key ID in
1210 id.apache.org, see links for more info."""))
1211 gpg_fingerprint = str(input("Enter your key fingerprint manually, all 40 characters (ENTER=skip): "))
1212 if gpg_fingerprint.strip() == '':
1213 return False
1214 elif len(gpg_fingerprint) != 40:
1215 print("gpg fingerprint must be 40 characters long, do not just input the last 8")
1216 gpg_fingerprint = gpg_fingerprint.upper()
1217 gpg_id = gpg_fingerprint[-8:]
1218 try:
1219 res = run("gpg --list-secret-keys %s" % gpg_fingerprint)
1220 print("Found key %s on your private gpg keychain" % gpg_id)
1221 # Check rsa and key length >= 4096
1222 match = re.search(r'^sec#? +((rsa|dsa)(\d{4})) ', res)
1223 type = "(unknown)"
1224 length = -1
1225 if match:
1226 type = match.group(2)
1227 length = int(match.group(3))
1228 else:
1229 match = re.search(r'^sec#? +((\d{4})([DR])/.*?) ', res)
1230 if match:
1231 type = 'rsa' if match.group(3) == 'R' else 'dsa'
1232 length = int(match.group(2))
1233 else:
1234 print("Could not determine type and key size for your key")
1235 print("%s" % res)
1236 if not ask_yes_no("Is your key of type RSA and size >= 2048 (ideally 4096)? "):
1237 print("Sorry, please generate a new key, add to KEYS and register with id.apache.org")
1238 return False
1239 if not type == 'rsa':
1240 print("We strongly recommend RSA type key, your is '%s'. Consider generating a new key." % type.upper())
1241 if length < 2048:
1242 print("Your key has key length of %s. Cannot use < 2048, please generate a new key before doing the release" % length)
1243 return False
1244 if length < 4096:
1245 print("Your key length is < 4096, Please generate a stronger key.")
1246 print("Alternatively, follow instructions in https://infra.apache.org/release-signing.html#note")
1247 if not ask_yes_no("Have you configured your gpg to avoid SHA-1?"):
1248 print("Please either generate a strong key or reconfigure your client")
1249 return False
1250 print("Validated that your key is of type RSA and has a length >= 2048 (%s)" % length)

Callers

nothing calls this directly

Calls 11

get_short_fingerprintMethod · 0.95
get_fingerprintMethod · 0.95
CommitterPgpClass · 0.90
runFunction · 0.90
ask_yes_noFunction · 0.85
download_keysFunction · 0.85
file_to_stringFunction · 0.85
get_stateMethod · 0.80
stripMethod · 0.80
searchMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…