Skip to content
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

Consolidate all fuzz test info (corpus, dictionaries, etc.) in one rule. #94

Merged
merged 5 commits into from
Dec 16, 2020

Conversation

stefanbucur
Copy link
Collaborator

@stefanbucur stefanbucur commented Dec 13, 2020

This is an internal refactoring that largely has no effect on the interface of the cc_fuzz_test macro.

The new fuzzing_binary rule supersedes the instrumented_fuzzing_binary rule. In addition to providing binary instrumentation, it collects all the other metadata about the fuzz test, such as corpus and dictionary paths, and the info about the fuzzing engine used, and makes it available to consumers via the new CcFuzzingBinaryInfo provider. This simplifies the creation of additional rules that depend on fuzz test binaries, such as the upcoming OSS-Fuzz packaging rule.

There is one major change in behavior for cc_fuzz_test: it now always builds the corpus and dictionary dependencies as part of building the main fuzzing binary. This is advantageous, but at the same time it invalidates an existing "compilation failure" test which was run manually. The test is disabled for the time being - I opened #95 to track this issue.

# Building and runing empty_fuzz_test_with_invalid_dict should be ok,
# but building and running empty_fuzz_test_with_invalid_dict_run are expected to get an error message
# due to the invalid dictionary.
cc_fuzz_test(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still being used or does it still make sense to have it around (e.g., for testing)? Mostly asking since the PR description sounded like this was mostly going to be a refactoring

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great point - this was intended to be a refactoring, but it does indeed slightly change the semantics of the cc_fuzz_test rule: while the rule output stays the same, there are now more targets in the macro that are built by default. This test was assuming one of these targets (the dictionary) would not be built by default, so someone could manually check that this fuzz test would fail.

But since these manual "compilation failure" tests are rather brittle and less useful, I opted to remove this one for the time being.

I opened #95 to track the addition of a proper regression test.

Copy link

@markus-kusano markus-kusano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only nits

},
)

def _fuzzing_binary_transition_impl(settings, attr):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is attr ever used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not for this particular transition, but this is part of the standard signature required by the implementation attribute of the transition() definition below. (It's a bit like argc and argv in a main function.)

Base automatically changed from remove-corpus-zip-pkg to master December 16, 2020 05:40
The new rule supersedes the instrumented_fuzzing_binary rule and gets to incorporate all the other metadata about the fuzz test, such as corpus and dictionary paths, and the info about the fuzzing engine used. This simplifies the creation of additional rules that depend on fuzz test binaries, which can retrieve this metadata from the new CcFuzzingBinaryInfo provider.
@stefanbucur stefanbucur force-pushed the fuzzing-binary-rule-consolidation branch from c34d0de to a86b11d Compare December 16, 2020 05:43
@stefanbucur stefanbucur merged commit 6ddf1e5 into master Dec 16, 2020
@stefanbucur stefanbucur deleted the fuzzing-binary-rule-consolidation branch December 16, 2020 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants