0
0
mirror of https://github.com/signalapp/Signal-Server.git synced 2024-09-20 20:03:07 +02:00

Count instances where an account's identity key could not be interpreted as an IdentityKey

This commit is contained in:
Jon Chambers 2023-06-06 09:44:14 -04:00 committed by Jon Chambers
parent 9c93d379a8
commit 8579babde6

View File

@ -10,6 +10,7 @@ import static java.util.Objects.requireNonNull;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Timer;
import java.io.IOException;
@ -30,6 +31,8 @@ import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import org.signal.libsignal.protocol.IdentityKey;
import org.signal.libsignal.protocol.InvalidKeyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.whispersystems.textsecuregcm.util.AttributeValues;
@ -77,6 +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 String CONDITIONAL_CHECK_FAILED = "ConditionalCheckFailed";
private static final String TRANSACTION_CONFLICT = "TransactionConflict";
@ -909,6 +914,14 @@ public class Accounts extends AbstractDynamoDbStore {
.map(AttributeValue::bool)
.orElse(false));
if (account.getIdentityKey() != null && account.getIdentityKey().length > 0) {
try {
new IdentityKey(account.getIdentityKey());
} catch (final InvalidKeyException e) {
INVALID_IDENTITY_KEY_COUNTER.increment();
}
}
return account;
} catch (final IOException e) {