Просмотр исходного кода

rn: avoid logging initial props in release builds

They may contain sensitive information.
j8
Saúl Ibarra Corretgé 6 лет назад
Родитель
Сommit
fa3888991f

+ 6
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj Просмотреть файл

44
 		C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
44
 		C6CC49AF207412CF000DFA42 /* PiPViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC49AE207412CF000DFA42 /* PiPViewCoordinator.swift */; };
45
 		DEAD3226220C497000E93636 /* JitsiMeetConferenceOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
45
 		DEAD3226220C497000E93636 /* JitsiMeetConferenceOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
46
 		DEAD3227220C497000E93636 /* JitsiMeetConferenceOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */; };
46
 		DEAD3227220C497000E93636 /* JitsiMeetConferenceOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */; };
47
+		DEAFA779229EAD520033A7FA /* RNRootView.m in Sources */ = {isa = PBXBuildFile; fileRef = DEAFA778229EAD520033A7FA /* RNRootView.m */; };
47
 		DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */; };
48
 		DEFC743F21B178FA00E4DD96 /* LocaleDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */; };
48
 		DEFE535421FB1BF800011A3A /* JitsiMeet.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFE535321FB1BF800011A3A /* JitsiMeet.m */; };
49
 		DEFE535421FB1BF800011A3A /* JitsiMeet.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFE535321FB1BF800011A3A /* JitsiMeet.m */; };
49
 		DEFE535621FB2E8300011A3A /* ReactUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFE535521FB2E8300011A3A /* ReactUtils.m */; };
50
 		DEFE535621FB2E8300011A3A /* ReactUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = DEFE535521FB2E8300011A3A /* ReactUtils.m */; };
96
 		DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JitsiMeetConferenceOptions.h; sourceTree = "<group>"; };
97
 		DEAD3224220C497000E93636 /* JitsiMeetConferenceOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JitsiMeetConferenceOptions.h; sourceTree = "<group>"; };
97
 		DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiMeetConferenceOptions.m; sourceTree = "<group>"; };
98
 		DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiMeetConferenceOptions.m; sourceTree = "<group>"; };
98
 		DEAD3228220C734300E93636 /* JitsiMeetConferenceOptions+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetConferenceOptions+Private.h"; sourceTree = "<group>"; };
99
 		DEAD3228220C734300E93636 /* JitsiMeetConferenceOptions+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JitsiMeetConferenceOptions+Private.h"; sourceTree = "<group>"; };
100
+		DEAFA777229EAD3B0033A7FA /* RNRootView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNRootView.h; sourceTree = "<group>"; };
101
+		DEAFA778229EAD520033A7FA /* RNRootView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNRootView.m; sourceTree = "<group>"; };
99
 		DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocaleDetector.m; sourceTree = "<group>"; };
102
 		DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LocaleDetector.m; sourceTree = "<group>"; };
100
 		DEFE535321FB1BF800011A3A /* JitsiMeet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiMeet.m; sourceTree = "<group>"; };
103
 		DEFE535321FB1BF800011A3A /* JitsiMeet.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JitsiMeet.m; sourceTree = "<group>"; };
101
 		DEFE535521FB2E8300011A3A /* ReactUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReactUtils.m; sourceTree = "<group>"; };
104
 		DEFE535521FB2E8300011A3A /* ReactUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReactUtils.m; sourceTree = "<group>"; };
173
 				DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */,
176
 				DEAD3225220C497000E93636 /* JitsiMeetConferenceOptions.m */,
174
 				0B412F161EDEC65D00B1A0A6 /* JitsiMeetView.h */,
177
 				0B412F161EDEC65D00B1A0A6 /* JitsiMeetView.h */,
175
 				0B412F171EDEC65D00B1A0A6 /* JitsiMeetView.m */,
178
 				0B412F171EDEC65D00B1A0A6 /* JitsiMeetView.m */,
179
+				DEAFA777229EAD3B0033A7FA /* RNRootView.h */,
180
+				DEAFA778229EAD520033A7FA /* RNRootView.m */,
176
 				C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */,
181
 				C6F99C13204DB63D0001F710 /* JitsiMeetView+Private.h */,
177
 				0B412F1B1EDEC80100B1A0A6 /* JitsiMeetViewDelegate.h */,
182
 				0B412F1B1EDEC80100B1A0A6 /* JitsiMeetViewDelegate.h */,
178
 				DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */,
183
 				DEFC743D21B178FA00E4DD96 /* LocaleDetector.m */,
