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

Numpy getting included in coverage numbers when imported #1024

Open
sg3-141-592 opened this issue May 21, 2023 · 1 comment
Open

Numpy getting included in coverage numbers when imported #1024

sg3-141-592 opened this issue May 21, 2023 · 1 comment

Comments

@sg3-141-592
Copy link
Contributor

Where numpy is imported into a fuzz.py file it's getting included in the reachability and coverage numbers

image

A couple of examples

For toml I tried setting export PYFUZZPACKAGE=$SRC/toml/toml which fixed just analysing the toml functions but breaks the reachability analysis.

image
@sg3-141-592 sg3-141-592 changed the title Numpy getting included in coverage numbers Numpy getting included in coverage numbers when imported May 21, 2023
@DavidKorczynski
Copy link
Contributor

I think this is likely something we cannot resolve due to the way coverage is collected.

Probably, when import numpy is executed then various functions in the numpy module tree will be called, meaning numpy code other than def declarations will be called triggering the actual logic of the functions.

One way we could solve this is by making it such that code coverage collection begins only right before fuzzing launches, rather than, e.g. before all imports. However, this won't be perfect as well since we can still have imports triggered by the target code, although this will be done much more rarely.

Another option is to collect code coverage of the fuzzer but without any actual fuzzing and then subtract the code coverage found with a run of code coverage where the fuzzing is actually run. This way we could remove any code coverage gained from non-fuzzing code.

Another option is to make it possible for projects to add environment variables specifying which paths should be included in the code coverage reports.

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

No branches or pull requests

2 participants