Skip to content

Commit f9c7bf4

Browse files
Merge pull request #20 from acezxn/js-audit-1
Javascript auditing support
2 parents a97be88 + 06384d4 commit f9c7bf4

33 files changed

Lines changed: 1698 additions & 76 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,4 @@ cython_debug/
172172
#.idea/
173173

174174
testcases/**
175+
.vscode

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@
1010
[submodule "benchmark/Go/sally"]
1111
path = benchmark/Go/sally
1212
url = https://github.com/uber-go/sally.git
13+
[submodule "benchmark/Javascript/microlight"]
14+
path = benchmark/Javascript/microlight
15+
url = https://github.com/asvd/microlight.git
16+
[submodule "benchmark/Javascript/mocha"]
17+
path = benchmark/Javascript/mocha
18+
url = https://github.com/mochajs/mocha.git
19+
[submodule "squish"]
20+
path = squish
21+
url = https://github.com/shgysk8zer0/squish.git
22+
[submodule "benchmark/Javascript/squish"]
23+
path = benchmark/Javascript/squish
24+
url = https://github.com/shgysk8zer0/squish.git
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var myname = "daniel";
2+
myname = null;
3+
4+
function test2_process(data) {
5+
let current = myname;
6+
let value = data[0];
7+
console.log(current.length)
8+
return value;
9+
}
10+
11+
12+
function test2_caller() {
13+
let data = null;
14+
return test2_process(data)
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function func_generator(value) {
2+
let fn = null;
3+
if (value % 3 == 0) {
4+
fn = console.log;
5+
} else if (value % 3 == 1) {
6+
fn = console.error;
7+
}
8+
return fn;
9+
}
10+
11+
const print = () => {
12+
func_generator(8)("Hello world!");
13+
console.log("Done");
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function getLength2(value) {
2+
if (!value) {
3+
return 0;
4+
}
5+
return value.length;
6+
}
7+
8+
const print2 = () => {
9+
let a = getLength2(null);
10+
console.log();
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function hello3() {
2+
let output = [];
3+
4+
for (let i = 0; i < 5; i++) {
5+
output.push(null);
6+
}
7+
return output;
8+
}
9+
10+
function hello4() {
11+
let output = hello3();
12+
for (let i = 0; i < 4; i++) {
13+
output[i] = i.toString();
14+
}
15+
return output[4] ? output[4].length : 0;
16+
}
17+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var a = console.error;
2+
delete a.error;
3+
const exec = function () {
4+
a.error();
5+
}
6+
exec()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const obj = {
2+
greet() {
3+
let obj = 1;
4+
console.log("hello");
5+
}
6+
};
7+
8+
9+
const a = obj;
10+
11+
function call(items) {
12+
a = items;
13+
}
14+
15+
const exec = function () {
16+
var b = null;
17+
let c = 1;
18+
call(b);
19+
20+
for (let i = 0; i < 5; i++) {
21+
a.greet();
22+
}
23+
}
24+
25+
exec();

lib/build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@
3737
os.system(
3838
f'git clone https://github.com/tree-sitter/tree-sitter-python.git {cwd / "vendor/tree-sitter-python"}'
3939
)
40+
4041
# Checkout to specific commit for language version 14 compatibility
4142
os.system(
4243
f'cd {cwd / "vendor/tree-sitter-python"} && git checkout 710796b8b877a970297106e5bbc8e2afa47f86ec'
4344
)
45+
46+
if not (cwd / "vendor/tree-sitter-javascript/grammar.js").exists():
47+
os.system(
48+
f'git clone https://github.com/tree-sitter/tree-sitter-javascript.git {cwd / "vendor/tree-sitter-javascript"}'
49+
)
4450

4551
if not (cwd / "vendor/tree-sitter-go/grammar.js").exists():
4652
os.system(
@@ -61,6 +67,7 @@
6167
str(cwd / "vendor/tree-sitter-cpp"),
6268
str(cwd / "vendor/tree-sitter-java"),
6369
str(cwd / "vendor/tree-sitter-python"),
70+
str(cwd / "vendor/tree-sitter-javascript"),
6471
str(cwd / "vendor/tree-sitter-go"),
6572
],
6673
)

requirements.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)