From c5416c52ce8f3130605791a28a63109ba60e1a0b Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Thu, 29 Jan 2015 12:59:48 -0800 Subject: [PATCH] Replace usage of md5 with sha256 for generation of mojo app ids. Before we start adding more uses of mojo app ids we should use to a non-broken hash function. :) What was holding me back before was I wasn't aware of us having an incremental hash api other than base/md5.h (others in base only operate on the full input data), however it turns out that the crypto/ library has one in crypto/secure_hash.h. R=abarth@chromium.org BUG= Review URL: https://codereview.chromium.org/868253006 --- engine/src/flutter/tools/mojo_cache_linker.py | 11 +++++++++-- engine/src/flutter/tools/skydb | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/tools/mojo_cache_linker.py b/engine/src/flutter/tools/mojo_cache_linker.py index 10685af6fa..d848ecdf84 100755 --- a/engine/src/flutter/tools/mojo_cache_linker.py +++ b/engine/src/flutter/tools/mojo_cache_linker.py @@ -44,10 +44,10 @@ def compute_path_to_app_id_map(paths, cache, cache_mtime): for path in paths: app_id = get_cached_app_id(path, cache, cache_mtime) if not app_id: - logging.info('md5sum %s' % path) + logging.info('sha256sum %s' % path) # Example output: # f82a3551478a9a0e010adccd675053b9 png_viewer.mojo - output = subprocess.check_output(['md5sum', path]) + output = subprocess.check_output(['sha256sum', path]) app_id = output.strip().split()[0] path_to_app_id_map[path] = app_id return path_to_app_id_map @@ -78,8 +78,13 @@ def main(): ' to match expected dlopen names from mojo_shell\'s NetworkLoader.') parser.add_argument('links_dir', type=str) parser.add_argument('build_dir', type=str) + parser.add_argument('-f', '--force', action='store_true') + parser.add_argument('-v', '--verbose', action='store_true') args = parser.parse_args() + if args.verbose: + logging.getLogger().setLevel(logging.INFO) + if not os.path.isdir(args.links_dir): logging.fatal('links_dir: %s is not a directory' % args.links_dir) sys.exit(1) @@ -87,6 +92,8 @@ def main(): # Some of the .so files are 100s of megabytes. Cache the md5s to save time. cache_path = os.path.join(args.build_dir, '.app_id_cache') cache, cache_mtime = read_app_id_cache(cache_path) + if args.force: + cache_mtime = None paths = library_paths(args.build_dir) path_to_app_id_map = compute_path_to_app_id_map(list(paths), diff --git a/engine/src/flutter/tools/skydb b/engine/src/flutter/tools/skydb index 627b99e115..4c22df7252 100755 --- a/engine/src/flutter/tools/skydb +++ b/engine/src/flutter/tools/skydb @@ -194,6 +194,8 @@ class SkyDebugger(object): self.pids['sky_command_port'] = args.command_port if is_android: + subprocess.check_call([ADB_PATH, 'root']) + # We could make installing conditional on an argument. apk_path = os.path.join(self.paths.build_dir, 'apks', ANDROID_APK_NAME)