From cac04146deee5fa8087d8023fcd1b0e2029591e7 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Tue, 6 Jun 2023 14:27:41 -0400 Subject: [PATCH] Identify specific cases with invalid identity keys --- .../textsecuregcm/storage/Accounts.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java index 8ccec6881..98ed87473 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/storage/Accounts.java @@ -80,7 +80,8 @@ public class Accounts extends AbstractDynamoDbStore { private static final Timer GET_ALL_FROM_OFFSET_TIMER = Metrics.timer(name(Accounts.class, "getAllFromOffset")); private static final Timer DELETE_TIMER = Metrics.timer(name(Accounts.class, "delete")); - private static final Counter INVALID_IDENTITY_KEY_COUNTER = Metrics.counter(name(Accounts.class, "invalidIdentityKey")); + private static final Counter INVALID_ACI_IDENTITY_KEY_COUNTER = Metrics.counter(name(Accounts.class, "invalidIdentityKey"), "type", "aci"); + private static final Counter INVALID_PNI_IDENTITY_KEY_COUNTER = Metrics.counter(name(Accounts.class, "invalidIdentityKey"), "type", "pni"); private static final String CONDITIONAL_CHECK_FAILED = "ConditionalCheckFailed"; @@ -918,7 +919,17 @@ static Account fromItem(final Map item) { try { new IdentityKey(account.getIdentityKey()); } catch (final InvalidKeyException e) { - INVALID_IDENTITY_KEY_COUNTER.increment(); + log.debug("Account {} has an invalid ACI identity key", account.getUuid()); + INVALID_ACI_IDENTITY_KEY_COUNTER.increment(); + } + } + + if (account.getPhoneNumberIdentityKey() != null && account.getPhoneNumberIdentityKey().length > 0) { + try { + new IdentityKey(account.getPhoneNumberIdentityKey()); + } catch (final InvalidKeyException e) { + log.debug("Account {} has an invalid PNI identity key", account.getUuid()); + INVALID_PNI_IDENTITY_KEY_COUNTER.increment(); } }