-
Notifications
You must be signed in to change notification settings - Fork 5
/
Variable.js
70 lines (64 loc) · 1.77 KB
/
Variable.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
class Variable {
constructor(type, value = null, taint = {}) {
this.type = type;
this.value = value;
this.taint = taint;
}
transfer_taint(variable) {
if (!variable.taint) {
return;
}
let keys = Object.keys(variable.taint);
for (let i = 0; i < keys.length; i++) {
if (variable.taint[keys[i]] > 0) {
this.taint[keys[i]] |= variable.taint[keys[i]];
}
}
}
transfer_direct_taint(variable) {
if (!variable.taint) {
return;
}
let keys = Object.keys(variable.taint);
for (let i = 0; i < keys.length; i++) {
if (variable.taint[keys[i]] > 0) {
//this.taint[keys[i]] |= 1;
this.taint[keys[i]] |= variable.taint[keys[i]];
}
}
}
transfer_indirect_taint(variable) {
if (!variable.taint) {
return;
}
let keys = Object.keys(variable.taint);
for (let i = 0; i < keys.length; i++) {
if (variable.taint[keys[i]] & 2) {
this.taint[keys[i]] |= 2;
}
}
}
transfer_from_taint(taint) {
if (!taint) {
return;
}
let keys = Object.keys(taint);
for (let i = 0; i < keys.length; i++) {
if (taint[keys[i]] > 0) {
this.taint[keys[i]] |= taint[keys[i]];
}
}
}
transfer_from_taint_indirect(variable) {
if (!taint) {
return;
}
let keys = Object.keys(taint);
for (let i = 0; i < keys.length; i++) {
if (taint[keys[i]] & 2) {
this.taint[keys[i]] |= 2;
}
}
}
}
module.exports = Variable;