Skip to content

[Tracing] Emiting TestcaseRejectionEvent during corpus pruning #4848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,11 @@ def _process_corpus_crashes(output: uworker_msg_pb2.Output): # pylint: disable=
fuzz_target=fuzz_target.project_qualified_name())
if existing_testcase:
logs.info('_process_corpus_crashes figured out crash already exists.')
events.emit(
events.TestcaseRejectionEvent(
testcase=existing_testcase,
rejection_reason=events.RejectionReason.CORPUS_PRUNING_DUPLICATE
))
continue

unit_name = os.path.basename(crash.unit_path)
Expand Down
1 change: 1 addition & 0 deletions src/clusterfuzz/_internal/metrics/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class RejectionReason:
"""Explanation for the testcase rejection values."""
ANALYZE_NO_REPRO = 'analyze_no_repro'
ANALYZE_FLAKE_ON_FIRST_ATTEMPT = 'analyze_flake_on_first_attempt'
CORPUS_PRUNING_DUPLICATE = 'corpus_pruning_duplicate'


@dataclass(kw_only=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,28 @@ def test_prune(self):

self.assertEqual(self.mock.unpack_seed_corpus_if_needed.call_count, 1)

def test_rejection_event_duplicate(self):
"""Test that a duplicate crash results in a rejection event."""
existing_testcase = test_utils.create_generic_testcase()

helpers.patch(self, [
'clusterfuzz._internal.datastore.data_handler.find_testcase',
])
self.mock.find_testcase.return_value = existing_testcase

uworker_input = corpus_pruning_task.utask_preprocess(
job_type='libfuzzer_asan_job',
fuzzer_name='libFuzzer_test_fuzzer',
uworker_env={})
output = corpus_pruning_task.utask_main(uworker_input)
output.uworker_input.CopyFrom(uworker_input)
corpus_pruning_task.utask_postprocess(output)

self.mock.emit.assert_called_once_with(
events.TestcaseRejectionEvent(
testcase=existing_testcase,
rejection_reason=events.RejectionReason.CORPUS_PRUNING_DUPLICATE))

def test_get_libfuzzer_flags(self):
"""Test get_libfuzzer_flags logic."""
fuzz_target = data_handler.get_fuzz_target('libFuzzer_test_fuzzer')
Expand Down
Loading