ExpoSEJS / ExpoSE

A Dynamic Symbolic Execution (DSE) engine for JavaScript. ExpoSE is highly scalable, compatible with recent JavaScript standards, and supports symbolic modelling of strings and regular expressions.
MIT License
188 stars 36 forks source link

Electron Browser mode and instrumentation failure #88

Open 1one-w01f opened 4 years ago

1one-w01f commented 4 years ago

Let me begin by congratulating you for the excellent papers.

Was wondering how to use the Browser mode w/ Electron? How to specify symbolic input in that case? I can see the Electron browser showing up but then after closing it I get a bunch of errors in the CLI:

[!] Exception E: SyntaxError: Unexpected end of JSON input of test data on 
[!] Exception E: SyntaxError: Unexpected end of JSON input of coverage data on 
[!] Error extracting final output - a fatal error must have occured
[!] expoSE replay 'https://google.com' '{"_bound":0}'
[!] Stats
[!] Done
[+] Total Lines Of Code 0
[+] Total Coverage: NaN%
[+] EXPOSE_PRINT_COVERAGE=1 for line by line breakdown
[+] ExpoSE Finished. 1 paths, 1 errors

Digging around the log file in /tmp/ it appears to me that it always fails to instrument:

b'Transforming\nFailure during HTML instrumentation: ENOENT: no such file or directory, open ... ...
... ...
... ...
... ...
Exception in processFile() @ proxy.py
Traceback (most recent call last):
  File "node_modules/jalangi2/scripts/proxy.py", line 51, in processFile
    with open (instrumentedFileName, "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'cache/www.google.com/e286e6d443be5e0a7f6b1b5381f16203/index_jalangi_.html'

I wrote a very simple page as a test (shown below) but that also results in a similar instrumentation failure. Can you give me some pointers to how to make it work?

<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Parse foo</title>
</head>
<body>
<script>

var s = location.href.substring(document.location.href.indexOf("?a=")+3);

var regex1 = RegExp('foo*','g');
var array1;

while ((array1 = regex1.exec(s)) !== null) {
  document.write(`Found ${array1[0]}. Next starts at ${regex1.lastIndex}.<br>`);
}

</script>
</body>
</html>
jawline commented 4 years ago

Hi! Our browser support is very experimental, and often a bit finicky to get working. The easiest way to get it working would be to modify our Dockerfile for your needs, as (Unless I've broken something) that should work with browser support out of the box.

I would recommend using this branch https://github.com/ExpoSEJS/ExpoSE/tree/features/browser as we make all experimental changes for the browser here, and I can't remember what is in master.

Second, we require specific versions of nodejs and python (Our dockerfile is pegged to them): https://github.com/ExpoSEJS/ExpoSE/blob/features/browser/scripts/docker_setup, https://github.com/ExpoSEJS/ExpoSE/blob/features/browser/Dockerfile give installation details.

Finally, we currently have only got it working on Ubuntu. I'm pretty sure it will run on other flavours of Linux, especially if you use Xvfb to make a display rather than a real X window, but I doubt it will work on Mac.