Skip to content

Commit

Permalink
Add a basic JavaScript-to-FuzzIL compiler
Browse files Browse the repository at this point in the history
The new compiler:
- Is (mostly) written in Swift to ensure that changes to FuzzIL are
  reflected in the compiler.
- Features an "end-to-end" testsuite that runs as part of `swift test`.
  The testsuite consists of a number of JavaScript programs which are
  compiled to FuzzIL, then lifted back to JavaScript and checked to
  produce the same output as the original code.
- Uses a (fairly) stable protobuf-based AST format which is currently
  produced by a node.js-based parser (since there seem to be no good
  JavaScript parsers with swift integration), but could also be produced
  by any other parser.

The compiler is still quite far away from being feature complete but it
should support the most important language features. Adding support for
more features is usually relatively simple: typically it involves adding
one or more tests to the testuite, adding the relevant AST nodes to
ast.proto, updating the parser script to emit these nodes, and updating
the compiler to handle them. However, some features may require changes
to FuzzIL, such as proper handling of loop headers.

The compiler is currently exposed through the FuzzILTool's --compile
option. In the future we may want to have a more sophisticated CLI
interface, for example to allow removing calls to certain functions
(such as assertX from tests) from the compiled code.
  • Loading branch information
Samuel Groß committed Feb 22, 2023
1 parent c8b25c3 commit 807625f
Show file tree
Hide file tree
Showing 156 changed files with 7,815 additions and 10,340 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -5,6 +5,11 @@ Package.resolved
/*.xcodeproj
.vscode
.*.sw?
.swiftpm

# custom GCE configuration
Cloud/GCE/config.sh

# node.js dependencies, used by the JavaScript parser for the FuzzIL compiler
node_modules
package-lock.json
2 changes: 2 additions & 0 deletions Cloud/Docker/Corpus/.gitignore
@@ -0,0 +1,2 @@
*js
*fuzzil.protobuf
3 changes: 3 additions & 0 deletions Cloud/Docker/Dockerfile
Expand Up @@ -23,6 +23,9 @@ ADD DuktapeBuilder/out duktape
# Add JerryScript binary
ADD JerryScriptBuilder/out jerryscript

# Add Corpus (if any)
ADD Corpus corpus

# Add Fuzzilli binaries
ADD FuzzilliBuilder/out/Fuzzilli Fuzzilli
ADD FuzzilliBuilder/out/REPRLRun REPRLRun
Expand Down
2 changes: 2 additions & 0 deletions Cloud/GCE/config-template.sh
Expand Up @@ -19,6 +19,8 @@ BINARY=./v8/d8
FUZZILLI_ARGS="--profile=v8"
# Arguments for the root instance. See ./Fuzzilli --help
FUZZILLI_ROOT_ARGS="--exportStatistics"
# Arguments for the intermediate instances. See ./Fuzzilli --help
FUZZILLI_INTERMEDIATE_ARGS=""
# Arguments for the leaf instances. See ./Fuzzilli --help
FUZZILLI_LEAF_ARGS=""

Expand Down
2 changes: 1 addition & 1 deletion Cloud/GCE/start.sh
Expand Up @@ -165,7 +165,7 @@ if [ "$START_INTERMEDIATES" = true ]; then
--container-tty \
--container-command=/bin/bash \
--container-arg="-c" \
--container-arg="sysctl -w 'kernel.core_pattern=|/bin/false' && ./Fuzzilli --instanceType=intermediate --connectTo=$parent_ip:1337 --bindTo=0.0.0.0:1337 $FUZZILLI_ARGS $BINARY" \
--container-arg="sysctl -w 'kernel.core_pattern=|/bin/false' && ./Fuzzilli --instanceType=intermediate --connectTo=$parent_ip:1337 --bindTo=0.0.0.0:1337 $FUZZILLI_ARGS $FUZZILLI_INTERMEDIATE_ARGS $BINARY" \
--network-tier=PREMIUM \
--maintenance-policy=MIGRATE \
--labels=container-vm=$IMAGE,level=$level,role=intermediate,session=$SESSION
Expand Down
6 changes: 0 additions & 6 deletions Compiler/.gitignore

This file was deleted.

35 changes: 0 additions & 35 deletions Compiler/Dockerfile

This file was deleted.

110 changes: 0 additions & 110 deletions Compiler/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions Compiler/bin/dune

This file was deleted.

36 changes: 0 additions & 36 deletions Compiler/bin/fuzzilli_compiler.ml

This file was deleted.

4 changes: 0 additions & 4 deletions Compiler/build-pbs.sh

This file was deleted.

1 change: 0 additions & 1 deletion Compiler/dune-project

This file was deleted.

Empty file removed Compiler/fuzzilli_compiler.opam
Empty file.
22 changes: 0 additions & 22 deletions Compiler/package.json

This file was deleted.

0 comments on commit 807625f

Please sign in to comment.