Skip to content

Commit

Permalink
Add first fuzz target for fuzzing simplify algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Feb 26, 2021
1 parent 54c09a4 commit 1e36d1e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- geo_types
- geo
- geo_postgis
- geo_fuzz
- coverage
- bench
steps:
Expand All @@ -24,6 +25,7 @@ jobs:
- name: Mark the job as a failure
if: "!success()"
run: exit 1

geo_types:
name: geo-types
runs-on: ubuntu-latest
Expand Down Expand Up @@ -80,6 +82,24 @@ jobs:
- run: cargo install cargo-all-features
- run: cargo build-all-features
- run: cargo test-all-features

geo_fuzz:
name: geo-fuzz
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
defaults:
run:
working-directory: geo/fuzz
strategy:
matrix:
container_image: ["georust/geo-ci:rust-1.49", "georust/geo-ci:rust-1.50"]
container:
image: ${{ matrix.container_image }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- run: cargo build --bins

coverage:
name: coverage
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions geo/fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
corpus
artifacts
29 changes: 29 additions & 0 deletions geo/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "geo-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.geo]
path = ".."

[dependencies.geo-types]
path = "../../geo-types"
features = ["arbitrary"]

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "simplify"
path = "fuzz_targets/simplify.rs"
test = false
doc = false
11 changes: 11 additions & 0 deletions geo/fuzz/fuzz_targets/simplify.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]

use geo::algorithm::simplify::Simplify;
use libfuzzer_sys::fuzz_target;

fuzz_target!(|tuple: (geo_types::Polygon<f32>, f32)| {
if tuple.1 < 0. {
return;
}
tuple.0.simplify(&tuple.1);
});

0 comments on commit 1e36d1e

Please sign in to comment.