-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
Fuzz Tests Are Crashing at Start-up on ClusterFuzz #1905
Comments
DaveLak
added a commit
to DaveLak/GitPython
that referenced
this issue
Apr 22, 2024
A Git executable is not globally available in the ClusterFuzz container environment where OSS-Fuzz executes fuzz tests, causing an error in the fuzz harnesses when GitPython attempts to initialize, crashing the tests before they can run. To avoid this issue, we bundle the `git` binary that is available in the OSS-Fuzz build container with the fuzz harness via Pyinstaller's `--add-binary` flag in `build.sh` and use GitPython's `git.refresh(<full-path-to-git-executable>)` method inside a Pyinstaller runtime check to initialize GitPython with the bundled Git executable when running from the bundled application. In all other execution environments, we assume a `git` executable is available globally. Fixes: - gitpython-developers#1905 - google/oss-fuzz#10600
Thanks for reporting! This should be fixed by #1906 . |
DaveLak
added a commit
to DaveLak/GitPython
that referenced
this issue
Apr 26, 2024
This is a second attempt at gitpython-developers#1906 and should resolve: - gitpython-developers#1905 - google/oss-fuzz#10600 PR gitpython-developers#1906 had the right idea but wrong implementation, and the differences between the ClusterFuzz image that it was supposed to fix and the OSS-Fuzz image where the fix was tested led to the issue not being fully resolved. The root cause of the issue is the same: A Git executable is not globally available in the ClusterFuzz container environment where OSS-Fuzz executes fuzz tests. gitpython-developers#1906 attempted to fix the issue by bundling the Git binary and using GitPython's `git.refresh(<full-path-to-git-executable>)` method to set it inside the `TestOneInput` function of the test harness. However, GitPython attempts to set the binary at import time via its `__init__` hook, and crashes the test if no executable is found during the import. This issue is fixed here by setting the environment variable that GitPython looks in before importing it, so it's available for the import. This was tested by setting the `$PATH` to an empty string inside the test files, which reproduced the crash, then adding the changes introduced here with `$PATH` still empty, which avoided the crash indicating that the bundled Git executable is working as expected.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PR #1901 was successful in fixing the broken build but resurfaced another issue that is preventing the fuzzer from running.
The Problem
It appears that a Git executable is not available in the ClusterFuzz container environment where fuzz tests are executed, causing an error in the fuzz harnesses when GitPython attempts to initialize.
This issue has been previously seen and reported on the OSS-Fuzz issue tracker: google/oss-fuzz#10600
Relevant Portion of the ClusterFuzz Crash Logs from 2024-04-20
Possible Solution
OSS-Fuzz uses Pyinstaller to bundle fuzz harnesses and their dependencies in the
compile_python_fuzzers
function called bybuild.sh
. Arguments passed tocompile_python_fuzzers
after the fuzz harness are forwarded to Pyinstaller, which accepts an--add-binary
flag to add arbitrary binaries to the bundle and are made available to the bundled program at runtime.We should be able to:
Download a pre built Git binary from kernal.org in theNever mind, the downloadable archives are source, not builds.container-environment-bootstrap.sh
script.git
available in the OSS-Fuzz build container with the fuzz harness inbuild.sh
git.refresh(<full-path-to-git-executable>)
method inside a Pyintaller runtime check to initialize GitPython with the bundled Git executable when running from the bundled application.Next Steps
I'll test out the possible solution described above and open a PR if it works as expected.Done in Fix Fuzzer Crash in ClusterFuzz Due to Missing Git Executable #1906If it doesn't work, I'll document the outcome in this issue.The text was updated successfully, but these errors were encountered: