Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1161)

Side by Side Diff: runtime/bin/main.cc

Issue 2125343002: Ban cross origin WebSocket connections to the service protocol (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: skybrian review Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 static bool trace_loading = false; 112 static bool trace_loading = false;
113 113
114 114
115 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1"; 115 static const char* DEFAULT_VM_SERVICE_SERVER_IP = "127.0.0.1";
116 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181; 116 static const int DEFAULT_VM_SERVICE_SERVER_PORT = 8181;
117 // VM Service options. 117 // VM Service options.
118 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP; 118 static const char* vm_service_server_ip = DEFAULT_VM_SERVICE_SERVER_IP;
119 // The 0 port is a magic value which results in the first available port 119 // The 0 port is a magic value which results in the first available port
120 // being allocated. 120 // being allocated.
121 static int vm_service_server_port = -1; 121 static int vm_service_server_port = -1;
122 122 // True when we are running in development mode and cross origin security
123 // checks are disabled.
124 static bool vm_service_dev_mode = false;
123 125
124 // Exit code indicating an API error. 126 // Exit code indicating an API error.
125 static const int kApiErrorExitCode = 253; 127 static const int kApiErrorExitCode = 253;
126 // Exit code indicating a compilation error. 128 // Exit code indicating a compilation error.
127 static const int kCompilationErrorExitCode = 254; 129 static const int kCompilationErrorExitCode = 254;
128 // Exit code indicating an unhandled error that is not a compilation error. 130 // Exit code indicating an unhandled error that is not a compilation error.
129 static const int kErrorExitCode = 255; 131 static const int kErrorExitCode = 255;
130 // Exit code indicating a vm restart request. Never returned to the user. 132 // Exit code indicating a vm restart request. Never returned to the user.
131 static const int kRestartRequestExitCode = 1000; 133 static const int kRestartRequestExitCode = 1000;
132 134
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 DEFAULT_VM_SERVICE_SERVER_IP)) { 388 DEFAULT_VM_SERVICE_SERVER_IP)) {
387 Log::PrintErr("unrecognized --enable-vm-service option syntax. " 389 Log::PrintErr("unrecognized --enable-vm-service option syntax. "
388 "Use --enable-vm-service[=<port number>[/<IPv4 address>]]\n"); 390 "Use --enable-vm-service[=<port number>[/<IPv4 address>]]\n");
389 return false; 391 return false;
390 } 392 }
391 393
392 return true; 394 return true;
393 } 395 }
394 396
395 397
398 static bool ProcessDisableServiceOriginCheckOption(
399 const char* option_value, CommandLineOptions* vm_options) {
400 ASSERT(option_value != NULL);
401 Log::PrintErr("WARNING: You are running with the service protocol in an "
402 "insecure mode.\n");
403 vm_service_dev_mode = true;
404 return true;
405 }
406
407
396 static bool ProcessObserveOption(const char* option_value, 408 static bool ProcessObserveOption(const char* option_value,
397 CommandLineOptions* vm_options) { 409 CommandLineOptions* vm_options) {
398 ASSERT(option_value != NULL); 410 ASSERT(option_value != NULL);
399 411
400 if (!ExtractPortAndIP(option_value, 412 if (!ExtractPortAndIP(option_value,
401 &vm_service_server_port, 413 &vm_service_server_port,
402 &vm_service_server_ip, 414 &vm_service_server_ip,
403 DEFAULT_VM_SERVICE_SERVER_PORT, 415 DEFAULT_VM_SERVICE_SERVER_PORT,
404 DEFAULT_VM_SERVICE_SERVER_IP)) { 416 DEFAULT_VM_SERVICE_SERVER_IP)) {
405 Log::PrintErr("unrecognized --observe option syntax. " 417 Log::PrintErr("unrecognized --observe option syntax. "
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 { "--help", ProcessHelpOption }, 495 { "--help", ProcessHelpOption },
484 { "--packages=", ProcessPackagesOption }, 496 { "--packages=", ProcessPackagesOption },
485 { "--package-root=", ProcessPackageRootOption }, 497 { "--package-root=", ProcessPackageRootOption },
486 { "-v", ProcessVerboseOption }, 498 { "-v", ProcessVerboseOption },
487 { "--verbose", ProcessVerboseOption }, 499 { "--verbose", ProcessVerboseOption },
488 { "--version", ProcessVersionOption }, 500 { "--version", ProcessVersionOption },
489 501
490 // VM specific options to the standalone dart program. 502 // VM specific options to the standalone dart program.
491 { "--compile_all", ProcessCompileAllOption }, 503 { "--compile_all", ProcessCompileAllOption },
492 { "--enable-vm-service", ProcessEnableVmServiceOption }, 504 { "--enable-vm-service", ProcessEnableVmServiceOption },
505 { "--disable-service-origin-check", ProcessDisableServiceOriginCheckOption },
493 { "--observe", ProcessObserveOption }, 506 { "--observe", ProcessObserveOption },
494 { "--shutdown", ProcessShutdownOption }, 507 { "--shutdown", ProcessShutdownOption },
495 { "--snapshot=", ProcessSnapshotFilenameOption }, 508 { "--snapshot=", ProcessSnapshotFilenameOption },
496 { "--snapshot-kind=", ProcessSnapshotKindOption }, 509 { "--snapshot-kind=", ProcessSnapshotKindOption },
497 { "--run-app-snapshot=", ProcessRunAppSnapshotOption }, 510 { "--run-app-snapshot=", ProcessRunAppSnapshotOption },
498 { "--use-blobs", ProcessUseBlobsOption }, 511 { "--use-blobs", ProcessUseBlobsOption },
499 { "--trace-loading", ProcessTraceLoadingOption }, 512 { "--trace-loading", ProcessTraceLoadingOption },
500 { "--hot-reload-test-mode", ProcessHotReloadTestModeOption }, 513 { "--hot-reload-test-mode", ProcessHotReloadTestModeOption },
501 { NULL, NULL } 514 { NULL, NULL }
502 }; 515 };
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 772
760 // Set up the library tag handler for this isolate. 773 // Set up the library tag handler for this isolate.
761 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler); 774 Dart_Handle result = Dart_SetLibraryTagHandler(Loader::LibraryTagHandler);
762 CHECK_RESULT(result); 775 CHECK_RESULT(result);
763 776
764 if (Dart_IsServiceIsolate(isolate)) { 777 if (Dart_IsServiceIsolate(isolate)) {
765 // If this is the service isolate, load embedder specific bits and return. 778 // If this is the service isolate, load embedder specific bits and return.
766 bool skip_library_load = run_app_snapshot; 779 bool skip_library_load = run_app_snapshot;
767 if (!VmService::Setup(vm_service_server_ip, 780 if (!VmService::Setup(vm_service_server_ip,
768 vm_service_server_port, 781 vm_service_server_port,
769 skip_library_load)) { 782 skip_library_load,
783 vm_service_dev_mode)) {
770 *error = strdup(VmService::GetErrorMessage()); 784 *error = strdup(VmService::GetErrorMessage());
771 return NULL; 785 return NULL;
772 } 786 }
773 if (compile_all) { 787 if (compile_all) {
774 result = Dart_CompileAll(); 788 result = Dart_CompileAll();
775 CHECK_RESULT(result); 789 CHECK_RESULT(result);
776 } 790 }
777 Dart_ExitScope(); 791 Dart_ExitScope();
778 Dart_ExitIsolate(); 792 Dart_ExitIsolate();
779 return isolate; 793 return isolate;
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 Platform::Exit(Process::GlobalExitCode()); 1783 Platform::Exit(Process::GlobalExitCode());
1770 } 1784 }
1771 1785
1772 } // namespace bin 1786 } // namespace bin
1773 } // namespace dart 1787 } // namespace dart
1774 1788
1775 int main(int argc, char** argv) { 1789 int main(int argc, char** argv) {
1776 dart::bin::main(argc, argv); 1790 dart::bin::main(argc, argv);
1777 UNREACHABLE(); 1791 UNREACHABLE();
1778 } 1792 }
OLDNEW
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/vmservice/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698