Skip to content

Commit c168c88

Browse files
Revert "[rearch][fuzz_task] Get data bundle directory in safe way. (#… (#4205)
…4202)" This reverts commit 970c2ce. Causign error `Failed to sync data bundle media.`
1 parent 069cad0 commit c168c88

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/clusterfuzz/_internal/bot/tasks/setup.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ def _prepare_update_data_bundle(fuzzer, data_bundle):
467467
return data_bundle_directory
468468

469469

470-
def _update_data_bundle(
470+
def update_data_bundle(
471471
fuzzer: data_types.Fuzzer,
472-
data_bundle_corpus: uworker_msg_pb2.DataBundleCorpus) -> Optional[str]: # pylint: disable=no-member
472+
data_bundle_corpus: uworker_msg_pb2.DataBundleCorpus) -> bool: # pylint: disable=no-member
473473
"""Updates a data bundle to the latest version."""
474474
data_bundle = uworker_io.entity_from_protobuf(data_bundle_corpus.data_bundle,
475475
data_types.DataBundle)
@@ -656,7 +656,7 @@ def _set_up_data_bundles(update_input: uworker_msg_pb2.SetupInput): # pylint: d
656656
fuzzer = uworker_io.entity_from_protobuf(update_input.fuzzer,
657657
data_types.Fuzzer)
658658
for data_bundle_corpus in update_input.data_bundle_corpuses:
659-
if not _update_data_bundle(fuzzer, data_bundle_corpus):
659+
if not update_data_bundle(fuzzer, data_bundle_corpus):
660660
return False
661661

662662
return True
@@ -744,6 +744,16 @@ def _is_data_bundle_up_to_date(data_bundle, data_bundle_directory):
744744
return False
745745

746746

747+
def trusted_get_data_bundle_directory(fuzzer):
748+
"""For fuzz_task which doesn't get data bundles in an untrusted manner."""
749+
# TODO(metzman): Delete this when fuzz_task is migrated.
750+
# Check if we have a fuzzer-specific data bundle. Use it to calculate the
751+
# data directory we will fetch our testcases from.
752+
data_bundle = data_types.DataBundle.query(
753+
data_types.DataBundle.name == fuzzer.data_bundle_name).get()
754+
return get_data_bundle_directory(fuzzer, data_bundle)
755+
756+
747757
def get_data_bundle_directory(fuzzer, data_bundle):
748758
"""Return data bundle data directory."""
749759
# Store corpora for built-in fuzzers like libFuzzer in the same directory

src/clusterfuzz/_internal/bot/tasks/utasks/fuzz_task.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1782,9 +1782,7 @@ def run(self):
17821782

17831783
# Data bundle directories can also have testcases which are kept in-place
17841784
# because of dependencies.
1785-
self.data_directory = setup.get_data_bundle_directory(
1786-
self.fuzzer, self.uworker_input.setup_input.data_bundle_corpuses)
1787-
1785+
self.data_directory = setup.trusted_get_data_bundle_directory(self.fuzzer)
17881786
if not self.data_directory:
17891787
logs.error(
17901788
'Unable to setup data bundle %s.' % self.fuzzer.data_bundle_name)

src/clusterfuzz/_internal/tests/core/bot/tasks/setup_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def setUp(self):
214214
'clusterfuzz._internal.bot.tasks.task_types.is_remote_utask',
215215
'clusterfuzz._internal.bot.tasks.setup._update_fuzzer',
216216
'clusterfuzz._internal.bot.tasks.setup._clear_old_data_bundles_if_needed',
217-
'clusterfuzz._internal.bot.tasks.setup._update_data_bundle',
217+
'clusterfuzz._internal.bot.tasks.setup.update_data_bundle',
218218
])
219219
self.mock.get_signed_upload_url.return_value = 'https://fake/upload'
220220
self.mock.get_signed_download_url.return_value = 'https://fake/download'
@@ -234,4 +234,4 @@ def test_data_bundles(self):
234234
setup_input = setup.preprocess_update_fuzzer_and_data_bundles(
235235
self.fuzzer_name)
236236
setup.update_fuzzer_and_data_bundles(setup_input)
237-
self.assertEqual(self.mock._update_data_bundle.call_count, 2)
237+
self.assertEqual(self.mock.update_data_bundle.call_count, 2)

src/clusterfuzz/_internal/tests/core/bot/untrusted_runner/untrusted_runner_integration_test.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
from clusterfuzz._internal.system import shell
4242
from clusterfuzz._internal.tests.test_libs import untrusted_runner_helpers
4343

44-
# pylint: disable=protected-access
45-
4644
TEST_FILE_CONTENTS = (b'A' * config.FILE_TRANSFER_CHUNK_SIZE +
4745
b'B' * config.FILE_TRANSFER_CHUNK_SIZE +
4846
b'C' * (config.FILE_TRANSFER_CHUNK_SIZE // 2))
@@ -515,7 +513,7 @@ def test_symbolize(self):
515513
self.assertEqual(expected_symbolized_stacktrace, symbolized_stacktrace)
516514

517515
def test_update_data_bundle(self):
518-
"""Test _update_data_bundle."""
516+
"""Test update_data_bundle."""
519517
self.mock.get_data_bundle_bucket_name.return_value = TEST_BUNDLE_BUCKET
520518

521519
# Get a blobstore key for the fuzzer.
@@ -538,15 +536,15 @@ def test_update_data_bundle(self):
538536
data_bundle_corpus.data_bundle.CopyFrom(
539537
uworker_io.entity_to_protobuf(bundle))
540538
self.assertTrue(
541-
setup._update_data_bundle(returned_fuzzer, data_bundle_corpus))
539+
setup.update_data_bundle(returned_fuzzer, data_bundle_corpus))
542540

543541
data_bundle_directory = file_host.rebase_to_worker_root(
544542
setup.get_data_bundle_directory(returned_fuzzer, bundle))
545543
self.assertTrue(os.path.exists(os.path.join(data_bundle_directory, 'a')))
546544
self.assertTrue(os.path.exists(os.path.join(data_bundle_directory, 'b')))
547545

548546
self.assertTrue(
549-
setup._update_data_bundle(returned_fuzzer, data_bundle_corpus))
547+
setup.update_data_bundle(returned_fuzzer, data_bundle_corpus))
550548

551549
def test_get_fuzz_targets(self):
552550
"""Test get_fuzz_targets."""

0 commit comments

Comments
 (0)