Merge pull request #17787 from yoff/shared/add-location-to-typetracking-nodes

shared: Add locations to type tracking nodes
This commit is contained in:
yoff
2025-01-13 23:06:09 +01:00
committed by GitHub
8 changed files with 22 additions and 14 deletions

View File

@@ -334,7 +334,7 @@ private module TrackLambda<methodDispatchSig/1 lambdaDispatch0> {
)
}
private module TtInput implements TypeTrackingInput {
private module TtInput implements TypeTrackingInput<Location> {
import TypeTrackingSteps
predicate callStep(Node n1, LocalSourceNode n2) { argParamCand(n1, n2) }
@@ -348,7 +348,7 @@ private module TrackLambda<methodDispatchSig/1 lambdaDispatch0> {
}
}
private import TypeTracking<TtInput>::TypeTrack<lambdaSource/1>::Graph<lambdaSink/1>
private import TypeTracking<Location, TtInput>::TypeTrack<lambdaSource/1>::Graph<lambdaSink/1>
private predicate edgePlus(PathNode n1, PathNode n2) = fastTC(edges/2)(n1, n2)

View File

@@ -4,7 +4,8 @@
*/
private import internal.TypeTrackingImpl as Impl
import Impl::Shared::TypeTracking<Impl::TypeTrackingInput>
private import semmle.python.Files
import Impl::Shared::TypeTracking<Location, Impl::TypeTrackingInput>
private import semmle.python.dataflow.new.internal.DataFlowPublic as DataFlowPublic
/**

View File

@@ -106,7 +106,7 @@ private module SummaryTypeTrackerInput implements SummaryTypeTracker::Input {
private module TypeTrackerSummaryFlow = SummaryTypeTracker::SummaryFlow<SummaryTypeTrackerInput>;
module TypeTrackingInput implements Shared::TypeTrackingInput {
module TypeTrackingInput implements Shared::TypeTrackingInput<Location> {
class Node = DataFlowPublic::Node;
class LocalSourceNode = DataFlowPublic::LocalSourceNode;
@@ -323,4 +323,4 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
predicate nonStandardFlowsTo(LocalSourceNode localSource, Node dst) { localSource.flowsTo(dst) }
}
import SharedImpl::TypeTracking<TypeTrackingInput>
import SharedImpl::TypeTracking<Location, TypeTrackingInput>

View File

@@ -3,5 +3,6 @@
* for tracking types.
*/
private import codeql.ruby.AST
private import codeql.ruby.typetracking.internal.TypeTrackingImpl as Impl
import Impl::Shared::TypeTracking<Impl::TypeTrackingInput>
import Impl::Shared::TypeTracking<Location, Impl::TypeTrackingInput>

View File

@@ -265,7 +265,7 @@ private module TypeTrackerSummaryFlow = SummaryTypeTracker::SummaryFlow<SummaryT
private newtype TContentFilter = MkElementFilter()
module TypeTrackingInput implements Shared::TypeTrackingInput {
module TypeTrackingInput implements Shared::TypeTrackingInput<Location> {
class Node = DataFlowPublic::Node;
class LocalSourceNode = DataFlowPublic::LocalSourceNode;
@@ -467,4 +467,4 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
predicate hasFeatureBacktrackStoreTarget() { none() }
}
import SharedImpl::TypeTracking<TypeTrackingInput>
import SharedImpl::TypeTracking<Location, TypeTrackingInput>

View File

@@ -80,7 +80,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
}
}
private module TypeTrackingInput implements Tt::TypeTrackingInput {
private module TypeTrackingInput implements Tt::TypeTrackingInput<Location> {
final class Node = Lang::Node;
class LocalSourceNode extends Node {
@@ -145,7 +145,7 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> {
predicate hasFeatureBacktrackStoreTarget() { none() }
}
private module TypeTracking = Tt::TypeTracking<TypeTrackingInput>;
private module TypeTracking = Tt::TypeTracking<Location, TypeTrackingInput>;
/**
* The cost limits for the `AccessPathFront` to `AccessPathApprox` expansion.

View File

@@ -3,14 +3,19 @@
* for tracking types.
*/
private import codeql.util.Location
/**
* The step relations for type tracking.
*/
signature module TypeTrackingInput {
signature module TypeTrackingInput<LocationSig Location> {
/** A node that is used by the type-trackers. */
class Node {
/** Gets a textual representation of this node. */
string toString();
/** Gets the source location of this node. */
Location getLocation();
}
/**
@@ -127,8 +132,8 @@ private import internal.TypeTrackingImpl as Impl
* Given a set of step relations, this module provides classes and predicates
* for simple data-flow reachability suitable for tracking types.
*/
module TypeTracking<TypeTrackingInput I> {
private module MkImpl = Impl::TypeTracking<I>;
module TypeTracking<LocationSig Location, TypeTrackingInput<Location> I> {
private module MkImpl = Impl::TypeTracking<Location, I>;
private module ConsistencyChecksInput implements MkImpl::ConsistencyChecksInputSig { }

View File

@@ -6,6 +6,7 @@
private import codeql.util.Boolean
private import codeql.util.Option
private import codeql.typetracking.TypeTracking
private import codeql.util.Location
/**
* Given a set of step relations, this module provides classes and predicates
@@ -14,7 +15,7 @@ private import codeql.typetracking.TypeTracking
* The constructed module contains both public and internal logic; the public
* interface is exposed via `codeql.typetracking.TypeTracking`.
*/
module TypeTracking<TypeTrackingInput I> {
module TypeTracking<LocationSig Location, TypeTrackingInput<Location> I> {
private import I
signature module ConsistencyChecksInputSig {