forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-native+0.75.2+017+redactAppParameters.patch
40 lines (40 loc) · 1.49 KB
/
react-native+0.75.2+017+redactAppParameters.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/node_modules/react-native/Libraries/ReactNative/AppRegistry.js b/node_modules/react-native/Libraries/ReactNative/AppRegistry.js
index 68bd389..be9b5bf 100644
--- a/node_modules/react-native/Libraries/ReactNative/AppRegistry.js
+++ b/node_modules/react-native/Libraries/ReactNative/AppRegistry.js
@@ -232,12 +232,34 @@ const AppRegistry = {
appParameters: Object,
displayMode?: number,
): void {
+ const redactAppParameters = (parameters) => {
+ const initialProps = parameters['initialProps'];
+ const url = initialProps['url'];
+
+ if(!url) {
+ return parameters;
+ }
+
+ const sensitiveParams = ['authToken', 'autoGeneratedPassword', 'autoGeneratedLogin'];
+ const [urlBase, queryString] = url.split('?');
+
+ if (!queryString) {
+ return parameters;
+ }
+
+ const redactedSearchParams = queryString.split('&').map((param) => {
+ const [key, value] = param.split('=');
+ return `${key}=${sensitiveParams.includes(key) ? '<REDACTED>' : value}`
+ });
+ return {...parameters, initialProps: {...initialProps, url: `${urlBase}?${redactedSearchParams.join('&')}`}};
+ }
+
if (appKey !== 'LogBox') {
const msg =
'Updating props for Surface "' +
appKey +
'" with ' +
- JSON.stringify(appParameters);
+ JSON.stringify(redactAppParameters(appParameters));
infoLog(msg);
BugReporting.addSource(
'AppRegistry.setSurfaceProps' + runCount++,