-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
253 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 |
---|---|---|
|
@@ -5,4 +5,5 @@ members = [ | |
"zns", | ||
"zns-cli", | ||
"zns-daemon", | ||
"fuzz" | ||
] |
This file contains 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 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,19 @@ | ||
[package] | ||
name = "zns-fuzz" | ||
version = "0.0.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
zns = {path = "../zns", features = ["arbitrary"]} | ||
|
||
[[bin]] | ||
name = "parser" | ||
path = "fuzz_targets/parser.rs" | ||
test = false | ||
doc = false | ||
bench = false |
This file contains 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,42 @@ | ||
#!/bin/env bash | ||
set -e | ||
|
||
# Check if the correct number of arguments is provided | ||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <llvm-cov> <fuzz_target>" | ||
exit 1 | ||
fi | ||
|
||
# Assign the first argument to the fuzz_target variable | ||
COMMAND=$1 | ||
FUZZ_TARGET=$2 | ||
|
||
|
||
if ! command -v $(COMMAND) &> /dev/null; then | ||
echo "llvm-cov could not be found, please install LLVM." | ||
exit 1 | ||
fi | ||
|
||
if ! command -v rustfilt &> /dev/null; then | ||
echo "rustfilt could not be found, please install rustfilt." | ||
exit 1 | ||
fi | ||
|
||
cargo fuzz coverage "$FUZZ_TARGET" | ||
|
||
TARGET_DIR="target/x86_64-unknown-linux-gnu/coverage/x86_64-unknown-linux-gnu/release" | ||
PROF_DATA="coverage/$FUZZ_TARGET/coverage.profdata" | ||
OUTPUT_FILE="coverage/index.html" | ||
|
||
if [ ! -f "$PROF_DATA" ]; then | ||
echo "Coverage data file $PROF_DATA not found." | ||
exit 1 | ||
fi | ||
|
||
$COMMAND show "$TARGET_DIR/$FUZZ_TARGET" --format=html \ | ||
-Xdemangler=rustfilt \ | ||
--ignore-filename-regex="\.cargo" \ | ||
-instr-profile="$PROF_DATA" \ | ||
> "$OUTPUT_FILE" | ||
|
||
echo "Coverage report generated as $OUTPUT_FILE" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,31 @@ | ||
{ | ||
description = "Simple OAuth2 server for hackerspaces"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
rust-overlay = { | ||
url = "github:oxalica/rust-overlay"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
inputs.flake-utils.follows = "flake-utils"; | ||
}; | ||
}; | ||
outputs = {self, nixpkgs, flake-utils, rust-overlay, ... }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
overlays = [ (import rust-overlay) ]; | ||
pkgs = import nixpkgs { | ||
inherit system overlays; | ||
}; | ||
in | ||
with pkgs; | ||
{ | ||
devShell = mkShell { | ||
buildInputs = [ | ||
(rust-bin.nightly.latest.default.override { extensions = [ "llvm-tools-preview" ]; }) | ||
cargo-fuzz | ||
rustfilt | ||
]; | ||
}; | ||
}); | ||
} |
This file contains 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,9 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
use zns::{parser::FromBytes, reader::Reader, structs::Message}; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let mut reader = Reader::new(data); | ||
let _ = Message::from_bytes(&mut reader); | ||
}); |
This file contains 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 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 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
Oops, something went wrong.