CodeQL library for JavaScript

Predicate DataFlow::functionOneWayForwardingStep

Holds if the function in succ forwards all its arguments to a call to pred. This can thus be seen as a step pred -> succ used for tracking function values through “wrapper functions”, since the succ function partially replicates behavior of pred.

This is similar to functionForwardingStep except the innermost forwarding call does not need flow to the return value; this can be useful for tracking callback-style functions where the result tends to be unused.


function f(x, callback) {
  g(x, callback); // step: g -> f

function doExec(x, callback) {
  exec(x, callback); // step: exec -> doExec

function doEither(x, y) {
  if (x > y) {
    return foo(x, y); // step: foo -> doEither
  } else {
    return bar(x, y); // step: bar -> doEither

function wrapWithLogging(f) {
  return (x) => {
    return f(x); // step: f -> anonymous function
wrapWithLogging(g); // step: g -> wrapWithLogging(g)

Import path

import javascript
predicate functionOneWayForwardingStep(Node pred, Node succ)