noir icon indicating copy to clipboard operation
noir copied to clipboard

feat: compile stdin and fuzz

Open michaeljklein opened this issue 7 months ago • 0 comments

Description

Problem*

My previous attempt to use AFL to fuzz nargo got stuck on making a fuzzing target:

  • There's a lot of file accesses
  • The file manager is opaque and challenging to fuzz directly
  • A quick-and-dirty JSON encoding of the file manager was too fragile to fuzz with
  • Removing file accesses directly was hard

Summary*

This attempt rethinks the problem:

  • Instead of fuzzing a whole workspace or package, only main.nr is fuzzed
  • This is done by adding a debug CLI option to accept main.nr from STDIN and use an implicit Nargo.toml

Results thus far:

  • It works, but it's rather slow (~1.72 executions/s)
    • Even with test cases restricted to 120 bytes!
    • ~95% of compilation appears to be parsing
  • There appears to be remaining file accesses, with only ~90% stability achieved

Additional Context

Documentation*

Check one:

  • [x] No documentation needed.
  • [ ] Documentation included in this PR.
  • [ ] [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • [x] I have tested the changes locally.
  • [ ] I have formatted the changes with Prettier and/or cargo fmt on default settings.

michaeljklein avatar Jul 23 '24 17:07 michaeljklein