Пример #1
0
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
Пример #2
0
 def test_fuzzer_py(self):
     path = self._create_file('abc_fuzzer.par', contents=b'anything')
     self.assertTrue(utils.is_fuzz_target_local(path))
Пример #3
0
 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))
Пример #4
0
 def test_not_a_fuzzer_without_extension(self):
     path = self._create_file('abc', contents=b'anything')
     self.assertFalse(utils.is_fuzz_target_local(path))
Пример #5
0
 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))
Пример #6
0
 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))
Пример #7
0
 def test_fuzzer_posix(self):
     self.fs.create_file('/abc_fuzzer', contents='anything')
     self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer'))
Пример #8
0
 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))
Пример #9
0
 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'))
Пример #10
0
 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'))
Пример #11
0
 def test_fuzzer_without_suffix(self):
   self.fs.CreateFile('/abc', contents='anything\nLLVMFuzzerTestOneInput')
   self.assertTrue(utils.is_fuzz_target_local('/abc'))
Пример #12
0
 def test_fuzzer_win(self):
   self.fs.CreateFile('/abc_fuzzer.exe', contents='anything')
   self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer.exe'))
Пример #13
0
 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'))
Пример #14
0
 def test_not_a_fuzzer_without_extension(self):
   self.fs.CreateFile('/abc', contents='anything')
   self.assertFalse(utils.is_fuzz_target_local('/abc'))
Пример #15
0
 def test_not_a_fuzzer_invalid_name(self):
   self.fs.CreateFile('/abc$_fuzzer', contents='anything')
   self.assertFalse(utils.is_fuzz_target_local('/abc$_fuzzer'))
Пример #16
0
 def test_fuzzer_not_exist(self):
     self.assertFalse(utils.is_fuzz_target_local('/not_exist_fuzzer'))
Пример #17
0
 def test_fuzzer_without_suffix(self):
     path = self._create_file('abc',
                              contents=b'anything\nLLVMFuzzerTestOneInput')
     self.assertTrue(utils.is_fuzz_target_local(path))
Пример #18
0
 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))
Пример #19
0
 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))
Пример #20
0
 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'))