Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Establish a fuzzing harness to demonstrate parser robustness #4

@riking

Description

@riking

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(); }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions