feature(keyringctl): raise exception on duplicate uid data

This commit is contained in:
Levente Polyak 2021-11-25 23:05:51 +01:00
parent b653edfcdc
commit b32c37bec1
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
2 changed files with 20 additions and 0 deletions

View File

@ -354,6 +354,10 @@ def convert_certificate(
current_packet_fingerprint = None
current_packet_uid = Uid(simplify_ascii(packet_dump_field(packet, "Value")))
if current_packet_uid in uids:
raise Exception(
f"Duplicate User ID {current_packet_uid} used in packet {uids[current_packet_uid]} and {packet}"
)
uids[current_packet_uid] = packet
elif packet.name.endswith("UserAttribute"):
current_packet_mode = "uattr"

View File

@ -423,6 +423,22 @@ def test_convert_signature_packet(
"bar",
does_not_raise(),
),
(
Path("foo.asc"),
[
Path("--PublicKey"),
Path("--Signature"),
Path("--UserID"),
Path("--UserID"),
],
[
"".join(choice("ABCDEF" + digits) for _ in range(40)),
"foo <foo@bar.com>",
"foo <foo@bar.com>",
],
"bar",
raises(Exception),
),
(
Path("foo.asc"),
[