Skip to content

Commit 3ca6031

Browse files
committed
JS: rename predicate
1 parent 75451e3 commit 3ca6031

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module AccessPath {
6060
not this instanceof PropertyProjection and
6161
not this instanceof Closure::ClosureNamespaceAccess and
6262
not this = DataFlow::parameterNode(any(ImmediatelyInvokedFunctionExpr iife).getAParameter()) and
63-
not this = FlowSteps::IdentityCalls::syntactic(_)
63+
not FlowSteps::identityFunctionStep(_, this)
6464
}
6565

6666
/** Holds if this represents the root of the global access path. */

javascript/ql/src/semmle/javascript/dataflow/DataFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ module DataFlow {
199199
not fun.getExit().isJoin() // can only reach exit by the return statement
200200
)
201201
or
202-
this = FlowSteps::IdentityCalls::syntactic(result)
202+
FlowSteps::identityFunctionStep(result, this)
203203
}
204204

205205
/**

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,18 @@ private module CachedSteps {
404404
predicate receiverPropWrite(Function f, string prop, DataFlow::Node rhs) {
405405
DataFlow::thisNode(f).hasPropertyWrite(prop, rhs)
406406
}
407+
408+
/**
409+
* A step from `pred` to `succ` through a call to an identity function.
410+
*/
411+
cached
412+
predicate identityFunctionStep(DataFlow::Node pred, DataFlow::CallNode succ) {
413+
exists(DataFlow::GlobalVarRefNode global |
414+
global.getName() = "Object" and
415+
succ.(DataFlow::MethodCallNode).calls(global, ["freeze", "seal"]) and
416+
pred = succ.getArgument(0)
417+
)
418+
}
407419
}
408420

409421
import CachedSteps
@@ -529,19 +541,3 @@ module PathSummary {
529541
*/
530542
PathSummary return() { exists(FlowLabel lbl | result = MkPathSummary(true, false, lbl, lbl)) }
531543
}
532-
533-
/**
534-
* Provides predicates for reasoning about calls to identity functions.
535-
*/
536-
module IdentityCalls {
537-
/**
538-
* Gets an identity call for `input` that can be recognized syntactically.
539-
*/
540-
DataFlow::CallNode syntactic(DataFlow::Node input) {
541-
exists(DataFlow::GlobalVarRefNode global |
542-
global.getName() = "Object" and
543-
result.(DataFlow::MethodCallNode).calls(global, ["freeze", "seal"]) and
544-
input = result.getArgument(0)
545-
)
546-
}
547-
}

0 commit comments

Comments
 (0)