Remove copyToClipBoardMiddleware

Summary:
This diff removes the copyToClipBoardMiddleware. This was exposing the /copy-to-clipboard endpoint that allowed unauthenticated access to writing to a developers clipboard.

This was only used in a single place, the Android red box dialog, so I've removed it from there.

Reviewed By: cpojer

Differential Revision: D14790813

fbshipit-source-id: 80e044eefd9658b8c5885643cdadf7947c00d34a
This commit is contained in:
Sebastian McKenzie
2019-04-10 13:37:00 -07:00
committed by Facebook Github Bot
parent 135ba492fb
commit d338a60cbe
2 changed files with 0 additions and 48 deletions

View File

@@ -55,7 +55,6 @@ import org.json.JSONObject;
private ListView mStackView;
private Button mReloadJsButton;
private Button mDismissButton;
private Button mCopyToClipboardButton;
private @Nullable Button mReportButton;
private @Nullable TextView mReportTextView;
private @Nullable ProgressBar mLoadingIndicator;
@@ -229,35 +228,6 @@ import org.json.JSONObject;
}
}
private static class CopyToHostClipBoardTask extends AsyncTask<String, Void, Void> {
private final DevSupportManager mDevSupportManager;
private CopyToHostClipBoardTask(DevSupportManager devSupportManager) {
mDevSupportManager = devSupportManager;
}
@Override
protected Void doInBackground(String... clipBoardString) {
try {
String sendClipBoardUrl =
Uri.parse(mDevSupportManager.getSourceUrl()).buildUpon()
.path("/copy-to-clipboard")
.query(null)
.build()
.toString();
for (String string: clipBoardString) {
OkHttpClient client = new OkHttpClient();
RequestBody body = RequestBody.create(null, string);
Request request = new Request.Builder().url(sendClipBoardUrl).post(body).build();
client.newCall(request).execute();
}
} catch (Exception e) {
FLog.e(ReactConstants.TAG, "Could not copy to the host clipboard", e);
}
return null;
}
}
protected RedBoxDialog(
Context context,
DevSupportManager devSupportManager,
@@ -289,19 +259,6 @@ import org.json.JSONObject;
dismiss();
}
});
mCopyToClipboardButton = (Button) findViewById(R.id.rn_redbox_copy_button);
mCopyToClipboardButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title = mDevSupportManager.getLastErrorTitle();
StackFrame[] stack = mDevSupportManager.getLastErrorStack();
Assertions.assertNotNull(title);
Assertions.assertNotNull(stack);
new CopyToHostClipBoardTask(mDevSupportManager).executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR,
StackTraceHelper.formatStackTrace(title, stack));
}
});
if (mRedBoxHandler != null && mRedBoxHandler.isReportEnabled()) {
mLoadingIndicator = (ProgressBar) findViewById(R.id.rn_redbox_loading_indicator);

View File

@@ -65,11 +65,6 @@
android:text="@string/catalyst_reload_button"
style="@style/redboxButton"
/>
<Button
android:id="@+id/rn_redbox_copy_button"
android:text="@string/catalyst_copy_button"
style="@style/redboxButton"
/>
<Button
android:id="@+id/rn_redbox_report_button"
android:text="@string/catalyst_report_button"