コード例 #1
0
def get_issue_metadata(fuzz_target_path, extension):
  """Get issue metadata."""
  metadata_file_path = fuzzer_utils.get_supporting_file(fuzz_target_path,
                                                        extension)

  if environment.is_trusted_host():
    metadata_file_path = fuzzer_utils.get_file_from_untrusted_worker(
        metadata_file_path)

  if not os.path.exists(metadata_file_path):
    return []

  with open(metadata_file_path) as handle:
    return utils.parse_delimited(
        handle, delimiter='\n', strip=True, remove_empty=True)
コード例 #2
0
ファイル: engine_common.py プロジェクト: zzdxxd/clusterfuzz
def get_issue_labels(fuzz_target_path):
  """Return list of issue labels given a fuzz target path."""
  labels_file_path = fuzzer_utils.get_supporting_file(fuzz_target_path,
                                                      LABELS_FILE_EXTENSION)

  if environment.is_trusted_host():
    labels_file_path = fuzzer_utils.get_file_from_untrusted_worker(
        labels_file_path)

  if not os.path.exists(labels_file_path):
    return []

  with open(labels_file_path) as handle:
    return utils.parse_delimited(
        handle, delimiter='\n', strip=True, remove_empty=True)
コード例 #3
0
ファイル: options.py プロジェクト: sauravsrijan/clusterfuzz
def get_fuzz_target_options(fuzz_target_path):
    """Return a FuzzerOptions for the given target, or None if it does not
  exist."""
    options_file_path = fuzzer_utils.get_supporting_file(
        fuzz_target_path, OPTIONS_FILE_EXTENSION)
    options_cwd = os.path.dirname(options_file_path)

    if environment.is_trusted_host():
        options_file_path = fuzzer_utils.get_file_from_untrusted_worker(
            options_file_path)

    if not os.path.exists(options_file_path):
        return None

    try:
        return FuzzerOptions(options_file_path, cwd=options_cwd)
    except FuzzerOptionsException:
        logs.log_error('Invalid options file: %s.' % options_file_path)
        return None
コード例 #4
0
ファイル: engine_common.py プロジェクト: rozekey/clusterfuzz
def get_additional_issue_metadata(fuzz_target_path):
  """Return the additional metadata fields given a fuzz target path. The data
  will be a JSON-formatted dictionary."""
  metadata_file_path = fuzzer_utils.get_supporting_file(
      fuzz_target_path, METADATA_FILE_EXTENSION)

  if environment.is_trusted_host():
    metadata_file_path = fuzzer_utils.get_file_from_untrusted_worker(
        metadata_file_path)

  if not os.path.exists(metadata_file_path):
    return {}

  with open(metadata_file_path) as handle:
    try:
      return json.load(handle)
    except (ValueError, TypeError):
      logs.log_error('Invalid metadata file format.', path=metadata_file_path)
      return {}
コード例 #5
0
def get_issue_owners(fuzz_target_path):
    """Return list of owner emails given a fuzz target path.

  Format of an owners file is described at:
  https://cs.chromium.org/chromium/src/third_party/depot_tools/owners.py
  """
    owners_file_path = fuzzer_utils.get_supporting_file(
        fuzz_target_path, OWNERS_FILE_EXTENSION)

    if environment.is_trusted_host():
        owners_file_path = fuzzer_utils.get_file_from_untrusted_worker(
            owners_file_path)

    if not os.path.exists(owners_file_path):
        return []

    owners = []
    with open(owners_file_path, 'r') as owners_file_handle:
        owners_file_content = owners_file_handle.read()

        for line in owners_file_content.splitlines():
            stripped_line = line.strip()
            if not stripped_line:
                # Ignore empty lines.
                continue
            if stripped_line.startswith('#'):
                # Ignore comment lines.
                continue
            if stripped_line == '*':
                # Not of any use, we can't add everyone as owner with this.
                continue
            if (stripped_line.startswith('per-file')
                    or stripped_line.startswith('file:')):
                # Don't have a source checkout, so ignore.
                continue
            if '@' not in stripped_line:
                # Bad email address.
                continue
            owners.append(stripped_line)

    return owners