From 221d94961a0ebc8fc533ace3380b047fbddab3f7 Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 1 Aug 2019 13:43:31 +0100 Subject: [PATCH] JS: Resolve simple calls based on qualified name --- javascript/ql/src/semmle/javascript/Closure.qll | 14 -------------- .../javascript/dataflow/internal/FlowSteps.qll | 8 ++++++++ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/javascript/ql/src/semmle/javascript/Closure.qll b/javascript/ql/src/semmle/javascript/Closure.qll index 82df218e577..b7ce833f893 100644 --- a/javascript/ql/src/semmle/javascript/Closure.qll +++ b/javascript/ql/src/semmle/javascript/Closure.qll @@ -244,18 +244,4 @@ module Closure { DataFlow::SourceNode moduleImport(string moduleName) { getClosureNamespaceFromSourceNode(result) = moduleName } - - private class ClosureNamespaceCall extends DataFlow::InvokeNode { - override Function getACallee(int imprecision) { - result = super.getACallee(imprecision) - or - imprecision = 0 and - exists(string name | - GlobalAccessPath::isAssignedInUniqueFile(name) and - GlobalAccessPath::fromRhs(result.flow()) = name and - GlobalAccessPath::fromReference(getCalleeNode()) = name and - not result.getTopLevel().isExterns() - ) - } - } } diff --git a/javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll b/javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll index 07f3d32c4b7..ce5baef6325 100644 --- a/javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll +++ b/javascript/ql/src/semmle/javascript/dataflow/internal/FlowSteps.qll @@ -127,6 +127,14 @@ private module CachedSteps { invk = cls.getAClassReference().getAMethodCall(name) and f = cls.getStaticMethod(name).getFunction() ) + or + // Call from `foo.bar.baz()` to `foo.bar.baz = function()` + not f.getTopLevel().isExterns() and + exists(string name | + GlobalAccessPath::isAssignedInUniqueFile(name) and + GlobalAccessPath::fromRhs(f.flow()) = name and + GlobalAccessPath::fromReference(invk.getCalleeNode()) = name + ) } /**