def _get_fuzz_targets_from_archive(archive_path): """Get iterator of fuzz targets from archive path.""" # Import here as this path is not available in App Engine context. from bot.fuzzers import utils as fuzzer_utils for archive_file in archive.iterator(archive_path): if fuzzer_utils.is_fuzz_target_local(archive_file.name, archive_file.handle): fuzz_target = os.path.splitext(os.path.basename(archive_file.name))[0] yield fuzz_target
def test_fuzzer_py(self): path = self._create_file('abc_fuzzer.par', contents=b'anything') self.assertTrue(utils.is_fuzz_target_local(path))
def test_not_a_fuzzer_with_extension_and_suffix(self): path = self._create_file('abc_fuzzer.dict', contents=b'LLVMFuzzerTestOneInput') self.assertFalse(utils.is_fuzz_target_local(path))
def test_not_a_fuzzer_without_extension(self): path = self._create_file('abc', contents=b'anything') self.assertFalse(utils.is_fuzz_target_local(path))
def test_not_a_fuzzer_blocklisted_name(self): path = self._create_file('jazzer_driver', contents=b'LLVMFuzzerTestOneInput') self.assertFalse(utils.is_fuzz_target_local(path))
def test_not_a_fuzzer_invalid_name(self): path = self._create_file('abc$_fuzzer', contents=b'LLVMFuzzerTestOneInput') self.assertFalse(utils.is_fuzz_target_local(path))
def test_fuzzer_posix(self): self.fs.create_file('/abc_fuzzer', contents='anything') self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer'))
def test_fuzzer_without_file_string_and_without_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') path = self._create_file('nomatch', contents=b'anything') self.assertFalse(utils.is_fuzz_target_local(path))
def test_fuzzer_with_file_string_and_without_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') self.fs.CreateFile('/nomatch', contents='anything\nLLVMFuzzerTestOneInput') self.assertFalse(utils.is_fuzz_target_local('/nomatch'))
def test_fuzzer_with_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') self.fs.CreateFile('/a_custom', contents='anything') self.assertTrue(utils.is_fuzz_target_local('/a_custom'))
def test_fuzzer_without_suffix(self): self.fs.CreateFile('/abc', contents='anything\nLLVMFuzzerTestOneInput') self.assertTrue(utils.is_fuzz_target_local('/abc'))
def test_fuzzer_win(self): self.fs.CreateFile('/abc_fuzzer.exe', contents='anything') self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer.exe'))
def test_not_a_fuzzer_with_extension_and_suffix(self): self.fs.CreateFile('/abc_fuzzer.dict', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc_fuzzer.dict'))
def test_not_a_fuzzer_without_extension(self): self.fs.CreateFile('/abc', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc'))
def test_not_a_fuzzer_invalid_name(self): self.fs.CreateFile('/abc$_fuzzer', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc$_fuzzer'))
def test_fuzzer_not_exist(self): self.assertFalse(utils.is_fuzz_target_local('/not_exist_fuzzer'))
def test_fuzzer_without_suffix(self): path = self._create_file('abc', contents=b'anything\nLLVMFuzzerTestOneInput') self.assertTrue(utils.is_fuzz_target_local(path))
def test_fuzzer_with_fuzzer_name_and_without_name_regex_match(self): environment.set_value('FUZZER_NAME_REGEX', '.*_custom$') path = self._create_file('a_fuzzer', contents=b'anything\nLLVMFuzzerTestOneInput') self.assertTrue(utils.is_fuzz_target_local(path))
def test_file_handle(self): """Test with a file handle.""" path = self._create_file('abc', contents=b'anything\nLLVMFuzzerTestOneInput') with open(path, 'rb') as f: self.assertTrue(utils.is_fuzz_target_local('name', f))
def test_not_a_fuzzer_with_extension(self): self.fs.create_file('/abc.dict', contents='anything') self.assertFalse(utils.is_fuzz_target_local('/abc.dict'))