浏览代码

rn: avoid logging initial props in release builds

They may contain sensitive information.
j8
Saúl Ibarra Corretgé 6 年前
父节点
当前提交
fa3888991f

+ 6
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj 查看文件

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

+ 2
- 0
ios/sdk/src/JitsiMeet+Private.h 查看文件

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

+ 5
- 6
ios/sdk/src/JitsiMeetView.m 查看文件

@@ -17,12 +17,11 @@
17 17
 
18 18
 #include <mach/mach_time.h>
19 19
 
20
-#import <React/RCTRootView.h>
21
-
22 20
 #import "JitsiMeet+Private.h"
23 21
 #import "JitsiMeetConferenceOptions+Private.h"
24 22
 #import "JitsiMeetView+Private.h"
25 23
 #import "ReactUtils.h"
24
+#import "RNRootView.h"
26 25
 
27 26
 
28 27
 @implementation JitsiMeetView {
@@ -36,7 +35,7 @@
36 35
     /**
37 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,9 +144,9 @@ static void initializeViewsMap() {
145 144
     } else {
146 145
         RCTBridge *bridge = [[JitsiMeet sharedInstance] getReactBridge];
147 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 150
         rootView.backgroundColor = self.backgroundColor;
152 151
 
153 152
         // Add rootView as a subview which completely covers this one.

+ 20
- 0
ios/sdk/src/RNRootView.h 查看文件

@@ -0,0 +1,20 @@
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 查看文件

@@ -0,0 +1,45 @@
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,6 +16,8 @@ import { AppRegistry } from 'react-native';
16 16
 import { App } from './features/app';
17 17
 import { IncomingCallApp } from './features/mobile/incoming-call';
18 18
 
19
+declare var __DEV__;
20
+
19 21
 /**
20 22
  * The type of the React {@code Component} props of {@link Root}.
21 23
  */
@@ -49,6 +51,26 @@ class Root extends PureComponent<Props> {
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 74
 // Register the main/root Component of JitsiMeetView.
53 75
 AppRegistry.registerComponent('App', () => Root);
54 76
 

正在加载...
取消
保存