forked from Diggsey/ijson
-
Notifications
You must be signed in to change notification settings - Fork 0
MOD-12261 add CI + fuzz tests #15
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
Open
AvivDavid23
wants to merge
21
commits into
master
Choose a base branch
from
MOD-12261-add-ci-test-for-ijeson-fazzer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d690d2a
initial fuzz target
AvivDavid23 2ae12e3
simple test + ci files
AvivDavid23 ab64488
test
AvivDavid23 dbbcc29
test
AvivDavid23 a65efd6
project structure
AvivDavid23 a91e221
project structure
AvivDavid23 5dade0d
project structure
AvivDavid23 123da85
fix
AvivDavid23 b215cf2
remove toolchain
AvivDavid23 71bbf38
ci
AvivDavid23 0669e74
ci
AvivDavid23 c6dabbd
ci
AvivDavid23 0a54aa6
fix
AvivDavid23 543065b
test
AvivDavid23 76e1adc
fix
AvivDavid23 e864539
fix
AvivDavid23 ad754fb
change to randomise json de
AvivDavid23 3981302
remove print
AvivDavid23 19b5378
fix strings
AvivDavid23 44b5a5b
remove print, again
AvivDavid23 b362ba7
fix
AvivDavid23 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,28 @@ | ||
| name: Build and Test | ||
| description: Run build and test steps for the project | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install Toolchain | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: "1.88" | ||
| components: rustfmt | ||
|
|
||
| - name: Cargo Format | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: fmt | ||
| args: -- --check | ||
|
|
||
| - name: Build | ||
| shell: bash | ||
| run: cargo build | ||
|
|
||
| - name: Test | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: test | ||
| args: -- --test-threads=1 | ||
|
|
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,30 @@ | ||
| name: Smoke-Test Fuzz Targets | ||
| description: Run fuzz tests on the project | ||
|
|
||
| inputs: | ||
| fuzz_target: | ||
| description: 'The fuzz target to run' | ||
| required: true | ||
| fuzz_time: | ||
| description: 'Maximum time in seconds to run fuzzing' | ||
| required: false | ||
| default: '180' | ||
| cargo_fuzz_version: | ||
| description: 'Version of cargo-fuzz to install' | ||
| required: false | ||
| default: '0.13.0' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install cargo-fuzz | ||
| uses: actions-rs/cargo@v1 | ||
| with: | ||
| command: install | ||
| args: cargo-fuzz --version ${{ inputs.cargo_fuzz_version }} | ||
AvivDavid23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Run Fuzz Tests | ||
| shell: bash | ||
| working-directory: fuzz | ||
| run: cargo fuzz run ${{ inputs.fuzz_target }} --release -- -max_total_time=${{ inputs.fuzz_time }} | ||
|
|
||
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,36 @@ | ||
| name: CI | ||
|
|
||
| on: [pull_request] | ||
AvivDavid23 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build_and_test: | ||
| name: Build and Test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run Build and Test | ||
| uses: ./.github/actions/build_and_test | ||
|
|
||
| fuzz_tests: | ||
| name: Fuzz Tests (${{ matrix.fuzz_target }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| fuzz_target: | ||
| - fuzz_json_de | ||
| # Add more fuzz targets here as needed | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run Fuzz Tests | ||
| uses: ./.github/actions/fuzz_tests | ||
| with: | ||
| fuzz_target: ${{ matrix.fuzz_target }} | ||
|
|
||
This file was deleted.
Oops, something went wrong.
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
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,4 @@ | ||
| target | ||
| corpus | ||
| artifacts | ||
| coverage |
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,24 @@ | ||
| [package] | ||
| name = "ijson-fuzz" | ||
| version = "0.0.0" | ||
| publish = false | ||
| edition = "2021" | ||
|
|
||
| [package.metadata] | ||
| cargo-fuzz = true | ||
|
|
||
| [dependencies] | ||
| libfuzzer-sys = "0.4" | ||
| arbitrary = { version = "1.3", features = ["derive"] } | ||
| serde = { workspace = true } | ||
| serde_json = { workspace = true } | ||
|
|
||
| [dependencies.ijson] | ||
| path = ".." | ||
|
|
||
| [[bin]] | ||
| name = "fuzz_json_de" | ||
| path = "fuzz_targets/fuzz_json_de.rs" | ||
| test = false | ||
| doc = false | ||
| bench = false |
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,54 @@ | ||
| #![no_main] | ||
|
|
||
| use arbitrary::Arbitrary; | ||
| use ijson::IValue; | ||
| use libfuzzer_sys::fuzz_target; | ||
| use serde::Deserialize; | ||
| use std::collections::HashMap; | ||
|
|
||
| #[derive(Arbitrary, Debug)] | ||
| enum JsonValue { | ||
| Null, | ||
| Bool(bool), | ||
| Number(f64), | ||
| String(String), | ||
| Array(Vec<JsonValue>), | ||
| Object(HashMap<String, JsonValue>), | ||
| } | ||
|
|
||
| impl JsonValue { | ||
| fn to_json_string(&self) -> String { | ||
| match self { | ||
| JsonValue::Null => "null".to_string(), | ||
| JsonValue::Bool(b) => b.to_string(), | ||
| JsonValue::Number(n) => { | ||
| if n.is_finite() { | ||
| n.to_string() | ||
| } else { | ||
| "0".to_string() | ||
| } | ||
| } | ||
| JsonValue::String(s) => format!("\"{}\"", s), | ||
| JsonValue::Array(arr) => { | ||
| let items: Vec<String> = arr.iter().map(|v| v.to_json_string()).collect(); | ||
| format!("[{}]", items.join(",")) | ||
| } | ||
| JsonValue::Object(obj) => { | ||
| let items: Vec<String> = obj | ||
| .iter() | ||
| .map(|(k, v)| { | ||
| let key = k.clone(); | ||
| format!("\"{}\":{}", key, v.to_json_string()) | ||
| }) | ||
| .collect(); | ||
| format!("{{{}}}", items.join(",")) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fuzz_target!(|value: JsonValue| { | ||
| let json_string = value.to_json_string(); | ||
| let mut deserializer = serde_json::Deserializer::from_str(&json_string); | ||
| let _ = IValue::deserialize(&mut deserializer); | ||
| }); |
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,2 @@ | ||
| [toolchain] | ||
| channel = "nightly" |
Oops, something went wrong.
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.