mirror of
https://github.com/github/codeql.git
synced 2026-04-19 05:54:00 +02:00
JS: Add legacy post-update step
This is to ensure getALocalSource() can be replaced by getPostUpdateNode() as the base of a store
This commit is contained in:
@@ -30,6 +30,20 @@ predicate returnExpr(Function f, DataFlow::Node source, DataFlow::Node sink) {
|
||||
not f = any(SetterMethodDeclaration decl).getBody()
|
||||
}
|
||||
|
||||
/**
|
||||
* A step from a post-update node to the local sources of the corresponding pre-update node.
|
||||
*
|
||||
* This ensures that `getPostUpdateNode()` can be used in place of `getALocalSource()` when generating
|
||||
* store steps, and the resulting step will work in both data flow analyses.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
private predicate legacyPostUpdateStep(DataFlow::Node pred, DataFlow::Node succ) {
|
||||
exists(DataFlow::Node node |
|
||||
pred = node.getPostUpdateNode() and
|
||||
succ = node.getALocalSource()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if data can flow in one step from `pred` to `succ`, taking
|
||||
* additional steps from the configuration into account.
|
||||
@@ -41,6 +55,8 @@ predicate localFlowStep(
|
||||
) {
|
||||
pred = succ.getAPredecessor() and predlbl = succlbl
|
||||
or
|
||||
legacyPostUpdateStep(pred, succ) and predlbl = succlbl
|
||||
or
|
||||
DataFlow::LegacyFlowStep::step(pred, succ) and predlbl = succlbl
|
||||
or
|
||||
DataFlow::LegacyFlowStep::step(pred, succ, predlbl, succlbl)
|
||||
|
||||
Reference in New Issue
Block a user