mirror of https://github.com/status-im/nim-eth.git
Fix quotes
This commit is contained in:
parent
2b8921690c
commit
0874f41a53
|
@ -29,8 +29,8 @@ const
|
||||||
"--passL='-fsanitize=fuzzer,address'"
|
"--passL='-fsanitize=fuzzer,address'"
|
||||||
# Can also test in debug mode obviously, but might be slower
|
# Can also test in debug mode obviously, but might be slower
|
||||||
# Can turn on more logging, in case of libFuzzer it will get very verbose though
|
# Can turn on more logging, in case of libFuzzer it will get very verbose though
|
||||||
defaultFlags = "-d:release -d:chronicles_log_level=fatal "# &
|
defaultFlags = "-d:release -d:chronicles_log_level=fatal " &
|
||||||
# "--hints:off --warnings:off --verbosity:0"
|
"--hints:off --warnings:off --verbosity:0"
|
||||||
|
|
||||||
type
|
type
|
||||||
Fuzzer* = enum
|
Fuzzer* = enum
|
||||||
|
@ -42,9 +42,24 @@ type
|
||||||
clang = aflClang,
|
clang = aflClang,
|
||||||
clangFast = aflClangFast
|
clangFast = aflClangFast
|
||||||
|
|
||||||
|
|
||||||
|
proc quote(s: string): string {.noSideEffect.} =
|
||||||
|
## Copy of quoteShellPosix from os module
|
||||||
|
const safeUnixChars = {'%', '+', '-', '.', '/', '_', ':', '=', '@',
|
||||||
|
'0'..'9', 'A'..'Z', 'a'..'z'}
|
||||||
|
if s.len == 0:
|
||||||
|
return "''"
|
||||||
|
|
||||||
|
let safe = s.allCharsInSet(safeUnixChars)
|
||||||
|
|
||||||
|
if safe:
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return "'" & s.replace("'", "'\"'\"'") & "'"
|
||||||
|
|
||||||
proc aflCompile*(target: string, c: Compiler) =
|
proc aflCompile*(target: string, c: Compiler) =
|
||||||
let aflOptions = &"-d:standalone -d:noSignalHandler {$c}"
|
let aflOptions = &"-d:standalone -d:noSignalHandler {$c}"
|
||||||
let compileCmd = &"""nim c {defaultFlags} {aflOptions} {target}"""
|
let compileCmd = &"nim c {defaultFlags} {aflOptions} {target.quote()}"
|
||||||
exec compileCmd
|
exec compileCmd
|
||||||
|
|
||||||
proc aflExec*(target: string, inputDir: string, resultsDir: string,
|
proc aflExec*(target: string, inputDir: string, resultsDir: string,
|
||||||
|
@ -57,14 +72,14 @@ proc aflExec*(target: string, inputDir: string, resultsDir: string,
|
||||||
var fuzzCmd: string
|
var fuzzCmd: string
|
||||||
# if there is an output dir already, continue fuzzing from previous run
|
# if there is an output dir already, continue fuzzing from previous run
|
||||||
if (not dirExists(resultsDir)) or cleanStart:
|
if (not dirExists(resultsDir)) or cleanStart:
|
||||||
fuzzCmd = &"""afl-fuzz -i {inputDir} -o {resultsDir} -M fuzzer01 -- ./{target}"""
|
fuzzCmd = &"afl-fuzz -i {inputDir.quote()} -o {resultsDir.quote()} -M fuzzer01 -- ./{target.quote()}"
|
||||||
else:
|
else:
|
||||||
fuzzCmd = &"""afl-fuzz -i - -o {resultsDir} -M fuzzer01 -- ./{target}"""
|
fuzzCmd = &"afl-fuzz -i - -o {resultsDir.quote()} -M fuzzer01 -- ./{target.quote()}"
|
||||||
exec fuzzCmd
|
exec fuzzCmd
|
||||||
|
|
||||||
proc libFuzzerCompile*(target: string) =
|
proc libFuzzerCompile*(target: string) =
|
||||||
let libFuzzerOptions = &"--noMain {libFuzzerClang}"
|
let libFuzzerOptions = &"--noMain {libFuzzerClang}"
|
||||||
let compileCmd = &"""nim c {defaultFlags} {libFuzzerOptions} {target}"""
|
let compileCmd = &"nim c {defaultFlags} {libFuzzerOptions} {target.quote()}"
|
||||||
exec compileCmd
|
exec compileCmd
|
||||||
|
|
||||||
proc libFuzzerExec*(target: string, corpusDir: string) =
|
proc libFuzzerExec*(target: string, corpusDir: string) =
|
||||||
|
@ -72,7 +87,7 @@ proc libFuzzerExec*(target: string, corpusDir: string) =
|
||||||
# libFuzzer is OK when starting with empty corpus dir
|
# libFuzzer is OK when starting with empty corpus dir
|
||||||
mkDir(corpusDir)
|
mkDir(corpusDir)
|
||||||
|
|
||||||
exec &"""./{target} {corpusDir}"""
|
exec &"./{target.quote()} {corpusDir.quote()}"
|
||||||
|
|
||||||
proc getDir*(path: string): string =
|
proc getDir*(path: string): string =
|
||||||
# TODO: This is not platform friendly at all.
|
# TODO: This is not platform friendly at all.
|
||||||
|
|
Loading…
Reference in New Issue