Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
31 changes: 31 additions & 0 deletions .github/actions/build_and_test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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:
profile: minimal
override: true
components: rustfmt, clippy

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

- 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

24 changes: 24 additions & 0 deletions .github/actions/fuzz_tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Smoke-Test Fuzz Targets
description: Run fuzz tests on the project

runs:
using: composite
steps:
- name: Install Nightly Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Install cargo-fuzz
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-fuzz --version 0.13.0

- name: Run Fuzz Tests
shell: bash
working-directory: fuzz
run: cargo fuzz run fuzz_string --release -- -max_total_time=180

29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on: [pull_request]

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
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run Fuzz Tests
uses: ./.github/actions/fuzz_tests

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