Skip to content

Commit

Permalink
build: Add daily fuzzing
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <[email protected]>
  • Loading branch information
Stranger6667 committed Sep 16, 2024
1 parent 5210aa6 commit d8eb69d
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: ["compile"]
target: ["compile", "validation"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand All @@ -206,4 +206,4 @@ jobs:

- run: cargo install cargo-fuzz

- run: cargo +nightly fuzz run --release ${{ matrix.target }} fuzz/seeds/${{ matrix.target }} -- -dict=fuzz/dict -max_total_time=60
- run: cargo +nightly fuzz run --release ${{ matrix.target }} fuzz/seeds -- -dict=fuzz/dict -max_total_time=60
2 changes: 1 addition & 1 deletion .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: ["compile"]
target: ["compile", "validation"]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ default:
@just --list

fuzz TARGET:
cargo +nightly fuzz run --release {{TARGET}} fuzz/corpus/{{TARGET}} fuzz/seeds/{{TARGET}} -- -dict=fuzz/dict
mkdir -p fuzz/corpus/{{TARGET}}
cargo +nightly fuzz run --release {{TARGET}} fuzz/corpus/{{TARGET}} fuzz/seeds -- -dict=fuzz/dict

lint-rs:
cargo +nightly fmt --all
Expand Down
7 changes: 7 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ path = "fuzz_targets/compile.rs"
test = false
doc = false
bench = false

[[bin]]
name = "validation"
path = "fuzz_targets/validation.rs"
test = false
doc = false
bench = false
21 changes: 21 additions & 0 deletions fuzz/fuzz_targets/validation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![no_main]
use jsonschema::BasicOutput;
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: (&[u8], &[u8])| {
let (schema, instance) = data;
if let Ok(schema) = serde_json::from_slice(schema) {
if let Ok(compiled) = jsonschema::compile(&schema) {
if let Ok(instance) = serde_json::from_slice(instance) {
let _ = compiled.is_valid(&instance);
if let Err(errors) = compiled.validate(&instance) {
for error in errors {
let _ = error.to_string();
}
}
let output: BasicOutput = compiled.apply(&instance).basic();
let _ = serde_json::to_value(output).expect("Failed to serialize");
}
}
}
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d8eb69d

Please sign in to comment.