JS: Update use of Locations

This commit is contained in:
Asger F
2024-05-06 10:11:49 +02:00
parent 2de9af2236
commit 19f14622f3
8 changed files with 21 additions and 44 deletions

View File

@@ -1056,11 +1056,7 @@ module DataFlow {
override StmtContainer getContainer() { result = expr.getContainer() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
expr.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = expr.getLocation() }
}
/**
@@ -1075,13 +1071,7 @@ module DataFlow {
override StmtContainer getContainer() { result = constructor }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
constructor
.getLocation()
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = constructor.getLocation() }
}
/**
@@ -1403,11 +1393,7 @@ module DataFlow {
override string toString() { result = "[function self-reference] " + function.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
function.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = function.getLocation() }
}
/**
@@ -1423,11 +1409,7 @@ module DataFlow {
override StmtContainer getContainer() { result = expr.getContainer() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
expr.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = expr.getLocation() }
override string toString() { result = "[post update] " + expr.toString() }
}

View File

@@ -59,12 +59,6 @@ class CaptureNode extends DataFlow::Node, TSynthCaptureNode {
cached
private Location getLocation() { result = this.getNode().getLocation() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}
class GenericSynthesizedNode extends DataFlow::Node, TGenericSynthesizedNode {
@@ -78,11 +72,7 @@ class GenericSynthesizedNode extends DataFlow::Node, TGenericSynthesizedNode {
override string toString() { result = "[synthetic node] " + tag }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
node.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = node.getLocation() }
string getTag() { result = tag }
}

View File

@@ -3,7 +3,7 @@ private import semmle.javascript.dataflow.internal.DataFlowNode
private import codeql.dataflow.VariableCapture
private import semmle.javascript.dataflow.internal.sharedlib.DataFlowImplCommon as DataFlowImplCommon
module VariableCaptureConfig implements InputSig<js::Location> {
module VariableCaptureConfig implements InputSig<js::DbLocation> {
private js::Function getLambdaFromVariable(js::LocalVariable variable) {
result.getVariable() = variable
or
@@ -185,7 +185,7 @@ module VariableCaptureConfig implements InputSig<js::Location> {
string toString() { none() } // Overridden in subclass
js::Location getLocation() { none() } // Overridden in subclass
js::DbLocation getLocation() { none() } // Overridden in subclass
predicate hasCfgNode(BasicBlock bb, int i) { none() } // Overridden in subclass
@@ -203,7 +203,7 @@ module VariableCaptureConfig implements InputSig<js::Location> {
override string toString() { result = pattern.toString() }
/** Gets the location of this write. */
override js::Location getLocation() { result = pattern.getLocation() }
override js::DbLocation getLocation() { result = pattern.getLocation() }
override js::DataFlow::Node getSource() {
// Note: there is not always an expression corresponding to the RHS of the assignment.
@@ -239,7 +239,7 @@ module VariableCaptureConfig implements InputSig<js::Location> {
override string toString() { result = "[implicit init] " + variable }
override js::Location getLocation() { result = variable.getLocation() }
override js::DbLocation getLocation() { result = variable.getLocation() }
override CapturedVariable getVariable() { result = variable }
@@ -259,7 +259,7 @@ module VariableCaptureConfig implements InputSig<js::Location> {
predicate exitBlock(BasicBlock bb) { bb.getLastNode() instanceof js::ControlFlowExitNode }
}
module VariableCaptureOutput = Flow<js::Location, VariableCaptureConfig>;
module VariableCaptureOutput = Flow<js::DbLocation, VariableCaptureConfig>;
js::DataFlow::Node getNodeFromClosureNode(VariableCaptureOutput::ClosureNode node) {
result = TValueNode(node.(VariableCaptureOutput::ExprNode).getExpr())

View File

@@ -1,4 +1,5 @@
private import semmle.javascript.Locations
private import codeql.dataflow.DataFlow
private import DataFlowArg
import DataFlowMake<JSDataFlow>
import DataFlowMake<Location, JSDataFlow>
import DataFlowImplSpecific::Public

View File

@@ -1,8 +1,9 @@
private import semmle.javascript.Locations
private import DataFlowImplSpecific
private import codeql.dataflow.DataFlow as SharedDataFlow
private import codeql.dataflow.TaintTracking as SharedTaintTracking
module JSDataFlow implements SharedDataFlow::InputSig {
module JSDataFlow implements SharedDataFlow::InputSig<Location> {
import Private
import Public
@@ -16,6 +17,6 @@ module JSDataFlow implements SharedDataFlow::InputSig {
predicate viableImplInCallContext = Private::viableImplInCallContext/2;
}
module JSTaintFlow implements SharedTaintTracking::InputSig<JSDataFlow> {
module JSTaintFlow implements SharedTaintTracking::InputSig<Location, JSDataFlow> {
import semmle.javascript.dataflow.internal.TaintTrackingPrivate
}

View File

@@ -1,3 +1,4 @@
private import semmle.javascript.Locations
private import codeql.dataflow.internal.DataFlowImpl
private import DataFlowArg
import MakeImpl<JSDataFlow>
import MakeImpl<Location, JSDataFlow>

View File

@@ -1,3 +1,4 @@
private import semmle.javascript.Locations
private import DataFlowArg
private import codeql.dataflow.internal.DataFlowImplCommon
import MakeImplCommon<JSDataFlow>
import MakeImplCommon<Location, JSDataFlow>

View File

@@ -1,3 +1,4 @@
private import semmle.javascript.Locations
private import codeql.dataflow.TaintTracking
private import DataFlowArg
import TaintFlowMake<JSDataFlow, JSTaintFlow>
import TaintFlowMake<Location, JSDataFlow, JSTaintFlow>