From 97a6e01d2491e877f8038d91fee89460874931a4 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Tue, 14 Apr 2020 11:32:11 -0700 Subject: [PATCH] MessageReceiver: Drop messages with GroupContextV2 --- protos/SignalService.proto | 7 +++ ts/textsecure.d.ts | 13 +++++ ts/textsecure/MessageReceiver.ts | 8 +++ ts/util/lint/exceptions.json | 90 +------------------------------- ts/util/lint/linter.ts | 2 + 5 files changed, 31 insertions(+), 89 deletions(-) diff --git a/protos/SignalService.proto b/protos/SignalService.proto index ef543d698524..5dfdf15de013 100644 --- a/protos/SignalService.proto +++ b/protos/SignalService.proto @@ -193,6 +193,7 @@ message DataMessage { optional string body = 1; repeated AttachmentPointer attachments = 2; optional GroupContext group = 3; + optional GroupContextV2 groupV2 = 15; optional uint32 flags = 4; optional uint32 expireTimer = 5; optional bytes profileKey = 6; @@ -371,6 +372,12 @@ message GroupContext { optional AttachmentPointer avatar = 5; } +message GroupContextV2 { + optional bytes masterKey = 1; + optional uint32 revision = 2; + optional bytes groupChange = 3; +} + message ContactDetails { message Avatar { optional string contentType = 1; diff --git a/ts/textsecure.d.ts b/ts/textsecure.d.ts index a994698595b4..02536ecc9284 100644 --- a/ts/textsecure.d.ts +++ b/ts/textsecure.d.ts @@ -126,6 +126,7 @@ type ProtobufCollectionType = { DeviceName: typeof DeviceNameClass; Envelope: typeof EnvelopeClass; GroupContext: typeof GroupContextClass; + GroupContextV2: typeof GroupContextV2Class; GroupDetails: typeof GroupDetailsClass; NullMessage: typeof NullMessageClass; ProvisioningUuid: typeof ProvisioningUuidClass; @@ -216,6 +217,7 @@ export declare class DataMessageClass { body?: string | null; attachments?: Array; group?: GroupContextClass | null; + groupV2?: GroupContextV2Class | null; flags?: number; expireTimer?: number; profileKey?: ProtoBinaryType; @@ -355,6 +357,17 @@ export declare class GroupContextClass { avatar?: AttachmentPointerClass | null; } +export declare class GroupContextV2Class { + static decode: ( + data: ArrayBuffer | ByteBufferClass, + encoding?: string + ) => GroupContextV2Class; + + masterKey?: ProtoBinaryType; + revision?: number; + groupChange?: ProtoBinaryType; +} + // Note: we need to use namespaces to express nested classes in Typescript export declare namespace GroupContextClass { class Member { diff --git a/ts/textsecure/MessageReceiver.ts b/ts/textsecure/MessageReceiver.ts index 9cf2a0f190aa..9b10b2ceccee 100644 --- a/ts/textsecure/MessageReceiver.ts +++ b/ts/textsecure/MessageReceiver.ts @@ -1107,6 +1107,14 @@ class MessageReceiverInner extends EventTarget { ); } + if (msg.groupV2) { + window.log.warn( + 'MessageReceiver.handleDataMessage: Dropping GroupsV2 message' + ); + this.removeFromCache(envelope); + return; + } + if ( msg.flags && msg.flags & window.textsecure.protobuf.DataMessage.Flags.END_SESSION diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index b45f7d2c82e2..bf768273d607 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -11561,94 +11561,6 @@ "reasonCategory": "falseMatch", "updated": "2020-04-05T23:45:16.746Z" }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.js", - "line": " const buffer = window.dcodeIO.ByteBuffer.wrap(ciphertext);", - "lineNumber": 665, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.js", - "line": " const buffer = window.dcodeIO.ByteBuffer.wrap(ciphertext);", - "lineNumber": 685, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.js", - "line": "MessageReceiverInner.stringToArrayBuffer = (string) => window.dcodeIO.ByteBuffer.wrap(string, 'binary').toArrayBuffer();", - "lineNumber": 1253, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.js", - "line": "MessageReceiverInner.arrayBufferToString = (arrayBuffer) => window.dcodeIO.ByteBuffer.wrap(arrayBuffer).toString('binary');", - "lineNumber": 1254, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.js", - "line": "MessageReceiverInner.arrayBufferToStringBase64 = (arrayBuffer) => window.dcodeIO.ByteBuffer.wrap(arrayBuffer).toString('base64');", - "lineNumber": 1256, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.ts", - "line": " window.dcodeIO.ByteBuffer.wrap(string, 'binary').toArrayBuffer();", - "lineNumber": 179, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.ts", - "line": " window.dcodeIO.ByteBuffer.wrap(arrayBuffer).toString('binary');", - "lineNumber": 181, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.ts", - "line": " window.dcodeIO.ByteBuffer.wrap(string, 'base64').toArrayBuffer();", - "lineNumber": 183, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.ts", - "line": " window.dcodeIO.ByteBuffer.wrap(arrayBuffer).toString('base64');", - "lineNumber": 185, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.ts", - "line": " const buffer = window.dcodeIO.ByteBuffer.wrap(ciphertext);", - "lineNumber": 987, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, - { - "rule": "jQuery-wrap(", - "path": "ts/textsecure/MessageReceiver.ts", - "line": " const buffer = window.dcodeIO.ByteBuffer.wrap(ciphertext);", - "lineNumber": 1016, - "reasonCategory": "falseMatch", - "updated": "2020-04-05T23:45:16.746Z" - }, { "rule": "jQuery-wrap(", "path": "ts/textsecure/SendMessage.js", @@ -11745,4 +11657,4 @@ "reasonCategory": "falseMatch", "updated": "2020-04-05T23:45:16.746Z" } -] +] \ No newline at end of file diff --git a/ts/util/lint/linter.ts b/ts/util/lint/linter.ts index d4fcb1d07932..dd08841bcfc6 100644 --- a/ts/util/lint/linter.ts +++ b/ts/util/lint/linter.ts @@ -58,6 +58,8 @@ const excludedFiles = [ '^js/background.js', '^ts/Crypto.js', '^ts/Crypto.ts', + '^ts/textsecure/MessageReceiver.js', + '^ts/textsecure/MessageReceiver.ts', // Generated files '^js/components.js',