-
Notifications
You must be signed in to change notification settings - Fork 4
/
ReactAssignToHref.ql
52 lines (41 loc) · 1.25 KB
/
ReactAssignToHref.ql
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
import javascript
/**
* Gets a warning message for `pref` if one of the `nodeIntegration` features is enabled.
*/
class ReactSetHrefSinks extends DataFlow::Node {
ReactSetHrefSinks() {
exists(JSXAttribute attr |
attr.getName() = "href" and attr.getValue() = this.asExpr()
)
}
}
class ReactSetHrefTracker extends TaintTracking::Configuration{
ReactSetHrefTracker() {
this = "ReactSetHrefTracker"
}
override predicate isSource(DataFlow::Node nd){
exists(|
not (nd.asExpr() instanceof ConstantExpr)
and not exists(nd.toString().toLowerCase().indexOf("icon"))
)
//any()
}
override predicate isSink(DataFlow::Node nd){
nd instanceof ReactSetHrefSinks
}
/*override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
exists(DataFlow::ObjectLiteralNode obj, DataFlow::Node html_value |
obj.hasPropertyWrite("__html", html_value) and
succ = obj and
pred = html_value
)
}*/
}
from ReactSetHrefTracker pt, DataFlow::Node source, DataFlow::Node sink
where pt.hasFlow(source, sink)
select source,sink
/*
from ObjectExpr ob, Property value
where value = ob.getPropertyByName("nodeIntegration")
select ob,value
*/