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
def get_seed_corpus_path(fuzz_target_path): """Returns the path of the seed corpus if one exists. Otherwise returns None. Logs an error if multiple seed corpora exist for the same target.""" archive_path_without_extension = fuzzer_utils.get_supporting_file( fuzz_target_path, SEED_CORPUS_ARCHIVE_SUFFIX) # Get all files that end with _seed_corpus.* possible_archive_paths = set(glob.glob(archive_path_without_extension + '.*')) # Now get a list of these that are valid seed corpus archives. archive_paths = possible_archive_paths.intersection( set(archive_path_without_extension + extension for extension in archive.ARCHIVE_FILE_EXTENSIONS)) archive_paths = list(archive_paths) if not archive_paths: return None if len(archive_paths) > 1: logs.log_error('Multiple seed corpuses exist for fuzz target %s: %s.' % (fuzz_target_path, ', '.join(archive_paths))) return archive_paths[0]
def get_default_dictionary_path(fuzz_target_path): """Return default dictionary path.""" return fuzzer_utils.get_supporting_file(fuzz_target_path, DICTIONARY_FILE_EXTENSION)