Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scripts to generate a dictionary and seed corpus for the config fuzzing #5915

Merged
merged 1 commit into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
Add scripts to generate a dictionary and seed corpus for the config f…
…uzzing
  • Loading branch information
tomrittervg committed Oct 27, 2019
commit c8fd184096189382f5b379c4210d2e9866d76b97
26 changes: 26 additions & 0 deletions tools/harnesses/osqueryfuzz_config_corpus.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed in accordance with the terms specified in
# the LICENSE file found in the root directory of this source tree.

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function usage() {
echo "${BASH_SOURCE[0]} destination-file"
}

function main() {
if [[ $# < 1 ]]; then
usage
exit 1
fi

zip -j $1 $SCRIPT_DIR/../../../tools/tests/*.conf
}

main $@
33 changes: 33 additions & 0 deletions tools/harnesses/osqueryfuzz_config_dict.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed in accordance with the terms specified in
# the LICENSE file found in the root directory of this source tree.

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

function usage() {
echo "${BASH_SOURCE[0]} destination-file"
}

function main() {
if [[ $# < 1 ]]; then
usage
exit 1
fi

# dict format is keyword="value" or just "value" - so we need to make sure our output is quoted.

egrep -h -R -o "HasMember\\(\"([^\"]+)\"\\)" ./ | sed 's/HasMember(//' | sed 's/)//' > tmp
egrep -h -o -e "\"([^\"]+)\"" $SCRIPT_DIR/../../../tools/tests/*.conf >> tmp
egrep -h -o -e "\"([^\"]+)\"" $SCRIPT_DIR/../../../packs/*.conf >> tmp

sort tmp | uniq > $1
rm tmp
}

main $@