Oak is an output-oriented symbolic interpreter for the PHP programming language. PHP scripts generate client page output dynamically, often depending on a number of program inputs including user interaction, database queries or file system access. This tool is inspired by the symbolic execution engine by Symex and additionally provides support for basic object-oriented programming and array support.
To build and run Oak, you will need
- Java 8+,
- Scala 2.11.8+,
- sbt 0.11+: sbt for building the interpreter and resolving dependencies.
To obtain the tool, simply clone this repository git clone https://github.com/smba/oak.git
and build the project by running sbt in the root directory of this repository sbt compile
.
The repository contains four projects:
oak
: Interpreter infrastructure including testsquercus
: Quercus is a pure-Java implementation of the PHP language, we basically reuse the parser and AST fragmentskernel
andhessian
are dependencies for quercus
To run Oak for a given PHP script file see edu.cmu.cs.oak.analysis.RunOakForFile.scala
and specify input script file and output path for the approximated output, then compile and execute the file. The predefined example script file schoolmate/index.php
is the main entry point for the SchoolMate application.
The approximated output can either be exported as HTML/JS output spiced with preprocessor-like annotations (#ifdef, #else, #endif, ...) or as a VarDOM/XML model (DOM-like output extended with select nodes to express variants and corresponding conditions).
To edit the interpreter IntelliJ IDEA or the Scala IDE for Eclipse are recommended. You can import sbt projects directly into IntelliJ; for eclipse we use the plugin sbteclipse to build eclipse projects. For Eclipse simply use sbt eclipse
to build eclipse projects.
Additionally, if you might want to configure different variants of the interpreter, use the Antenna preprocessor. The eclipse plugin FeatureIDE might become handy when modeling additional features.