-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebunpack.test.js
91 lines (67 loc) · 2.84 KB
/
webunpack.test.js
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
const lib = require('./lib/index.js');
const signaturesmodule = require('./lib/signatures.js');
const execSync = require('child_process').execSync;
const fs = require('fs');
const DIR_TMPWEBPACK_TEST = __dirname+"/tests";
test('handlebars vuln', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testhandlebarsvuln";
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdbfiltered.json", true);
expect(ret.name).toBe("handlebars");
expect(ret.version).toBe("4.3.2");
expect(ret.version).not.toBe(false);
}
});
test('validator react largedb', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testlargedbreactvuln";
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdb.json", true);
expect(ret.name).toBe("react");
expect(ret.version).toBe("0.5.0");
expect(ret.version).not.toBe(false);
}
});
test('validator vuln', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testvalidatorvuln";
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdb.json", true);
expect(ret.name).toBe("validator");
expect(ret.version).toBe("1.0.0");
expect(ret.version).not.toBe(false);
}
});
test('validator nonvuln', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testvalidatornonvuln";
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdb.json", true);
expect(ret.name).toBe(null);
expect(ret.version).toBe(null);
}
});
test('lodash vuln', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testlodashvuln";
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdb.json", true);
expect(ret.name).toBe(null);
expect(ret.version).toBe(null);
}
});
test('lodash nonvuln', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testlodashnonvuln";
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdb.json", true);
expect(ret.name).toBe(null);
expect(ret.version).toBe(null);
}
});
test('lodash vuln complete fictif test', () => {
var DIR_MODULE = DIR_TMPWEBPACK_TEST+"/testcompletelodashvuln";
if(lib.createSignatures(DIR_MODULE+"/fakevulnlodash.txt", DIR_MODULE+"/signaturesdb.json")) {
if(lib.installWebPack(DIR_MODULE)) {
var ret = lib.unpackFile(DIR_MODULE+"/dist/main.js", DIR_MODULE+"/signaturesdb.json", true);
console.dir(ret);
expect(ret.name).toBe("lodash");
expect(ret.version).toBe("4.0.0");
}
}
});