Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Event CI

permissions:
contents: read

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust nightly
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

- name: Build
run: cargo build

- name: Test
run: cargo test -- --test-threads=1

32 changes: 32 additions & 0 deletions .github/workflows/fuzz_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Smoke-Test Fuzz Targets

on:
pull_request:

jobs:
fuzz:
runs-on: ubuntu-latest

env:
CARGO_FUZZ_VERSION: 0.13.0
FUZZ_TIME: 180

strategy:
matrix:
include:
- fuzz_target: fuzz_string

steps:
- uses: actions/checkout@v4

- run: rustup toolchain install nightly
- run: rustup default nightly
- uses: actions/cache@v4
with:
path: ${{ runner.tool_cache }}/cargo-fuzz
key: cargo-fuzz-bin-${{ env.CARGO_FUZZ_VERSION }}
- run: echo "${{ runner.tool_cache }}/cargo-fuzz/bin" >> $GITHUB_PATH
- run: cargo install --root "${{ runner.tool_cache }}/cargo-fuzz" --version ${{ env.CARGO_FUZZ_VERSION }} cargo-fuzz --locked

- run: cd fuzz
- run: cargo fuzz run ${{ matrix.fuzz_target }} -- -max_total_time=${{ env.FUZZ_TIME }} --release
14 changes: 12 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
members = ["fuzz"]

[package]
name = "ijson"
version = "0.1.3"
Expand All @@ -14,12 +17,17 @@ default = []
tracing = ["mockalloc/tracing"]
thread_safe = []

[workspace.dependencies]
serde = "1.0.117"
serde_json = "1.0.59"


[dependencies]
hashbrown = "0.13.2"
dashmap = { version = "5.4", features = ["raw-api"] }
lazy_static = "1.4.0"
serde = "1.0.117"
serde_json = "1.0.59"
serde = { workspace = true }
serde_json = { workspace = true }
ctor = { version = "0.1.16", optional = true }
paste = "1.0.15"
half = "2.0.0"
Expand All @@ -28,4 +36,6 @@ half = "2.0.0"
mockalloc = "0.1.2"
ctor = "0.1.16"
rand = "0.8.4"
cargo-fuzz = "0.13.0"
ijson-fuzz = { path = "fuzz" }

4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
24 changes: 24 additions & 0 deletions fuzz/Cargo.toml
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_string"
path = "fuzz_targets/fuzz_string.rs"
test = false
doc = false
bench = false
13 changes: 13 additions & 0 deletions fuzz/fuzz_targets/fuzz_string.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![no_main]

use ijson::IValue;
use libfuzzer_sys::fuzz_target;
use serde::Deserialize;

fuzz_target!(|data: &str| {
if data.is_empty() {
return;
}
let mut deserializer = serde_json::Deserializer::from_str(data);
let _ = IValue::deserialize(&mut deserializer);
});
2 changes: 2 additions & 0 deletions fuzz/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
Loading