Skip to content

Commit

Permalink
[cfl] Allow reporting of unreproducible crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmetzman committed Dec 8, 2021
1 parent 6563751 commit 2812159
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions infra/cifuzz/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def __init__(self):
if not os.getenv('CIFUZZ_TEST') and not self._run_config_validate():
raise ConfigError('Invalid Run Configuration.')

self.report_old_crashes = environment.get_bool('REPORT_OLD_CRASHES', False)

def _run_config_validate(self):
"""Do extra validation on RunFuzzersConfig.__init__(). Do not name this
validate or else it will be called when using the parent's __init__ and will
Expand Down
5 changes: 4 additions & 1 deletion infra/cifuzz/fuzz_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ def is_crash_reportable(self, testcase, reproduce_args, batch=False):
# We don't need to check if the crash is novel for batch fuzzing.
return True

return self.is_crash_novel(testcase, reproduce_args)
is_novel = self.is_crash_novel(testcase, reproduce_args)
if not is_novel:
return self.config.report_old_crashes
return True

def is_crash_type_reportable(self, testcase):
"""Returns True if |testcase| is an actual crash. If crash is a timeout or
Expand Down
18 changes: 18 additions & 0 deletions infra/cifuzz/fuzz_target_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,24 @@ def test_new_reproducible_crash(self, mock_info, _):
'The crash is not reproducible on previous build. '
'Code change (pr/commit) introduced crash.')

@mock.patch('fuzz_target.FuzzTarget.is_reproducible', return_value=True)
@mock.patch('fuzz_target.FuzzTarget.is_crash_novel', return_value=False)
def test_old_reproducible_crash(self, _, __):
"""Tests that an old reproducible crash returns False."""
with tempfile.TemporaryDirectory() as tmp_dir:
self.target.out_dir = tmp_dir
self.assertFalse(self.target.is_crash_reportable(self.testcase_path, []))

@mock.patch('fuzz_target.FuzzTarget.is_reproducible', return_value=True)
@mock.patch('fuzz_target.FuzzTarget.is_crash_novel', return_value=False)
def test_old_reproducible_crash_report_unreproducible(self, _, __):
"""Tests that an old reproducible crash returns True if config to report old
crashes is True."""
with tempfile.TemporaryDirectory() as tmp_dir:
self.target.out_dir = tmp_dir
self.target.config.report_old_crashes = True
self.assertTrue(self.target.is_crash_reportable(self.testcase_path, []))

# yapf: disable
@parameterized.parameterized.expand([
# Reproducible on PR build, but also reproducible on OSS-Fuzz.
Expand Down

0 comments on commit 2812159

Please sign in to comment.