Skip to content

Commit e05e077

Browse files
committed
JS: Block jump steps through 'this' now that the capture lib handles 'this'
1 parent 16b08b7 commit e05e077

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/DataFlowPrivate.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,14 +1032,32 @@ private predicate isBlockedLegacyNode(Node node) {
10321032
legacyBarrier(node)
10331033
}
10341034

1035+
/**
1036+
* Holds if `thisNode` represents a value of `this` that is being tracked by the
1037+
* variable capture library.
1038+
*
1039+
* In this case we need to suppress the default flow steps between `thisNode` and
1040+
* the `ThisExpr` nodes; especially those that would become jump steps.
1041+
*
1042+
* Note that local uses of `this` are sometimes tracked by the local SSA library, but we should
1043+
* not block local def-use flow, since we only switch to use-use flow after a post-update.
1044+
*/
1045+
pragma[nomagic]
1046+
private predicate isThisNodeTrackedByVariableCapture(DataFlow::ThisNode thisNode) {
1047+
exists(StmtContainer container | thisNode = TThisNode(container) |
1048+
any(VariableCaptureConfig::CapturedVariable v).asThisContainer() = container
1049+
)
1050+
}
1051+
10351052
/**
10361053
* Holds if there is a value-preserving steps `node1` -> `node2` that might
10371054
* be cross function boundaries.
10381055
*/
10391056
private predicate valuePreservingStep(Node node1, Node node2) {
10401057
node1.getASuccessor() = node2 and
10411058
not isBlockedLegacyNode(node1) and
1042-
not isBlockedLegacyNode(node2)
1059+
not isBlockedLegacyNode(node2) and
1060+
not isThisNodeTrackedByVariableCapture(node1)
10431061
or
10441062
FlowSteps::propertyFlowStep(node1, node2)
10451063
or

0 commit comments

Comments
 (0)