-
-
Notifications
You must be signed in to change notification settings - Fork 592
Added fuzzer to be run with OSS-Fuzz #772
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
c269839
Added fuzzer to be run with OSS-Fuzz
DavidKorczynski d532f39
Fix up syntax
DavidKorczynski 9cd96a5
Removed os import
DavidKorczynski 260ca52
fuzzer: fix remaining style CI complaints
DavidKorczynski 5af7e48
Add CI-fuzz to ensure fuzzers are run.
DavidKorczynski cd5b770
Set CI fuzz to be 30 seconds.
DavidKorczynski 708d518
set continue on error in fuzzing CI job.
DavidKorczynski f62a9ae
Move continue-on-error to build step.
DavidKorczynski 87a37b3
Try adding an success statement in CI
DavidKorczynski 57777da
switch to checking steps output.
DavidKorczynski a1a0295
Add suggestions from Zac
DavidKorczynski 94e0f72
Make fuzzer friendly for pytest.
DavidKorczynski 2e6d699
Merge branch 'main' into DavidKorczynski/main
Julian 926f607
Minor style fixes.
Julian a5d05fe
Move the fuzz workflow to fuzz.yml.
Julian f6f3441
Add language, remove dry-run: false which is the default.
Julian aae07ed
Module docstring
Julian baf3b37
Go back to fuzz_* naming.
Julian 2fdf475
Ignore the fuzz module from coverage for now as well.
Julian d9b5ca8
Extra newline.
Julian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CIFuzz | ||
on: [pull_request] | ||
jobs: | ||
Fuzzing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Fuzzers | ||
id: build | ||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master | ||
with: | ||
oss-fuzz-project-name: 'jsonschema' | ||
dry-run: false | ||
continue-on-error: true | ||
- name: Run Fuzzers | ||
if: steps.build.outcome == 'success' | ||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master | ||
with: | ||
oss-fuzz-project-name: 'jsonschema' | ||
fuzz-seconds: 30 | ||
dry-run: false | ||
- name: Upload Crash | ||
uses: actions/upload-artifact@v1 | ||
if: failure() && steps.build.outcome == 'success' | ||
with: | ||
name: artifacts | ||
path: ./out/artifacts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
|
||
from hypothesis import given | ||
from hypothesis import strategies as st | ||
import atheris | ||
|
||
import jsonschema | ||
|
||
PRIM = st.one_of( | ||
st.booleans(), | ||
st.integers(min_value=-(2 ** 63), max_value=2 ** 63 - 1), | ||
st.floats(allow_nan=False, allow_infinity=False), | ||
st.text(), | ||
) | ||
DICT = st.recursive( | ||
base=st.dictionaries(st.text(), PRIM), | ||
DavidKorczynski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
extend=lambda inner: st.dictionaries(st.text(), inner), | ||
) | ||
|
||
|
||
@given(obj1=DICT, obj2=DICT) | ||
def test_schemas(obj1, obj2): | ||
try: | ||
jsonschema.validate(instance=obj1, schema=obj2) | ||
except jsonschema.exceptions.ValidationError: | ||
None | ||
except jsonschema.exceptions.SchemaError: | ||
None | ||
|
||
|
||
def main(): | ||
atheris.Setup(sys.argv, | ||
test_schemas.hypothesis.fuzz_one_input, | ||
enable_python_coverage=True) | ||
atheris.Fuzz() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.