Ejemplo n.º 1
0
def get_latest_cov_report_info(project_name):
    """Gets latest coverage report info for a specific OSS-Fuzz project from GCS.

  Args:
    project_name: The name of the relevant OSS-Fuzz project.

  Returns:
    The projects coverage report info in json dict or None on failure.
  """
    latest_report_info_url = fuzz_target.url_join(fuzz_target.GCS_BASE_URL,
                                                  LATEST_REPORT_INFO_PATH,
                                                  project_name + '.json')
    latest_cov_info_json = get_json_from_url(latest_report_info_url)
    if not latest_cov_info_json:
        logging.error('Could not get the coverage report json from url: %s.',
                      latest_report_info_url)
        return None
    return latest_cov_info_json
Ejemplo n.º 2
0
def get_target_coverage_report(latest_cov_info, target_name):
    """Get the coverage report for a specific fuzz target.

  Args:
    latest_cov_info: A dict containing a project's latest cov report info.
    target_name: The name of the fuzz target whose coverage is requested.

  Returns:
    The targets coverage json dict or None on failure.
  """
    if 'fuzzer_stats_dir' not in latest_cov_info:
        logging.error('The latest coverage report information did not contain'
                      '\'fuzzer_stats_dir\' key.')
        return None
    fuzzer_report_url_segment = latest_cov_info['fuzzer_stats_dir']

    # Converting gs:// to http://
    fuzzer_report_url_segment = fuzzer_report_url_segment.replace('gs://', '')
    target_url = fuzz_target.url_join(fuzz_target.GCS_BASE_URL,
                                      fuzzer_report_url_segment,
                                      target_name + '.json')
    return get_json_from_url(target_url)