Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
47 changes: 47 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Event CI

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 Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Cargo Format
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check

- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features -- -D warnings

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: -- --test-threads=1

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

on: [pull_request]

jobs:
fuzz:
env:
CARGO_FUZZ_VERSION: 0.13.0
FUZZ_TIME: 180

strategy:
matrix:
include:
- fuzz_target: fuzz_string
runs-on: ubuntu-latest
steps:
- name: Setup
uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: cargo-fuzz

- uses: actions-rs/cargo@v1
with:
command: install
args: cargo-fuzz --version ${{ env.CARGO_FUZZ_VERSION }}

- name: Fuzz
working-directory: fuzz
run: cargo fuzz run ${{ matrix.fuzz_target }} --release -- -max_total_time=${{ env.FUZZ_TIME }}
175 changes: 0 additions & 175 deletions .github/workflows/toolchain.yml

This file was deleted.

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