File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
javascript/ql/src/semmle/javascript/dataflow Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -1172,6 +1172,16 @@ module ClassNode {
1172
1172
result .getFile ( ) = f
1173
1173
}
1174
1174
1175
+ /**
1176
+ * Gets a reference to the function `func`, where there exists a read/write of the "prototype" property on that reference.
1177
+ */
1178
+ pragma [ noinline]
1179
+ private DataFlow:: SourceNode getAFunctionValueWithPrototype ( AbstractValue func ) {
1180
+ exists ( result .getAPropertyReference ( "prototype" ) ) and
1181
+ result .analyze ( ) .getAValue ( ) = pragma [ only_bind_into ] ( func ) and
1182
+ func instanceof AbstractFunction // the join-order goes bad if `func` has type `AbstractFunction`.
1183
+ }
1184
+
1175
1185
/**
1176
1186
* A function definition with prototype manipulation as a `ClassNode` instance.
1177
1187
*/
@@ -1182,10 +1192,7 @@ module ClassNode {
1182
1192
FunctionStyleClass ( ) {
1183
1193
function .getFunction ( ) = astNode and
1184
1194
(
1185
- exists ( DataFlow:: PropRef read |
1186
- read .getPropertyName ( ) = "prototype" and
1187
- read .getBase ( ) .analyze ( ) .getAValue ( ) = function
1188
- )
1195
+ exists ( getAFunctionValueWithPrototype ( function ) )
1189
1196
or
1190
1197
exists ( string name |
1191
1198
this = AccessPath:: getAnAssignmentTo ( name ) and
@@ -1246,7 +1253,7 @@ module ClassNode {
1246
1253
* Gets a reference to the prototype of this class.
1247
1254
*/
1248
1255
DataFlow:: SourceNode getAPrototypeReference ( ) {
1249
- exists ( DataFlow:: SourceNode base | base . analyze ( ) . getAValue ( ) = function |
1256
+ exists ( DataFlow:: SourceNode base | base = getAFunctionValueWithPrototype ( function ) |
1250
1257
result = base .getAPropertyRead ( "prototype" )
1251
1258
or
1252
1259
result = base .getAPropertySource ( "prototype" )
You can’t perform that action at this time.
0 commit comments