-
Notifications
You must be signed in to change notification settings - Fork 3
/
fuzzer.html
180 lines (151 loc) · 8.57 KB
/
fuzzer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Shift Fuzzer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favicon.ico">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="css/ribbon.css" rel="stylesheet">
<link href="css/css.css" rel="stylesheet">
<link href="css/demo.css" rel="stylesheet">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro:400,700" rel="stylesheet" type="text/css"/>
<!-- highlight.js -->
<link href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/styles/magula.min.css" rel="stylesheet"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- ace editor -->
<script src="vendor/ace-builds/src-min/ace.js"></script>
<script src="vendor/ace-builds/src-min/mode-javascript.js"></script>
<script src="vendor/ace-builds/src-min/theme-monokai.js"></script>
<script src="js/shift-fuzzer.js"></script>
<script src="js/shift-codegen.js"></script>
<script src="js/shift-parser.js"></script>
<script src="js/shift-validator.js"></script>
<style>
#demo1 {
position: relative;
}
#demo1 .editor {
width: 100%;
}
#demo1 .actions a {
text-decoration: none;
color: inherit;
}
#demo1 .actions {
position: absolute;
z-index: 5;
top: 0;
right: 0;
padding: 1em 1.5em;
}
#demo1 .actions .pause-button, #demo1 .actions .report-button {
display: none;
}
#demo1 .actions button {
line-height: 22px;
}
#demo1 .actions img {
height: 16px;
}
#demo1 .actions .send-to-parser {
font-weight: bold;
font-size: 14pt;
}
</style>
</head>
<body>
<div class="ribbon-container right">
<div class="ribbon">
<a href="https://github.com/shapesecurity/shift-fuzzer-js" target="_blank">Fork me on GitHub</a>
</div>
</div>
<div class="container">
<div class="content">
<div class="masthead">
<h3><a href="./index.html" class="muted hub-link">part of the Shift suite</a></h3>
</div>
<div class="jumbotron">
<h1><span class="shift">Shift</span> Fuzzer</h1>
<p class="lead">
generates random valid Shift ASTs
</p>
</div>
<hr />
<section id="introduction">
<h3>Introduction</h3>
<p>
The Shift Fuzzer generates a random, <a href="validator.html">valid</a>
Shift AST, and may generate any JavaScript program up to a given
complexity (AST depth) with a non-zero probability. Additional APIs
exist for generating only certain node types and for integrating a
custom pseudo-random number generator for deterministic and
reproducible fuzzing.
</p>
</section>
<section id="demo">
<h3>Demo</h3>
<p>
This demo uses the fuzzer to generate a random Shift AST and
renders it using the Shift Code Generator. Press the green button
in the upper right corner of the demo to begin cycling through
random programs. If the fuzzer finds a program that cannot be
parsed, you will be prompted to open an issue on GitHub because at
least one of the fuzzer, the code generator, or the parser will
have a bug.
</p>
<div class="demo" id="demo1">
<p class="actions">
<button class="btn btn-lg send-to-parser" type="button" title="Want to learn more about this program? Send it to the parser demo.">?</button>
<button class="btn btn-success btn-lg play-button" type="button" title="Begin cycling through random programs.">
<img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b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c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+Cjwvc3ZnPgo=" />
</button>
<button class="btn btn-warning btn-lg pause-button" type="button" title="Stop cycling through random programs.">
<img src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMS4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDUzNS41NzggNTM1LjU3OCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTM1LjU3OCA1MzUuNTc4OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgd2lkdGg9IjY0cHgiIGhlaWdodD0iNjRweCI+CjxnPgoJPGc+CgkJPGc+CgkJCTxwYXRoIGQ9Ik0yMzEuNiw1MTYuMjc4YzAsMTAuNjU4LTguNjQxLDE5LjMtMTkuMywxOS4zSDEwNi4xNWMtMTAuNjU5LDAtMTkuMy04LjY0MS0xOS4zLTE5LjNWMTkuMyAgICAgYzAtMTAuNjU5LDguNjQxLTE5LjMsMTkuMy0xOS4zaDEwNi4xNWMxMC42NTksMCwxOS4zLDguNjQxLDE5LjMsMTkuM1Y1MTYuMjc4eiIgZmlsbD0iI0ZGRkZGRiIvPgoJCQk8cGF0aCBkPSJNNDQ4LjcyOCw1MTYuMjc4YzAsMTAuNjU4LTguNjQxLDE5LjMtMTkuMywxOS4zaC0xMDYuMTVjLTEwLjY1OSwwLTE5LjMtOC42NDEtMTkuMy0xOS4zVjE5LjMgICAgIGMwLTEwLjY1OSw4LjY0MS0xOS4zLDE5LjMtMTkuM2gxMDYuMTVjMTAuNjU5LDAsMTkuMyw4LjY0MSwxOS4zLDE5LjNWNTE2LjI3OHoiIGZpbGw9IiNGRkZGRkYiLz4KCQk8L2c+Cgk8L2c+Cgk8Zz4KCTwvZz4KCTxnPgoJPC9nPgoJPGc+Cgk8L2c+Cgk8Zz4KCTwvZz4KCTxnPgoJPC9nPgoJPGc+Cgk8L2c+Cgk8Zz4KCTwvZz4KCTxnPgoJPC9nPgoJPGc+Cgk8L2c+Cgk8Zz4KCTwvZz4KCTxnPgoJPC9nPgoJPGc+Cgk8L2c+Cgk8Zz4KCTwvZz4KCTxnPgoJPC9nPgoJPGc+Cgk8L2c+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==" />
</button>
<button class="btn btn-danger btn-lg report-button" type="button">You've found a bug! Open an issue.</button>
</p>
<div class="editor" spellcheck="false"></div>
</div>
<script src="js/fuzzer/main.js"></script>
</section>
<section id="installation">
<h3>Installation</h3>
<pre><code class="nohighlight">npm install shift-fuzzer</code></pre>
</section>
<section id="usage">
<h3>Usage</h3>
<pre><code class="javascript">import fuzzProgram, {FuzzerState, fuzzFunctionDeclaration} from "shift-fuzzer";
import render from "shift-codegen";
// generate random program
let randomProgramAst = fuzzProgram();
let randomProgram = render(randomProgramAst);
console.log(randomProgram);
// generate random FunctionDeclaration
let randomFunctionAst = fuzzFunctionDeclaration(new FuzzerState({maxDepth: 7}));
let randomFunction = render(randomFunctionAst);
console.log(randomFunction);
// generate random program from a seed
const RNG_SEED = 0xBADBE1BE1;
let prng =
(function(state){
return function nextDouble() {
// implementation left as an exercise for the reader
};
}(RNG_SEED));
let seededRandomProgramAst = fuzzProgram(new FuzzerState({rng: prng, maxDepth: 7}));
let seededRandomProgram = render(seededRandomProgramAst);
console.log(seededRandomProgram);</code></pre>
</section>
</div>
<hr />
<div class="footer">
<p>© Shape Security, Inc.</p>
</div>
</div>
</body>
</html>