Skip to content

Commit 39e2d14

Browse files
committed
JS: Default to imprecision zero by default
1 parent 8aa34e6 commit 39e2d14

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ module DataFlow {
122122
CallGraph::getAFunctionReference(result, 0).flowsTo(this)
123123
}
124124

125+
/** Gets a function value that may reach this node with the given `imprecision` level. */
126+
final FunctionNode getAFunctionValue(int imprecision) {
127+
CallGraph::getAFunctionReference(result, imprecision).flowsTo(this)
128+
}
129+
125130
/**
126131
* Gets a function value that may reach this node,
127132
* possibly derived from a partial function invocation.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,16 @@ class InvokeNode extends DataFlow::SourceNode {
147147
* To alter the call graph as seen by the interprocedural data flow libraries, override
148148
* the `getACallee(int imprecision)` predicate instead.
149149
*/
150-
final Function getACallee() { result = getACallee(_) }
150+
final Function getACallee() { result = getACallee(0) }
151151

152152
/**
153153
* Gets a callee of this call site where `imprecision` is a heuristic measure of how
154154
* likely it is that `callee` is only suggested as a potential callee due to
155155
* imprecise analysis of global variables and is not, in fact, a viable callee at all.
156156
*
157157
* Callees with imprecision zero, in particular, have either been derived without
158-
* considering global variables, or are calls to a global variable within the same file.
158+
* considering global variables, or are calls to a global variable within the same file,
159+
* or a global variable that has unique definition within the project.
159160
*
160161
* This predicate can be overridden to alter the call graph used by the interprocedural
161162
* data flow libraries.

0 commit comments

Comments
 (0)