From 534acaa980eca282887c6a0e0d341a09648ed345 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Tue, 12 Nov 2019 17:12:26 -0300 Subject: [PATCH 01/12] Adds Added Photo Via Media Editor --- WordPressShared/Core/Analytics/WPAnalytics.h | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPressShared/Core/Analytics/WPAnalytics.h b/WordPressShared/Core/Analytics/WPAnalytics.h index 7c7bdc1..df5b73a 100644 --- a/WordPressShared/Core/Analytics/WPAnalytics.h +++ b/WordPressShared/Core/Analytics/WPAnalytics.h @@ -77,6 +77,7 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) { WPAnalyticsStatEditorAddedPhotoViaGiphy, WPAnalyticsStatEditorAddedPhotoViaOtherApps, WPAnalyticsStatEditorAddedPhotoViaStockPhotos, + WPAnalyticsStatEditorAddedPhotoViaMediaEditor, WPAnalyticsStatEditorAddedVideoViaOtherApps, WPAnalyticsStatEditorAztecBetaLink, WPAnalyticsStatEditorAztecPromoLink, From e2cb325675a3605bbcf604deec63061d4b5f25b9 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Mon, 2 Dec 2019 12:10:22 +0100 Subject: [PATCH 02/12] Adds Secret wrapper for sensitive information --- WordPressShared.xcodeproj/project.pbxproj | 8 ++++ WordPressShared/Core/Utility/Secret.swift | 49 +++++++++++++++++++++++ WordPressSharedTests/SecretTests.swift | 24 +++++++++++ 3 files changed, 81 insertions(+) create mode 100644 WordPressShared/Core/Utility/Secret.swift create mode 100644 WordPressSharedTests/SecretTests.swift diff --git a/WordPressShared.xcodeproj/project.pbxproj b/WordPressShared.xcodeproj/project.pbxproj index 59e9047..15ddd59 100644 --- a/WordPressShared.xcodeproj/project.pbxproj +++ b/WordPressShared.xcodeproj/project.pbxproj @@ -81,6 +81,8 @@ B5A7881F202B3A92007874FB /* WPTextFieldTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881B202B3A92007874FB /* WPTextFieldTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; B5A78820202B3A92007874FB /* WPTextFieldTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B5A7881C202B3A92007874FB /* WPTextFieldTableViewCell.m */; }; B5A78821202B3A92007874FB /* WPTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B5A7881D202B3A92007874FB /* WPTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; + E157E126239527700051AE41 /* Secret.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E125239527700051AE41 /* Secret.swift */; }; + E157E128239527AD0051AE41 /* SecretTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E157E127239527AD0051AE41 /* SecretTests.swift */; }; E18EABEA1F0E2C6800BFCB0B /* TestAnalyticsTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */; }; E18EABEB1F0E2C6800BFCB0B /* WPAnalyticsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */; }; E1A444281F063CAB00F6AA8A /* WPAnalytics.h in Headers */ = {isa = PBXBuildFile; fileRef = E1A444261F063CAB00F6AA8A /* WPAnalytics.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -191,6 +193,8 @@ B5A78823202B3B3C007874FB /* WordPressUIKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = WordPressUIKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; BAD47F9FCABF8C12D6352A20 /* Pods-WordPressSharedTests.release-internal.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.release-internal.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.release-internal.xcconfig"; sourceTree = ""; }; D62D565031D4683172615BAC /* Pods-WordPressSharedTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressSharedTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressSharedTests/Pods-WordPressSharedTests.release.xcconfig"; sourceTree = ""; }; + E157E125239527700051AE41 /* Secret.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secret.swift; sourceTree = ""; }; + E157E127239527AD0051AE41 /* SecretTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretTests.swift; sourceTree = ""; }; E18EABE71F0E2C6800BFCB0B /* TestAnalyticsTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestAnalyticsTracker.h; sourceTree = ""; }; E18EABE81F0E2C6800BFCB0B /* TestAnalyticsTracker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestAnalyticsTracker.m; sourceTree = ""; }; E18EABE91F0E2C6800BFCB0B /* WPAnalyticsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WPAnalyticsTests.m; sourceTree = ""; }; @@ -299,6 +303,7 @@ 7430C9D01F19302D0051B8E6 /* PhotonImageURLHelper.h */, 7430C9D11F19302D0051B8E6 /* PhotonImageURLHelper.m */, 7430C9DA1F1933F40051B8E6 /* RichContentFormatter.swift */, + E157E125239527700051AE41 /* Secret.swift */, 7414BD541F13CBE0005759F8 /* String+Helpers.swift */, F19847DB226F92420004A8BC /* String+URLValidation.swift */, 7414BD5F1F13D084005759F8 /* UIDevice+Helpers.h */, @@ -347,6 +352,7 @@ 93A73ABE1EE9DDB000C0F2F9 /* WPMapFilterReduceTest.m */, 8270708F1ECA4E1C00155CBF /* WordPressSharedTests-Bridging-Header.h */, F19847DD226F92EA0004A8BC /* StringURLValidationTests.swift */, + E157E127239527AD0051AE41 /* SecretTests.swift */, ); name = Tests; sourceTree = ""; @@ -653,6 +659,7 @@ buildActionMask = 2147483647; files = ( E1A444291F063CAB00F6AA8A /* WPAnalytics.m in Sources */, + E157E126239527700051AE41 /* Secret.swift in Sources */, 827070101ECA43AA00155CBF /* WPImageSource.m in Sources */, 93C674F51EE83D4B00BFAF05 /* Languages.swift in Sources */, B5A787E6202B2BD3007874FB /* WPDeviceIdentification.m in Sources */, @@ -704,6 +711,7 @@ B5393FDD206D6169007BF9D4 /* EmailTypoCheckerTests.swift in Sources */, F1134A292270C19200B8F75F /* DebouncerTests.swift in Sources */, 7430C9D51F1930460051B8E6 /* PhotonImageURLHelperTest.m in Sources */, + E157E128239527AD0051AE41 /* SecretTests.swift in Sources */, 740B23CF1F17F28E00067A2A /* DisplayableImageHelperTest.m in Sources */, E18EABEB1F0E2C6800BFCB0B /* WPAnalyticsTests.m in Sources */, 7430C9DD1F1934190051B8E6 /* RichContentFormatterTests.swift in Sources */, diff --git a/WordPressShared/Core/Utility/Secret.swift b/WordPressShared/Core/Utility/Secret.swift new file mode 100644 index 0000000..87f83b0 --- /dev/null +++ b/WordPressShared/Core/Utility/Secret.swift @@ -0,0 +1,49 @@ +import Foundation + +/// Wraps a value that contains sensitive information to prevent accidental logging +/// +/// Usage example +/// +/// ``` +/// let password = Secret("my secret password") +/// print(password) // Prints "--redacted" +/// print(password.secretValue) // Prints "my secret password" +/// ``` +/// +public struct Secret { + public let secretValue: T + + public init(_ secretValue: T) { + self.secretValue = secretValue + } +} + +extension Secret: RawRepresentable { + public typealias RawValue = T + + public init?(rawValue: Self.RawValue) { + self.init(rawValue) + } + + public var rawValue: T { + return secretValue + } +} + +extension Secret: CustomStringConvertible, CustomDebugStringConvertible, CustomReflectable { + private static var redacted: String { + return "--redacted--" + } + + public var description: String { + return Secret.redacted + } + + public var debugDescription: String { + return Secret.redacted + } + + public var customMirror: Mirror { + return Mirror(reflecting: Secret.redacted) + } +} diff --git a/WordPressSharedTests/SecretTests.swift b/WordPressSharedTests/SecretTests.swift new file mode 100644 index 0000000..65749fc --- /dev/null +++ b/WordPressSharedTests/SecretTests.swift @@ -0,0 +1,24 @@ +import WordPressShared +import XCTest + +class SecretTests: XCTestCase { + func testSecretDescription() { + let secret = Secret("my secret") + XCTAssertEqual("--redacted--", secret.description, "Description should be redacted") + } + + func testSecretDebugDescription() { + let secret = Secret("my secret") + XCTAssertEqual("--redacted--", secret.debugDescription, "Debug description should be redacted") + } + + func testSecretMirror() { + let secret = Secret("my secret") + XCTAssertEqual("--redacted--", String(reflecting: secret), "Mirror should be redacted") + } + + func testSecretUnwrapsValue() { + let secret = Secret("my secret") + XCTAssertEqual("my secret", secret.secretValue, "secretValue should not be redacted") + } +} From 4281d9f4e38dfcd2a966a59d761fe1d2f372b008 Mon Sep 17 00:00:00 2001 From: Jorge Bernal Date: Mon, 2 Dec 2019 12:12:00 +0100 Subject: [PATCH 03/12] Fix documentation --- WordPressShared/Core/Utility/Secret.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared/Core/Utility/Secret.swift b/WordPressShared/Core/Utility/Secret.swift index 87f83b0..66b5a8f 100644 --- a/WordPressShared/Core/Utility/Secret.swift +++ b/WordPressShared/Core/Utility/Secret.swift @@ -6,7 +6,7 @@ import Foundation /// /// ``` /// let password = Secret("my secret password") -/// print(password) // Prints "--redacted" +/// print(password) // Prints "--redacted--" /// print(password.secretValue) // Prints "my secret password" /// ``` /// From 4055396c0fa987b7eaa3bd9b7d9dc635392ae97d Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 2 Dec 2019 10:47:20 -0300 Subject: [PATCH 04/12] Bump version --- WordPressShared.podspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index d07d471..1c15d99 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.8.9-beta.1" + s.version = "1.8.10-beta-1" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC @@ -27,4 +27,3 @@ Pod::Spec.new do |s| s.dependency 'CocoaLumberjack', '~> 3.4' s.dependency 'FormatterKit/TimeIntervalFormatter', '1.8.2' end - From f6da65c3890fa3af94869e3c2bf02645ad3e8ce7 Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Mon, 2 Dec 2019 16:21:50 -0300 Subject: [PATCH 05/12] Add events for media editor showing and being used --- WordPressShared/Core/Analytics/WPAnalytics.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPressShared/Core/Analytics/WPAnalytics.h b/WordPressShared/Core/Analytics/WPAnalytics.h index df5b73a..c2d39fd 100644 --- a/WordPressShared/Core/Analytics/WPAnalytics.h +++ b/WordPressShared/Core/Analytics/WPAnalytics.h @@ -199,6 +199,8 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) { WPAnalyticsStatLoginSocialErrorUnknownUser, WPAnalyticsStatLogout, WPAnalyticsStatLowMemoryWarning, + WPAnalyticsStatMediaEditorShown, + WPAnalyticsStatMediaEditorUsed, WPAnalyticsStatMediaLibraryDeletedItems, WPAnalyticsStatMediaLibraryEditedItemMetadata, WPAnalyticsStatMediaLibraryPreviewedItem, From 1d570c901a380f407ed2b3cdb3070e0fe674d15a Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Wed, 4 Dec 2019 09:50:35 -0300 Subject: [PATCH 06/12] Update Xcode and simulator for Circle CI --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 295f74b..b6db9a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,21 +9,21 @@ workflows: jobs: - ios/test: name: Test - xcode-version: "10.2.0" + xcode-version: "11.2.1" workspace: WordPressShared.xcworkspace scheme: WordPressShared - device: iPhone XS - ios-version: "12.2" + device: iPhone 11 + ios-version: "13.2.2" bundle-install: true pod-install: true - ios/validate-podspec: name: Validate Podspec - xcode-version: "10.2.0" + xcode-version: "11.2.1" podspec-path: WordPressShared.podspec bundle-install: true - ios/publish-podspec: name: Publish to Trunk - xcode-version: "10.2.0" + xcode-version: "11.2.1" podspec-path: WordPressShared.podspec bundle-install: true post-to-slack: true From 29324c9e27b97222ef202a5bc3348099ab4b1344 Mon Sep 17 00:00:00 2001 From: Shiki Date: Thu, 28 Nov 2019 11:43:23 -0700 Subject: [PATCH 07/12] Analytics: Add .debugDeletedOrphanedEntities --- WordPressShared/Core/Analytics/WPAnalytics.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/WordPressShared/Core/Analytics/WPAnalytics.h b/WordPressShared/Core/Analytics/WPAnalytics.h index c2d39fd..2b5f40f 100644 --- a/WordPressShared/Core/Analytics/WPAnalytics.h +++ b/WordPressShared/Core/Analytics/WPAnalytics.h @@ -562,7 +562,18 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) { WPAnalyticsStatTwoFactorSentSMS, WPAnalyticsStatShareExtensionError, WPAnalyticsStatSearchAdsAttribution, - WPAnalyticsStatMaxValue + WPAnalyticsStatMaxValue, + /// Logged when there are orphaned entities (e.g. has NULL blog values). + /// + /// These are invalid rows in the database and will cause a crash in Core Data during saving. + /// + /// Event Properties: + /// + /// - entityName: String. The Core Data entity name. + /// - deletedCount: Int. The number of deleted entities. + /// + /// This event is not logged when there are no entities to delete. + WPAnalyticsStatDebugDeletedOrphanedEntities }; extern NSString *const WPAnalyticsStatEditorPublishedPostPropertyCategory; From ee842d8158365c0914cd6b0e23da25eff970072d Mon Sep 17 00:00:00 2001 From: Shiki Date: Thu, 28 Nov 2019 12:04:32 -0700 Subject: [PATCH 08/12] Fix .debugDeletedOrphanedEntities doc --- WordPressShared/Core/Analytics/WPAnalytics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPressShared/Core/Analytics/WPAnalytics.h b/WordPressShared/Core/Analytics/WPAnalytics.h index 2b5f40f..7ddc338 100644 --- a/WordPressShared/Core/Analytics/WPAnalytics.h +++ b/WordPressShared/Core/Analytics/WPAnalytics.h @@ -569,8 +569,8 @@ typedef NS_ENUM(NSUInteger, WPAnalyticsStat) { /// /// Event Properties: /// - /// - entityName: String. The Core Data entity name. - /// - deletedCount: Int. The number of deleted entities. + /// - entity_name: String. The Core Data entity name. + /// - deleted_count: Int. The number of deleted entities. /// /// This event is not logged when there are no entities to delete. WPAnalyticsStatDebugDeletedOrphanedEntities From de8f02aeccb9009fa038ac5387b69d0bfeee9ad3 Mon Sep 17 00:00:00 2001 From: Jeremy Massel Date: Wed, 11 Dec 2019 14:09:03 -0700 Subject: [PATCH 09/12] Fix memory layout issues with DDLogLevel --- WordPressShared/Core/Logging/WPSharedLogging.h | 6 ++++-- WordPressShared/Core/Logging/WPSharedLogging.m | 4 ++-- WordPressShared/Private/WPSharedLoggingPrivate.h | 2 +- WordPressShared/Private/WPSharedLoggingPrivate.m | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/WordPressShared/Core/Logging/WPSharedLogging.h b/WordPressShared/Core/Logging/WPSharedLogging.h index 05e286c..25ab154 100644 --- a/WordPressShared/Core/Logging/WPSharedLogging.h +++ b/WordPressShared/Core/Logging/WPSharedLogging.h @@ -1,2 +1,4 @@ -int WPSharedGetLoggingLevel(void); -void WPSharedSetLoggingLevel(int level); +@import CocoaLumberjack; + +DDLogLevel WPSharedGetLoggingLevel(void); +void WPSharedSetLoggingLevel(DDLogLevel level); diff --git a/WordPressShared/Core/Logging/WPSharedLogging.m b/WordPressShared/Core/Logging/WPSharedLogging.m index 8a9f516..01ca37b 100644 --- a/WordPressShared/Core/Logging/WPSharedLogging.m +++ b/WordPressShared/Core/Logging/WPSharedLogging.m @@ -1,10 +1,10 @@ #import "WPSharedLogging.h" #import "WPSharedLoggingPrivate.h" -int WPSharedGetLoggingLevel() { +DDLogLevel WPSharedGetLoggingLevel() { return ddLogLevel; } -void WPSharedSetLoggingLevel(int level) { +void WPSharedSetLoggingLevel(DDLogLevel level) { ddLogLevel = level; } diff --git a/WordPressShared/Private/WPSharedLoggingPrivate.h b/WordPressShared/Private/WPSharedLoggingPrivate.h index 4f02d57..65c4b33 100644 --- a/WordPressShared/Private/WPSharedLoggingPrivate.h +++ b/WordPressShared/Private/WPSharedLoggingPrivate.h @@ -1,2 +1,2 @@ @import CocoaLumberjack; -extern int ddLogLevel; \ No newline at end of file +extern DDLogLevel ddLogLevel; diff --git a/WordPressShared/Private/WPSharedLoggingPrivate.m b/WordPressShared/Private/WPSharedLoggingPrivate.m index 676e54f..516af98 100644 --- a/WordPressShared/Private/WPSharedLoggingPrivate.m +++ b/WordPressShared/Private/WPSharedLoggingPrivate.m @@ -1,2 +1,2 @@ #import "WPSharedLoggingPrivate.h" -int ddLogLevel = DDLogLevelWarning; +DDLogLevel ddLogLevel = DDLogLevelWarning; From 462e092ef9739a75fced48582f3138c81cf9a850 Mon Sep 17 00:00:00 2001 From: Jeremy Massel Date: Wed, 11 Dec 2019 14:50:25 -0700 Subject: [PATCH 10/12] Tag 1.8.10-beta-2 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index 1c15d99..df77271 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.8.10-beta-1" + s.version = "1.8.10-beta-2" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From 81624fffa292cb6d1aeeea048b8b225ec40c392a Mon Sep 17 00:00:00 2001 From: Leandro Alonso Date: Thu, 12 Dec 2019 09:33:54 -0300 Subject: [PATCH 11/12] Update podspec --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index df77271..fb753ea 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.8.10-beta-2" + s.version = "1.8.10-beta-3" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC From bbf4c2aa494b1653e2051b5b75d7c8bf5d719b0d Mon Sep 17 00:00:00 2001 From: Pinar Olguc Date: Mon, 16 Dec 2019 14:56:04 +0300 Subject: [PATCH 12/12] Release/1.8.9 --- WordPressShared.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressShared.podspec b/WordPressShared.podspec index fb753ea..dc1e2f4 100644 --- a/WordPressShared.podspec +++ b/WordPressShared.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "WordPressShared" - s.version = "1.8.10-beta-3" + s.version = "1.8.10" s.summary = "Shared components used in building the WordPress iOS apps and other library components." s.description = <<-DESC