Пример #1
0
def filter_binary_path(binary_path):
  """Filter binary path to provide local copy."""
  # LKL fuzzer name is not full path.
  if environment.is_android():
    # Skip symbolization when running it on bad entries like [stack:XYZ].
    if not binary_path.startswith('/') or '(deleted)' in binary_path:
      return ''

  # Initialize some helper variables.
  build_directory = environment.get_value('BUILD_DIR')

  # Try to find the library in the build directory first.
  local_binary_path = utils.find_binary_path(build_directory, binary_path)
  if local_binary_path:
    return local_binary_path

  # We should only download from the build server if we are Android.
  if environment.is_android():
    local_binary_path = _get_binary_from_build_or_device(binary_path)
    if local_binary_path:
      return local_binary_path

  # Unable to find library.
  logs.log_error('Unable to find library %s for symbolization.' % binary_path)
  return ''
Пример #2
0
def _get_repo_prop_data(build_id, fuzz_target):
  """Downloads repo.prop and returuns the data based on build_id and target."""
  symbols_directory = os.path.join(
      environment.get_value('SYMBOLS_DIR'), fuzz_target)
  repro_filename = symbols_downloader.get_repo_prop_archive_filename(
      build_id, fuzz_target)

  # Grab repo.prop, it is not on the device nor in the build_dir.
  _download_kernel_repo_prop_if_needed(symbols_directory, build_id, fuzz_target)
  local_repo_path = utils.find_binary_path(symbols_directory, repro_filename)
  if local_repo_path and os.path.exists(local_repo_path):
    return utils.read_data_from_file(local_repo_path, eval_data=False).decode()

  return None
Пример #3
0
def _get_binary_from_build_or_device(binary_path):
  """Look for binary on build server or on device."""
  # Initialize some helper variables.
  symbols_directory = environment.get_value('SYMBOLS_DIR')
  binary_filename = os.path.basename(binary_path)

  # We didn't find the library locally in the build directory.
  # Try finding the library in the local system library cache.
  download_system_symbols_if_needed(symbols_directory)
  local_binary_path = utils.find_binary_path(symbols_directory, binary_path)
  if local_binary_path:
    return local_binary_path

  # Try pulling in the binary directly from the device into the
  # system library cache directory.
  local_binary_path = os.path.join(symbols_directory, binary_filename)
  adb.run_command('pull %s %s' % (binary_path, local_binary_path))
  if os.path.exists(local_binary_path):
    return local_binary_path

  return None