Ejemplo n.º 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
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 7
0
 def test_fuzzer_posix(self):
     self.fs.create_file('/abc_fuzzer', contents='anything')
     self.assertTrue(utils.is_fuzz_target_local('/abc_fuzzer'))
Ejemplo n.º 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))
Ejemplo n.º 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'))
Ejemplo n.º 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'))
Ejemplo n.º 11
0
 def test_fuzzer_without_suffix(self):
   self.fs.CreateFile('/abc', contents='anything\nLLVMFuzzerTestOneInput')
   self.assertTrue(utils.is_fuzz_target_local('/abc'))
Ejemplo n.º 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'))
Ejemplo n.º 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'))
Ejemplo n.º 14
0
 def test_not_a_fuzzer_without_extension(self):
   self.fs.CreateFile('/abc', contents='anything')
   self.assertFalse(utils.is_fuzz_target_local('/abc'))
Ejemplo n.º 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'))
Ejemplo n.º 16
0
 def test_fuzzer_not_exist(self):
     self.assertFalse(utils.is_fuzz_target_local('/not_exist_fuzzer'))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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'))