Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared: Add locations to typet racking nodes #17787

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion python/ql/lib/semmle/python/dataflow/new/TypeTracking.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -318,9 +318,9 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
capturedJumpStep(nodeFrom, nodeTo)
}

predicate hasFeatureBacktrackStoreTarget() { any() }
predicate hasFeatureBacktrackStoreTarget() { none() }
yoff marked this conversation as resolved.
Show resolved Hide resolved

predicate nonStandardFlowsTo(LocalSourceNode localSource, Node dst) { localSource.flowsTo(dst) }
}

import SharedImpl::TypeTracking<TypeTrackingInput>
import SharedImpl::TypeTracking<Location, TypeTrackingInput>
3 changes: 2 additions & 1 deletion ruby/ql/lib/codeql/ruby/typetracking/TypeTracking.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -467,4 +467,4 @@ module TypeTrackingInput implements Shared::TypeTrackingInput {
predicate hasFeatureBacktrackStoreTarget() { none() }
}

import SharedImpl::TypeTracking<TypeTrackingInput>
import SharedImpl::TypeTracking<Location, TypeTrackingInput>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions shared/typetracking/codeql/typetracking/TypeTracking.qll
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
* 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();

Location getLocation();
}

/**
Expand Down Expand Up @@ -127,8 +131,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 { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
Loading