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

Fuzz range branch #21

Open
wants to merge 21 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Add support for --only-ascii

  • Loading branch information
swapgs committed Nov 20, 2019
commit 21b82ece6c1607e0291c396f41cf85007a1d5e20
@@ -14,9 +14,11 @@ export class Corpus {
private corpusPath: string | undefined;
private maxInputSize: number;
private seedLength: number;
private readonly onlyAscii: boolean;

constructor(dir: string[]) {
constructor(dir: string[], onlyAscii: boolean) {
this.inputs = [];
this.onlyAscii = onlyAscii;
this.maxInputSize = 4096;
for (let i of dir) {
if (!fs.existsSync(i)) {
@@ -107,6 +109,16 @@ export class Corpus {
}
}

toAscii(buf: Buffer) {
let x;
for (let i = 0; i < buf.length; i++) {
x = buf[i] & 127;
if ((x < 0x20 || x > 0x7E) && x !== 0x09 && (x < 0xA || x > 0xD)) {
buf[i] = 0x20;
}
}
}

mutate(buf: Buffer) {
let res = Buffer.allocUnsafe(buf.length);
buf.copy(res, 0, 0, buf.length);
@@ -342,6 +354,11 @@ export class Corpus {
if (res.length > this.maxInputSize) {
res = res.slice(0, this.maxInputSize)
}

if (this.onlyAscii) {
this.toAscii(res);
}

return res;
}
}
@@ -33,16 +33,19 @@ export class Fuzzer {
private regression: boolean;
private verse: Verse | null;
private readonly versifier: boolean;
private readonly onlyAscii: boolean;

constructor(target: string,
dir: string[],
exactArtifactPath: string,
rssLimitMb: number,
timeout: number,
regression: boolean,
onlyAscii: boolean,
versifier: boolean) {
this.target = target;
this.corpus = new Corpus(dir);
this.corpus = new Corpus(dir, onlyAscii);
this.onlyAscii = onlyAscii;
this.versifier = versifier;
this.verse = null;
this.total_executions = 0;
@@ -10,6 +10,7 @@ function startFuzzer(argv: any) {
argv.rssLimitMb,
argv.timeout,
argv.regression,
argv.onlyAscii,
argv.versifier);
fuzzer.start()
}
@@ -56,5 +57,10 @@ require('yargs')
description: 'use versifier algorithm (good for text based protocols)',
default: true,
})
.option('only-ascii', {
type: 'boolean',
description: 'generate only ASCII (isprint+isspace) inputs',
default: false,
})
.help()
.argv;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.