Skip to content

Commit 4c536dd

Browse files
committed
JS: Propagate locally returned functions out of calls
1 parent 6531db3 commit 4c536dd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

javascript/ql/src/semmle/javascript/dataflow/internal/CallGraphs.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ module CallGraph {
6161
function = cls.getConstructor() and
6262
cls.getAClassReference(t.continue()).flowsTo(result)
6363
)
64+
or
65+
imprecision = 0 and
66+
exists(DataFlow::FunctionNode outer |
67+
result = getAFunctionReference(outer, 0, t.continue()).getAnInvocation() and
68+
locallyReturnedFunction(outer, function)
69+
)
70+
}
71+
72+
cached
73+
private predicate locallyReturnedFunction(DataFlow::FunctionNode outer, DataFlow::FunctionNode inner) {
74+
inner.flowsTo(outer.getAReturn())
6475
}
6576

6677
/**

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/Test.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ spuriousCallee
22
missingCallee
33
| constructor-field.ts:40:5:40:14 | f3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 |
44
| constructor-field.ts:71:1:71:11 | bf3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 |
5-
| returned-function.js:23:1:23:4 | r2() | returned-function.js:8:9:10:9 | functio ... } | -1 |
65
badAnnotation

0 commit comments

Comments
 (0)