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

Establish a fuzzing harness to demonstrate parser robustness #4

Open
riking opened this issue Jul 17, 2022 · 0 comments
Open

Establish a fuzzing harness to demonstrate parser robustness #4

riking opened this issue Jul 17, 2022 · 0 comments

Comments

@riking
Copy link

riking commented Jul 17, 2022

Running a fuzzer is a basic quality-of-implementation task for any parser that wants to be widely used. Because you have a canonical reference format, you can easily implement round-trip verification fuzzing.

// We can round-trip any valid JSON
function fuzzTargetA(payload) {
  const expected = try { JSON.parse(payload) } catch { return; };
  const result = jcof.decode(jcof.encode(expected));
  if (!check_equivalence(expected, result)) { fail(); }
}

// We can encode anything we successfully decode, and it decodes without errors
function fuzzTargetB(payload) {
  const expected = try { jcof.decode(payload) } catch { return; };
  const result = jcof.decode(jcof.encode(decoded));
  if (!check_equivalence(expected, result)) { fail(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant