[SSK] Better logging for envelopes

Leave last 3 digits of recipientId when scrubbing logs.

This is in line with other Signal clients, and makes it possible to
trace interactions.

// FREEBIE
This commit is contained in:
Michael Kirk 2017-03-23 15:24:19 -04:00
parent fe18cb9a39
commit 6466e9f41f
3 changed files with 11 additions and 11 deletions

View File

@ -133,7 +133,7 @@ CHECKOUT OPTIONS:
:commit: 23a5d1b67afc4dd028198202e25fd2e06ce396d7
:git: https://github.com/WhisperSystems/SignalProtocolKit.git
SignalServiceKit:
:commit: 1fd7627daf713521e5ea8f20e266873d41e8c488
:commit: 63cc0328b5523b53216285e0c754d0500b3ec344
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket:
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf

View File

@ -1,5 +1,6 @@
// Created by Michael Kirk on 9/27/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSScrubbingLogFormatter.h"
@ -17,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *filteredString = [phoneRegex stringByReplacingMatchesInString:string
options:0
range:NSMakeRange(0, [string length])
withTemplate:@"[ REDACTED_PHONE_NUMBER ]"];
withTemplate:@"[ REDACTED_PHONE_NUMBER:xxx$1 ]"];
return filteredString;
}

View File

@ -1,5 +1,6 @@
// Created by Michael Kirk on 9/27/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSScrubbingLogFormatter.h"
#import <XCTest/XCTest.h>
@ -36,11 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
for (NSString *phoneString in phoneStrings) {
OWSScrubbingLogFormatter *formatter = [OWSScrubbingLogFormatter new];
NSString *actual = [formatter
formatLogMessage:[self
messageWithString:[NSString stringWithFormat:@"My phone number is %@", phoneString]]];
NSRange redactedRange = [actual rangeOfString:@"My phone number is [ REDACTED_PHONE_NUMBER ]"];
NSString *messageText = [NSString stringWithFormat:@"My phone number is %@", phoneString];
NSString *actual = [formatter formatLogMessage:[self messageWithString:messageText]];
NSRange redactedRange = [actual rangeOfString:@"My phone number is [ REDACTED_PHONE_NUMBER:xxx234 ]"];
XCTAssertNotEqual(NSNotFound, redactedRange.location, "Failed to redact phone string: %@", phoneString);
NSRange phoneNumberRange = [actual rangeOfString:phoneString];