File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
javascript/ql/lib/semmle/javascript/dataflow Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ private import javascript
8
8
private import semmle.javascript.dependencies.Dependencies
9
9
private import internal.CallGraphs
10
10
private import semmle.javascript.internal.CachedStages
11
+ private import semmle.javascript.dataflow.internal.PreCallGraphStep
11
12
12
13
/**
13
14
* A data flow node corresponding to an expression.
@@ -995,6 +996,9 @@ class ClassNode extends DataFlow::SourceNode instanceof ClassNode::Range {
995
996
result .getAstNode ( ) .getFile ( ) = this .getAstNode ( ) .getFile ( )
996
997
)
997
998
or
999
+ t .start ( ) and
1000
+ PreCallGraphStep:: classObjectSource ( this , result )
1001
+ or
998
1002
result = this .getAClassReferenceRec ( t )
999
1003
}
1000
1004
@@ -1044,6 +1048,9 @@ class ClassNode extends DataFlow::SourceNode instanceof ClassNode::Range {
1044
1048
// Note that this also blocks flows into a property of the receiver,
1045
1049
// but the `localFieldStep` rule will often compensate for this.
1046
1050
not result = any ( DataFlow:: ClassNode cls ) .getAReceiverNode ( )
1051
+ or
1052
+ t .start ( ) and
1053
+ PreCallGraphStep:: classInstanceSource ( this , result )
1047
1054
}
1048
1055
1049
1056
pragma [ noinline]
Original file line number Diff line number Diff line change @@ -44,6 +44,16 @@ class PreCallGraphStep extends Unit {
44
44
) {
45
45
none ( )
46
46
}
47
+
48
+ /**
49
+ * Holds if `node` can hold an instance of `cls`.
50
+ */
51
+ predicate classInstanceSource ( DataFlow:: ClassNode cls , DataFlow:: Node node ) { none ( ) }
52
+
53
+ /**
54
+ * Holds if `node` can hold an reference to the `cls` class itself.
55
+ */
56
+ predicate classObjectSource ( DataFlow:: ClassNode cls , DataFlow:: Node node ) { none ( ) }
47
57
}
48
58
49
59
cached
@@ -90,6 +100,22 @@ module PreCallGraphStep {
90
100
) {
91
101
any ( PreCallGraphStep s ) .loadStoreStep ( pred , succ , loadProp , storeProp )
92
102
}
103
+
104
+ /**
105
+ * Holds if `node` can hold an instance of `cls`.
106
+ */
107
+ cached
108
+ predicate classInstanceSource ( DataFlow:: ClassNode cls , DataFlow:: Node node ) {
109
+ any ( PreCallGraphStep s ) .classInstanceSource ( cls , node )
110
+ }
111
+
112
+ /**
113
+ * Holds if `node` can hold an reference to the `cls` class itself.
114
+ */
115
+ cached
116
+ predicate classObjectSource ( DataFlow:: ClassNode cls , DataFlow:: Node node ) {
117
+ any ( PreCallGraphStep s ) .classObjectSource ( cls , node )
118
+ }
93
119
}
94
120
95
121
/**
You can’t perform that action at this time.
0 commit comments