Updated Fuzzing your nim code to rabbit out all the hard bugs (markdown)
This commit is contained in:
parent
6f7a03894a
commit
dc28e4a24a
|
@ -127,3 +127,26 @@ You can limit the exceptions that are considered crashes by adjusting the except
|
|||
|
||||
Then I'd strongly suggest to start reading up on afl if you want to employ it with confidence.
|
||||
|
||||
## Testing for bugs in your code
|
||||
|
||||
By default AFL will identify segfaults and such but not vulnerabilities in your code. You can add extra assertions to be run only during the AFL test with:
|
||||
|
||||
```nim
|
||||
when defined(macosx) or defined(linux) or defined(freebsd) or
|
||||
defined(openbsd) or defined(netbsd) or defined(solaris):
|
||||
import posix
|
||||
|
||||
template AFLAssert*(cond: bool) =
|
||||
when defined(afl):
|
||||
if not cond:
|
||||
echo "Failed AFL assertion: " & astToStr(cond)
|
||||
let pid = posix.getpid()
|
||||
discard posix.kill(pid, posix.SIGABRT)
|
||||
```
|
||||
|
||||
Also add `-d:afl` to your nim.cfg to enable this.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue