From 934acfa50a5c7884a38e85c0092f3728699e61de Mon Sep 17 00:00:00 2001 From: kholood Date: Thu, 14 Nov 2024 16:45:20 +0200 Subject: [PATCH 1/5] feat(ios): enabling auto masking --- example/ios/InstabugTests/InstabugApiTests.m | 8 ++++++++ example/ios/Podfile | 1 + example/ios/Podfile.lock | 14 ++++++++------ ios/Classes/Modules/InstabugApi.m | 4 ++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/example/ios/InstabugTests/InstabugApiTests.m b/example/ios/InstabugTests/InstabugApiTests.m index 6c9544d71..211288266 100644 --- a/example/ios/InstabugTests/InstabugApiTests.m +++ b/example/ios/InstabugTests/InstabugApiTests.m @@ -451,6 +451,14 @@ - (void)testWillRedirectToAppStore { OCMVerify([self.mInstabug willRedirectToAppStore]); } +- (void)testSetAutoMaskingEnabled { + NSNumber *isEnabled = @1; + FlutterError *error; + [self.api setAutoMaskingEnabledIsEnabled:isEnabled error:&error]; + + OCMVerify([self.mNetworkLogger setAutoMaskingEnabled:YES]); +} + - (void)testNetworkLogWithW3Caught { NSString *url = @"https://example.com"; NSString *requestBody = @"hi"; diff --git a/example/ios/Podfile b/example/ios/Podfile index cdffbc5db..625c6c571 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -27,6 +27,7 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe flutter_ios_podfile_setup target 'Runner' do + pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec' use_frameworks! use_modular_headers! diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index f6cd7d9de..bcb533d72 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,33 +1,35 @@ PODS: - Flutter (1.0.0) - Instabug (14.0.0) - - instabug_flutter (13.4.0): + - instabug_flutter (14.0.0): - Flutter - Instabug (= 14.0.0) - OCMock (3.6) DEPENDENCIES: - Flutter (from `Flutter`) + - Instabug (from `https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec`) - instabug_flutter (from `.symlinks/plugins/instabug_flutter/ios`) - OCMock (= 3.6) SPEC REPOS: trunk: - - Instabug - OCMock EXTERNAL SOURCES: Flutter: :path: Flutter + Instabug: + :podspec: https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec instabug_flutter: :path: ".symlinks/plugins/instabug_flutter/ios" SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - Instabug: a0beffc01658773e2fac549845782f8937707dc4 - instabug_flutter: 71ec9d13d57a4958cabab59fe06792cade3bf754 + Instabug: 3fa42ac8b4350cb632df724b14a86ebdb875aad9 + instabug_flutter: ff8ab5ff34a476b1d2d887478ec190cda962b973 OCMock: 5ea90566be239f179ba766fd9fbae5885040b992 -PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84 +PODFILE CHECKSUM: e7d6c199070a4a2b3664012221f598abd9a35e69 -COCOAPODS: 1.16.2 +COCOAPODS: 1.15.2 diff --git a/ios/Classes/Modules/InstabugApi.m b/ios/Classes/Modules/InstabugApi.m index 8cdd336d1..f3f9bfe0a 100644 --- a/ios/Classes/Modules/InstabugApi.m +++ b/ios/Classes/Modules/InstabugApi.m @@ -341,6 +341,10 @@ - (void)willRedirectToStoreWithError:(FlutterError * _Nullable __autoreleasing * [Instabug willRedirectToAppStore]; } +- (void)setAutoMaskingEnabledIsEnabled:(NSNumber *)isEnabled error:(FlutterError *_Nullable *_Nonnull)error { + IBGNetworkLogger.autoMaskingEnabled = [isEnabled boolValue]; +} + - (void)addFeatureFlagsFeatureFlagsMap:(nonnull NSDictionary *)featureFlagsMap error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error { NSMutableArray *featureFlags = [NSMutableArray array]; for(id key in featureFlagsMap){ From 6ccb2419675f025d590b6388d2331ed26f390afe Mon Sep 17 00:00:00 2001 From: kholood Date: Thu, 14 Nov 2024 16:46:33 +0200 Subject: [PATCH 2/5] feat(android): enabling auto masking --- android/build.gradle | 6 +++--- .../com/instabug/flutter/modules/InstabugApi.java | 12 ++++++++++++ .../java/com/instabug/flutter/InstabugApiTest.java | 13 +++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index ebaccfa51..7a5f5bffa 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -44,11 +44,11 @@ android { } dependencies { - api 'com.instabug.library:instabug:14.0.0' + api 'com.instabug.library:instabug:14.0.0.6407912-SNAPSHOT' testImplementation 'junit:junit:4.13.2' - testImplementation "org.mockito:mockito-inline:3.12.1" + testImplementation "org.mockito:mockito-inline:5.0.0" testImplementation "io.mockk:mockk:1.13.13" - + testImplementation 'org.robolectric:robolectric:4.12.2' } // add upload_symbols task diff --git a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java index 7a8549718..cdfec9d0c 100644 --- a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java @@ -492,4 +492,16 @@ public Map isW3CFeatureFlagsEnabled() { public void willRedirectToStore() { Instabug.willRedirectToStore(); } + + @Override + public void setAutoMaskingEnabled(@NonNull Boolean isEnabled) { + try { + if (isEnabled) + Instabug.setNetworkAutoMaskingState(Feature.State.ENABLED); + else + Instabug.setNetworkAutoMaskingState(Feature.State.DISABLED); + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java index 3d0b15ed4..cec1432c9 100644 --- a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java +++ b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java @@ -622,7 +622,20 @@ public void testWillRedirectToStore() { api.willRedirectToStore(); mInstabug.verify(Instabug::willRedirectToStore); } + @Test + public void testSetAutoMaskingEnabledGivenFalse() { + boolean isEnabled = false; + api.setAutoMaskingEnabled(isEnabled); + mInstabug.verify(() -> Instabug.setNetworkAutoMaskingState(Feature.State.DISABLED)); + } + @Test + public void testSetAutoMaskingEnabledGivenTrue() { + boolean isEnabled = true; + + api.setAutoMaskingEnabled(isEnabled); + mInstabug.verify(() -> Instabug.setNetworkAutoMaskingState(Feature.State.ENABLED)); + } @Test public void isW3CFeatureFlagsEnabled() { From 54c1d61fee5305e08cacd5ba993b169b236f9dd9 Mon Sep 17 00:00:00 2001 From: kholood Date: Thu, 14 Nov 2024 16:49:19 +0200 Subject: [PATCH 3/5] feat: enabling auto masking --- lib/src/modules/network_logger.dart | 6 ++++++ pigeons/instabug.api.dart | 2 ++ test/network_logger_test.dart | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/lib/src/modules/network_logger.dart b/lib/src/modules/network_logger.dart index 14e524f87..bffad7c77 100644 --- a/lib/src/modules/network_logger.dart +++ b/lib/src/modules/network_logger.dart @@ -126,4 +126,10 @@ class NetworkLogger { } return null; } + + /// Enables or disables network logs sensitive information auto masking. + /// [boolean] isEnabled + static Future setAutoMaskingEnabled(bool isEnabled) async { + return _host.setAutoMaskingEnabled(isEnabled); + } } diff --git a/pigeons/instabug.api.dart b/pigeons/instabug.api.dart index c0187acb9..f885ad5a1 100644 --- a/pigeons/instabug.api.dart +++ b/pigeons/instabug.api.dart @@ -74,4 +74,6 @@ abstract class InstabugHostApi { Map isW3CFeatureFlagsEnabled(); void willRedirectToStore(); + + void setAutoMaskingEnabled(bool isEnabled); } diff --git a/test/network_logger_test.dart b/test/network_logger_test.dart index 77f5de51d..511531f63 100644 --- a/test/network_logger_test.dart +++ b/test/network_logger_test.dart @@ -229,4 +229,14 @@ void main() { await logger.networkLog(networkData); expect(networkData.requestHeaders['traceparent'], 'test'); }); + + test('[setAutoMaskingEnabled] should call host method', () async { + const enabled = true; + + await NetworkLogger.setAutoMaskingEnabled(enabled); + + verify( + mInstabugHost.setAutoMaskingEnabled(enabled), + ).called(1); + }); } From 588567d57991e3b40e7e02eecb0b32b44bec6723 Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Sun, 1 Dec 2024 13:57:10 +0200 Subject: [PATCH 4/5] chore: add changeLog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 119f6e213..d30e3645a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...dev) + +### Added + +- Add support enable/disable the automatic masking of sensitive information in network logs. ([#534](https://github.com/Instabug/Instabug-Flutter/pull/534)). + ## [14.0.0](https://github.com/Instabug/Instabug-Flutter/compare/v13.4.0...v14.0.0) (November 11, 2024) ### Added From 5dde1a5192765f873112cb6d49338fa21662c86a Mon Sep 17 00:00:00 2001 From: Ahmed alaa Date: Sun, 22 Dec 2024 12:58:02 +0200 Subject: [PATCH 5/5] chore: update ios snapshot --- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/example/ios/Podfile b/example/ios/Podfile index 625c6c571..aa77f7b43 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -27,7 +27,7 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe flutter_ios_podfile_setup target 'Runner' do - pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec' + pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-MOB-16539-NetworkConfigHandler/14.0.0/Instabug.podspec' use_frameworks! use_modular_headers! diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index bcb533d72..f63453502 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -8,7 +8,7 @@ PODS: DEPENDENCIES: - Flutter (from `Flutter`) - - Instabug (from `https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec`) + - Instabug (from `https://ios-releases.instabug.com/custom/feature-MOB-16539-NetworkConfigHandler/14.0.0/Instabug.podspec`) - instabug_flutter (from `.symlinks/plugins/instabug_flutter/ios`) - OCMock (= 3.6) @@ -20,16 +20,16 @@ EXTERNAL SOURCES: Flutter: :path: Flutter Instabug: - :podspec: https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec + :podspec: https://ios-releases.instabug.com/custom/feature-MOB-16539-NetworkConfigHandler/14.0.0/Instabug.podspec instabug_flutter: :path: ".symlinks/plugins/instabug_flutter/ios" SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - Instabug: 3fa42ac8b4350cb632df724b14a86ebdb875aad9 + Instabug: d727e5d85ca7ae8571eeb0754086a2df7b096b19 instabug_flutter: ff8ab5ff34a476b1d2d887478ec190cda962b973 OCMock: 5ea90566be239f179ba766fd9fbae5885040b992 -PODFILE CHECKSUM: e7d6c199070a4a2b3664012221f598abd9a35e69 +PODFILE CHECKSUM: 1ed6d7606fbc661422f116efe43de9d8d1666637 COCOAPODS: 1.15.2