From 9464c629e0233668db0f62af4da401cb244dca0d Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Tue, 9 Apr 2019 16:21:03 -0700 Subject: [PATCH 1/8] Added support for authentication codes for the VM service --- DEPS | 2 +- common/settings.h | 4 ++++ runtime/dart_isolate.cc | 1 + runtime/dart_service_isolate.cc | 5 +++++ runtime/dart_service_isolate.h | 1 + runtime/dart_vm.cc | 10 ++++++++++ shell/common/switches.cc | 5 +++++ shell/common/switches.h | 4 ++++ .../io/flutter/app/FlutterActivityDelegate.java | 3 +++ .../io/flutter/embedding/engine/FlutterShellArgs.java | 7 ++++++- 10 files changed, 40 insertions(+), 2 deletions(-) diff --git a/DEPS b/DEPS index 9997fe191459b..27d88909d089d 100644 --- a/DEPS +++ b/DEPS @@ -31,7 +31,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS. # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': 'aacc0b07098231ff2051cbc7b40c932171caaddb', + 'dart_revision': '15b11b018364ce032eae50d78fc8a52b541e2bce', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py diff --git a/common/settings.h b/common/settings.h index 1bd54f4126b38..c973f6fd23388 100644 --- a/common/settings.h +++ b/common/settings.h @@ -86,6 +86,10 @@ struct Settings { uint32_t observatory_port = 0; bool ipv6 = false; + // Determines whether an authentication code is required to communicate with + // the VM service. + bool disable_service_auth_codes = false; + // Font settings bool use_test_fonts = false; diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 91cd8bb5dd4aa..c7736728afc7b 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -580,6 +580,7 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( settings.observatory_port, // server observatory port tonic::DartState::HandleLibraryTag, // embedder library tag handler false, // disable websocket origin check + settings.disable_service_auth_codes, // disable VM service auth codes error // error (out) )) { // Error is populated by call to startup. diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index 2bedd79f81716..617fd1d48ae3a 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -134,6 +134,7 @@ bool DartServiceIsolate::Startup(std::string server_ip, intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, + bool disable_service_auth_codes, char** error) { Dart_Isolate isolate = Dart_CurrentIsolate(); FML_CHECK(isolate); @@ -196,6 +197,10 @@ bool DartServiceIsolate::Startup(std::string server_ip, Dart_SetField(library, Dart_NewStringFromCString("_originCheckDisabled"), Dart_NewBoolean(disable_origin_check)); SHUTDOWN_ON_ERROR(result); + result = + Dart_SetField(library, Dart_NewStringFromCString("_authCodesDisabled"), + Dart_NewBoolean(disable_service_auth_codes)); + SHUTDOWN_ON_ERROR(result); return true; } diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index cf4137a1e6b49..0c1f0d179e32c 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -26,6 +26,7 @@ class DartServiceIsolate { intptr_t server_port, Dart_LibraryTagHandler embedder_tag_handler, bool disable_origin_check, + bool disable_service_auth_codes, char** error); static std::string GetObservatoryUri(); diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index db8acaaa46abc..d5d8be6ff62d7 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -84,6 +84,11 @@ static const char* kDartStartPausedArgs[]{ "--pause_isolates_on_start", }; + +static const char* kDartDisableServiceAuthCodesArgs[] { + "--disable-service-auth-codes", +}; + static const char* kDartTraceStartupArgs[]{ "--timeline_streams=Compiler,Dart,Debugger,Embedder,GC,Isolate,VM", }; @@ -325,6 +330,11 @@ DartVM::DartVM(std::shared_ptr vm_data, PushBackAll(&args, kDartStartPausedArgs, arraysize(kDartStartPausedArgs)); } + if (settings_.disable_service_auth_codes) { + PushBackAll(&args, kDartDisableServiceAuthCodesArgs, + arraysize(kDartDisableServiceAuthCodesArgs)); + } + if (settings_.endless_trace_buffer || settings_.trace_startup) { // If we are tracing startup, make sure the trace buffer is endless so we // don't lose early traces. diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 215e043f78505..49a664ca29653 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -167,6 +167,11 @@ blink::Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { } } + // Disable need for authentication codes for VM service communication, if + // specified. + settings.disable_service_auth_codes = + command_line.HasOption(FlagForSwitch(Switch::DisableServiceAuthCodes)); + // Checked mode overrides. settings.disable_dart_asserts = command_line.HasOption(FlagForSwitch(Switch::DisableDartAsserts)); diff --git a/shell/common/switches.h b/shell/common/switches.h index 951bf7ad55b24..42b3d532cd3b9 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -99,6 +99,10 @@ DEF_SWITCH(FlutterAssetsDir, "Path to the Flutter assets directory.") DEF_SWITCH(Help, "help", "Display this help text.") DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.") +DEF_SWITCH(DisableServiceAuthCodes, + "disable-service-auth-codes", + "Disable the requirement for authentication codes for communicating" + " with the VM service.") DEF_SWITCH(StartPaused, "start-paused", "Start the application paused in the Dart debugger.") diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index c56908db643b3..3f971c0d61fbc 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -297,6 +297,9 @@ private static String[] getArgsFromIntent(Intent intent) { if (intent.getBooleanExtra("start-paused", false)) { args.add("--start-paused"); } + if (intent.getBooleanExtra("disable-service-auth-codes", false)) { + args.add("--disable-service-auth-codes"); + } if (intent.getBooleanExtra("use-test-fonts", false)) { args.add("--use-test-fonts"); } diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java index 6e5ec8c7ba7bc..c2fab9f035b71 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java @@ -27,6 +27,8 @@ public class FlutterShellArgs { public static final String ARG_TRACE_STARTUP = "--trace-startup"; public static final String ARG_KEY_START_PAUSED = "start-paused"; public static final String ARG_START_PAUSED = "--start-paused"; + public static final String ARG_KEY_DISABLE_SERVICE_AUTH_CODES = "disable-service-auth-codes"; + public static final String ARG_DISABLE_SERVICE_AUTH_CODES = "--disable-service-auth-codes"; public static final String ARG_KEY_USE_TEST_FONTS = "use-test-fonts"; public static final String ARG_USE_TEST_FONTS = "--use-test-fonts"; public static final String ARG_KEY_ENABLE_DART_PROFILING = "enable-dart-profiling"; @@ -56,6 +58,9 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) { if (intent.getBooleanExtra(ARG_KEY_START_PAUSED, false)) { args.add(ARG_START_PAUSED); } + if (intent.getBooleanExtra(ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) { + args.add(ARG_DISABLE_SERVICE_AUTH_CODES); + } if (intent.getBooleanExtra(ARG_KEY_USE_TEST_FONTS, false)) { args.add(ARG_USE_TEST_FONTS); } @@ -133,4 +138,4 @@ public String[] toArray() { String[] argsArray = new String[args.size()]; return args.toArray(argsArray); } -} \ No newline at end of file +} From 4ce96bf5e34d5698f5c27c5738ffb199ca9ae23f Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 08:12:46 -0700 Subject: [PATCH 2/8] Formatting --- runtime/dart_isolate.cc | 4 ++-- runtime/dart_vm.cc | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 60fe9436b800c..3c888887d9847 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -579,8 +579,8 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate( settings.observatory_port, // server observatory port tonic::DartState::HandleLibraryTag, // embedder library tag handler false, // disable websocket origin check - settings.disable_service_auth_codes, // disable VM service auth codes - error // error (out) + settings.disable_service_auth_codes, // disable VM service auth codes + error // error (out) )) { // Error is populated by call to startup. FML_DLOG(ERROR) << *error; diff --git a/runtime/dart_vm.cc b/runtime/dart_vm.cc index 7d563db616b80..476d05f2fc651 100644 --- a/runtime/dart_vm.cc +++ b/runtime/dart_vm.cc @@ -84,8 +84,7 @@ static const char* kDartStartPausedArgs[]{ "--pause_isolates_on_start", }; - -static const char* kDartDisableServiceAuthCodesArgs[] { +static const char* kDartDisableServiceAuthCodesArgs[]{ "--disable-service-auth-codes", }; From 17df86d54d0a9332e633a68aa0095d263a97c02c Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 08:51:29 -0700 Subject: [PATCH 3/8] Licenses --- ci/licenses_golden/licenses_third_party | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index 05eaa5a85773c..ea4c2e9ba7287 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 1ab2f2e559e655ad5cfe1e759d241b54 +Signature: 866085660a05bb407caffc09636cbd32 UNUSED LICENSES: From 012a5c68ba6c73792e2fff31bb1e3d2dc9416d4c Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 13:49:59 -0700 Subject: [PATCH 4/8] Disable auth codes by default for now --- common/settings.h | 2 +- shell/common/switches.cc | 2 +- shell/common/switches.h | 6 +++--- .../io/flutter/embedding/engine/FlutterShellArgs.java | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/common/settings.h b/common/settings.h index 038be9f9ccca5..96a1f8f92c122 100644 --- a/common/settings.h +++ b/common/settings.h @@ -88,7 +88,7 @@ struct Settings { // Determines whether an authentication code is required to communicate with // the VM service. - bool disable_service_auth_codes = false; + bool disable_service_auth_codes = true; // Font settings bool use_test_fonts = false; diff --git a/shell/common/switches.cc b/shell/common/switches.cc index d28977363688b..cee4942538213 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -169,7 +169,7 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { // Disable need for authentication codes for VM service communication, if // specified. settings.disable_service_auth_codes = - command_line.HasOption(FlagForSwitch(Switch::DisableServiceAuthCodes)); + !command_line.HasOption(FlagForSwitch(Switch::EnableServiceAuthCodes)); // Checked mode overrides. settings.disable_dart_asserts = diff --git a/shell/common/switches.h b/shell/common/switches.h index 7747c33bca44c..60fa03d66d9f0 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -96,9 +96,9 @@ DEF_SWITCH(FlutterAssetsDir, "Path to the Flutter assets directory.") DEF_SWITCH(Help, "help", "Display this help text.") DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.") -DEF_SWITCH(DisableServiceAuthCodes, - "disable-service-auth-codes", - "Disable the requirement for authentication codes for communicating" +DEF_SWITCH(EnableServiceAuthCodes, + "enable-service-auth-codes", + "Enable the requirement for authentication codes for communicating" " with the VM service.") DEF_SWITCH(StartPaused, "start-paused", diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java index c2fab9f035b71..4babc3cd033e2 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java @@ -27,8 +27,8 @@ public class FlutterShellArgs { public static final String ARG_TRACE_STARTUP = "--trace-startup"; public static final String ARG_KEY_START_PAUSED = "start-paused"; public static final String ARG_START_PAUSED = "--start-paused"; - public static final String ARG_KEY_DISABLE_SERVICE_AUTH_CODES = "disable-service-auth-codes"; - public static final String ARG_DISABLE_SERVICE_AUTH_CODES = "--disable-service-auth-codes"; + public static final String ARG_KEY_ENABLE_SERVICE_AUTH_CODES = "enable-service-auth-codes"; + public static final String ARG_ENABLE_SERVICE_AUTH_CODES = "--enable-service-auth-codes"; public static final String ARG_KEY_USE_TEST_FONTS = "use-test-fonts"; public static final String ARG_USE_TEST_FONTS = "--use-test-fonts"; public static final String ARG_KEY_ENABLE_DART_PROFILING = "enable-dart-profiling"; @@ -58,8 +58,8 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) { if (intent.getBooleanExtra(ARG_KEY_START_PAUSED, false)) { args.add(ARG_START_PAUSED); } - if (intent.getBooleanExtra(ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) { - args.add(ARG_DISABLE_SERVICE_AUTH_CODES); + if (intent.getBooleanExtra(ARG_KEY_ENABLE_SERVICE_AUTH_CODES, false)) { + args.add(ARG_ENABLE_SERVICE_AUTH_CODES); } if (intent.getBooleanExtra(ARG_KEY_USE_TEST_FONTS, false)) { args.add(ARG_USE_TEST_FONTS); From fd021955cb614debaedb00386c7a6b9a6c129875 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 14:07:39 -0700 Subject: [PATCH 5/8] Comments --- .../android/io/flutter/embedding/engine/FlutterShellArgs.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java index 4babc3cd033e2..8a65a1430bb05 100644 --- a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java +++ b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java @@ -58,6 +58,8 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) { if (intent.getBooleanExtra(ARG_KEY_START_PAUSED, false)) { args.add(ARG_START_PAUSED); } + // TODO(bkonyi): when authentication codes are enabled by default, change + // to 'disable-service-auth-codes' instead of 'enable-service-auth-codes'. if (intent.getBooleanExtra(ARG_KEY_ENABLE_SERVICE_AUTH_CODES, false)) { args.add(ARG_ENABLE_SERVICE_AUTH_CODES); } From 66713ea68074a95488c45e1cf66be8c5a83edcd0 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 14:08:21 -0700 Subject: [PATCH 6/8] Comments --- shell/common/switches.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/common/switches.h b/shell/common/switches.h index 60fa03d66d9f0..b0ff32d9b45c1 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -96,6 +96,8 @@ DEF_SWITCH(FlutterAssetsDir, "Path to the Flutter assets directory.") DEF_SWITCH(Help, "help", "Display this help text.") DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.") +// TODO(bkonyi): when authentication codes are enabled by default, change +// to 'disable-service-auth-codes' instead of 'enable-service-auth-codes'. DEF_SWITCH(EnableServiceAuthCodes, "enable-service-auth-codes", "Enable the requirement for authentication codes for communicating" From 4aba26b70556fd7ea167a946912cdcecb4c2cfb9 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 14:09:18 -0700 Subject: [PATCH 7/8] Comments --- shell/common/switches.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/common/switches.cc b/shell/common/switches.cc index cee4942538213..366923614b3bc 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -166,8 +166,10 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { } } - // Disable need for authentication codes for VM service communication, if + // Enable need for authentication codes for VM service communication, if // specified. + // TODO(bkonyi): when authentication codes are enabled by default, change + // to 'DisableServiceAuthCodes' and un-negate. settings.disable_service_auth_codes = !command_line.HasOption(FlagForSwitch(Switch::EnableServiceAuthCodes)); From 3be42f42e3c756708fb97c9f5430aed582290e99 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 10 Apr 2019 14:24:22 -0700 Subject: [PATCH 8/8] Update FlutterActivityDelegate.java --- .../android/io/flutter/app/FlutterActivityDelegate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java index 3f971c0d61fbc..467bfdbce240b 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -297,8 +297,8 @@ private static String[] getArgsFromIntent(Intent intent) { if (intent.getBooleanExtra("start-paused", false)) { args.add("--start-paused"); } - if (intent.getBooleanExtra("disable-service-auth-codes", false)) { - args.add("--disable-service-auth-codes"); + if (intent.getBooleanExtra("enable-service-auth-codes", false)) { + args.add("--enable-service-auth-codes"); } if (intent.getBooleanExtra("use-test-fonts", false)) { args.add("--use-test-fonts");