478
 			files = (
483
 			files = (
479
 				0BB9AD7B1F5EC8F4001C08DB /* CallKit.m in Sources */,
484
 				0BB9AD7B1F5EC8F4001C08DB /* CallKit.m in Sources */,
480
 				0BB9AD7D1F60356D001C08DB /* AppInfo.m in Sources */,
485
 				0BB9AD7D1F60356D001C08DB /* AppInfo.m in Sources */,
486
+				DEAFA779229EAD520033A7FA /* RNRootView.m in Sources */,
481
 				DEAD3227220C497000E93636 /* JitsiMeetConferenceOptions.m in Sources */,
487
 				DEAD3227220C497000E93636 /* JitsiMeetConferenceOptions.m in Sources */,
482
 				0B93EF7F1EC9DDCD0030D24D /* RCTBridgeWrapper.m in Sources */,
488
 				0B93EF7F1EC9DDCD0030D24D /* RCTBridgeWrapper.m in Sources */,
483
 				0BA13D311EE83FF8007BEF7F /* ExternalAPI.m in Sources */,
489
 				0BA13D311EE83FF8007BEF7F /* ExternalAPI.m in Sources */,

+ 2
- 0
ios/sdk/src/JitsiMeet+Private.h Просмотреть файл

14
  * limitations under the License.
14
  * limitations under the License.
15
  */
15
  */
16
 
16
 
17
+#import <React/RCTBridge.h>
18
+
17
 #import "JitsiMeet.h"
19
 #import "JitsiMeet.h"
18
 
20
 
19
 @interface JitsiMeet ()
21
 @interface JitsiMeet ()

+ 5
- 6
ios/sdk/src/JitsiMeetView.m Просмотреть файл

17
 
17
 
18
 #include <mach/mach_time.h>
18
 #include <mach/mach_time.h>
19
 
19
 
20
-#import <React/RCTRootView.h>
21
-
22
 #import "JitsiMeet+Private.h"
20
 #import "JitsiMeet+Private.h"
23
 #import "JitsiMeetConferenceOptions+Private.h"
21
 #import "JitsiMeetConferenceOptions+Private.h"
24
 #import "JitsiMeetView+Private.h"
22
 #import "JitsiMeetView+Private.h"
25
 #import "ReactUtils.h"
23
 #import "ReactUtils.h"
24
+#import "RNRootView.h"
26
 
25
 
27
 
26
 
28
 @implementation JitsiMeetView {
27
 @implementation JitsiMeetView {
36
     /**
35
     /**
37
      * React Native view where the entire content will be rendered.
36
      * React Native view where the entire content will be rendered.
38
      */
37
      */
39
-    RCTRootView *rootView;
38
+    RNRootView *rootView;
40
 }
39
 }
41
 
40
 
42
 /**
41
 /**
145
     } else {
144
     } else {
146
         RCTBridge *bridge = [[JitsiMeet sharedInstance] getReactBridge];
145
         RCTBridge *bridge = [[JitsiMeet sharedInstance] getReactBridge];
147
         rootView
146
         rootView
148
-            = [[RCTRootView alloc] initWithBridge:bridge
149
-                                       moduleName:@"App"
150
-                                initialProperties:props];
147
+            = [[RNRootView alloc] initWithBridge:bridge
148
+                                      moduleName:@"App"
149
+                               initialProperties:props];
151
         rootView.backgroundColor = self.backgroundColor;
150
         rootView.backgroundColor = self.backgroundColor;
152
 
151
 
153
         // Add rootView as a subview which completely covers this one.
152
         // Add rootView as a subview which completely covers this one.

+ 20
- 0
ios/sdk/src/RNRootView.h Просмотреть файл

1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import <React/RCTRootView.h>
18
+
19
+@interface RNRootView : RCTRootView
20
+@end

+ 45
- 0
ios/sdk/src/RNRootView.m Просмотреть файл

1
+/*
2
+ * Copyright @ 2019-present 8x8, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+#import <React/RCTRootContentView.h>
18
+#import <React/RCTLog.h>
19
+
20
+#import "RNRootView.h"
21
+
22
+@implementation RNRootView
23
+
24
+// Monkey-patch RCTRootView.runApplication to avoid logging initial props.
25
+- (void)runApplication:(RCTBridge *)bridge
26
+{
27
+    NSString *moduleName = [self valueForKey:@"_moduleName"] ?: @"";
28
+    RCTRootContentView *_contentView = [self valueForKey:@"_contentView"];
29
+    NSNumber *reactTag = [_contentView valueForKey:@"reactTag"];
30
+
31
+    NSDictionary *appParameters = @{
32
+                                    @"rootTag": reactTag,
33
+                                    @"initialProps": self.appProperties ?: @{},
34
+                                    };
35
+#if DEBUG
36
+    RCTLogInfo(@"Running application %@ (%@)", moduleName, appParameters);
37
+#endif
38
+
39
+    [bridge enqueueJSCall:@"AppRegistry"
40
+                   method:@"runApplication"
41
+                     args:@[moduleName, appParameters]
42
+               completion:NULL];
43
+}
44
+
45
+@end

+ 22
- 0
react/index.native.js Просмотреть файл

16
 import { App } from './features/app';
16
 import { App } from './features/app';
17
 import { IncomingCallApp } from './features/mobile/incoming-call';
17
 import { IncomingCallApp } from './features/mobile/incoming-call';
18
 
18
 
19
+declare var __DEV__;
20
+
19
 /**
21
 /**
20
  * The type of the React {@code Component} props of {@link Root}.
22
  * The type of the React {@code Component} props of {@link Root}.
21
  */
23
  */
49
     }
51
     }
50
 }
52
 }
51
 
53
 
54
+// HORRIBLE HACK ALERT! React Native logs the initial props with `console.log`. Here we are quickly patching it
55
+// to avoid logging potentially sensitive information.
56
+if (!__DEV__) {
57
+    /* eslint-disable */
58
+
59
+    const __orig_console_log = console.log;
60
+    const __orig_appregistry_runapplication = AppRegistry.runApplication;
61
+
62
+    AppRegistry.runApplication = (...args) => {
63
+        // $FlowExpectedError
64
+        console.log = () => {};
65
+        __orig_appregistry_runapplication(...args);
66
+        // $FlowExpectedError
67
+        console.log = __orig_console_log;
68
+    };
69
+
70
+    /* eslint-enable */
71
+}
72
+
73
+
52
 // Register the main/root Component of JitsiMeetView.
74
 // Register the main/root Component of JitsiMeetView.
53
 AppRegistry.registerComponent('App', () => Root);
75
 AppRegistry.registerComponent('App', () => Root);
54
 
76
 

Загрузка…
Отмена
Сохранить