Validate remote wipe confirm messages

This commit is contained in:
ameba23
2022-02-22 08:49:10 +01:00
parent 189dd6f7e5
commit 99ffbfd5ae
2 changed files with 16 additions and 4 deletions

View File

@@ -197,10 +197,10 @@ public class RemoteWipeManagerImpl extends ConversationClientImpl
// Send a CONFIRM message to each wiper
sendConfirmMessages(txn);
if (observer != null) {
observer.onPanic();
}
txn.attach(new RemoteWipeActivatedEvent());
// if (observer != null) {
// observer.onPanic();
// }
// txn.attach(new RemoteWipeActivatedEvent());
// we could here clear the metadata to allow us to send
// the wipe messages several times when testing
@@ -233,6 +233,7 @@ public class RemoteWipeManagerImpl extends ConversationClientImpl
clientHelper
.mergeGroupMetadata(txn, localGroup.getId(), localRecord);
} else if (type == CONFIRM) {
LOG.info("*** Got confirm msg");
messageTracker.trackIncomingMessage(txn, m);
ContactId contactId = getContactId(txn, m.getGroupId());

View File

@@ -17,6 +17,7 @@ import javax.annotation.concurrent.Immutable;
import javax.inject.Inject;
import static org.briarproject.bramble.util.ValidationUtils.checkSize;
import static org.briarproject.briar.api.remotewipe.MessageType.CONFIRM;
import static org.briarproject.briar.api.remotewipe.MessageType.REVOKE;
import static org.briarproject.briar.api.remotewipe.MessageType.SETUP;
import static org.briarproject.briar.api.remotewipe.MessageType.WIPE;
@@ -42,6 +43,7 @@ class RemoteWipeValidator extends BdfMessageValidator {
if (type == SETUP) return validateSetupMessage(body);
else if (type == WIPE) return validateWipeMessage(body);
else if (type == REVOKE) return validateRevokeMessage(body);
else if (type == CONFIRM) return validateConfirmMessage(body);
else throw new AssertionError();
}
@@ -71,4 +73,13 @@ class RemoteWipeValidator extends BdfMessageValidator {
new BdfEntry(MSG_KEY_LOCAL, false));
return new BdfMessageContext(meta);
}
private BdfMessageContext validateConfirmMessage(BdfList body)
throws FormatException {
checkSize(body, 1);
BdfDictionary meta = BdfDictionary.of(
new BdfEntry(MSG_KEY_MESSAGE_TYPE, CONFIRM.getValue()),
new BdfEntry(MSG_KEY_LOCAL, false));
return new BdfMessageContext(meta);
}
}