Debian Codegraph @

bin/fuzzfiles

raw symbols SCIP
1 #! /bin/bashscip-shell filesystem . . `/bin/bash`.
2 #
3 # This file is part of the LibreOffice project.
4 #
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 #
9
10 #check that zzuf is installed
11 hash zzuf &> /dev/nullscip-shell filesystem . . `/dev/null`.
12 if [scip-shell system . . `[`. $? -eq 1 ];then
13 echoscip-shell system . . echo. >&2 "zzuf not found. Please install and/or fix the PATH environment variable. Aborting"
14 exit -1
15 fi
16
17 #check that file(s) to fuzz are mentioned
18 if [[ $# -eq 0 ]]; then
19 echoscip-shell system . . echo. "Usage: fuzzfiles.sh <list of seed files to fuzz>"
20 echoscip-shell system . . echo. "The generated fuzzed files will be output to the current working directory"
21 echoscip-shell system . . echo. "The fuzzed files will be named XYZ-ratio-NNNN where:"
22 echoscip-shell system . . echo. -e "\tXYZ: the original file name"
23 echoscip-shell system . . echo. -e "\tratio: the fuzz ratio (what % of bytes were fuzzed)"
24 echoscip-shell system . . echo. -e "\tNNNN: the mutation # for that file and ratio combo"
25 exit -1
26 fi
27
28 for file in $@; do
29 if [scip-shell system . . `[`. -d $file ]; then
30 echoscip-shell system . . echo. "$file is a directory. Only files are allowed"
31 elif [scip-shell system . . `[`. -e $file ]; then
32 basename=${file##*/}
33 #Sequence from 0.001 to 0.5
34 for ratio in `seqscip-shell system . . seq. -w 1 2 500 | sedscip-shell system . . sed. -e 's/^/0./'`; do
35 echoscip-shell system . . echo. "Fuzzing $file with ratio $ratio"
36 for i in {1..1000}; do
37 zzuf -r $ratio < $file > "$basename-$ratio-$i"
38 done #end of for i in {1..
39 done #end of for ratio in ...
40 fi #end if of file validity check
41 done #end for file in $@