mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Dataflow: Reduce duplication, define PathGraphSig only once.
This commit is contained in:
@@ -562,6 +562,30 @@ module Configs<LocationSig Location, InputSig<Location> Lang> {
|
||||
}
|
||||
}
|
||||
|
||||
/** A type with `toString`. */
|
||||
private signature class TypeWithToString {
|
||||
string toString();
|
||||
}
|
||||
|
||||
import PathGraphSigMod
|
||||
|
||||
private module PathGraphSigMod {
|
||||
signature module PathGraphSig<TypeWithToString PathNode> {
|
||||
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
|
||||
predicate edges(PathNode a, PathNode b, string key, string val);
|
||||
|
||||
/** Holds if `n` is a node in the graph of data flow path explanations. */
|
||||
predicate nodes(PathNode n, string key, string val);
|
||||
|
||||
/**
|
||||
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
|
||||
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
|
||||
* `ret -> out` is summarized as the edge `arg -> out`.
|
||||
*/
|
||||
predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out);
|
||||
}
|
||||
}
|
||||
|
||||
module DataFlowMake<LocationSig Location, InputSig<Location> Lang> {
|
||||
private import Lang
|
||||
private import internal.DataFlowImpl::MakeImpl<Location, Lang>
|
||||
@@ -663,20 +687,7 @@ module DataFlowMake<LocationSig Location, InputSig<Location> Lang> {
|
||||
Location getLocation();
|
||||
}
|
||||
|
||||
signature module PathGraphSig<PathNodeSig PathNode> {
|
||||
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
|
||||
predicate edges(PathNode a, PathNode b, string key, string val);
|
||||
|
||||
/** Holds if `n` is a node in the graph of data flow path explanations. */
|
||||
predicate nodes(PathNode n, string key, string val);
|
||||
|
||||
/**
|
||||
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
|
||||
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
|
||||
* `ret -> out` is summarized as the edge `arg -> out`.
|
||||
*/
|
||||
predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out);
|
||||
}
|
||||
import PathGraphSigMod
|
||||
|
||||
/**
|
||||
* Constructs a `PathGraph` from two `PathGraph`s by disjoint union.
|
||||
|
||||
@@ -4291,12 +4291,10 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
|
||||
final predicate isSinkGroup(string group) { this = TPathNodeSinkGroup(group) }
|
||||
}
|
||||
|
||||
private import codeql.dataflow.test.ProvenancePathGraph as ProvenancePathGraph
|
||||
|
||||
/**
|
||||
* Provides the query predicates needed to include a graph in a path-problem query.
|
||||
*/
|
||||
module PathGraph implements PathGraphSig<PathNode>, ProvenancePathGraph::PathGraphSig<PathNode> {
|
||||
module PathGraph implements PathGraphSig<PathNode> {
|
||||
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
|
||||
query predicate edges(PathNode a, PathNode b, string key, string val) {
|
||||
a.(PathNodeImpl).getANonHiddenSuccessor(val) = b and
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
* In addition to the `PathGraph`, a `query predicate models` is provided to
|
||||
* list the contents of the referenced MaD rows.
|
||||
*/
|
||||
module;
|
||||
|
||||
private import codeql.dataflow.DataFlow as DF
|
||||
|
||||
signature predicate interpretModelForTestSig(QlBuiltins::ExtensionId madId, string model);
|
||||
|
||||
@@ -15,21 +16,6 @@ signature class PathNodeSig {
|
||||
string toString();
|
||||
}
|
||||
|
||||
signature module PathGraphSig<PathNodeSig PathNode> {
|
||||
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
|
||||
predicate edges(PathNode a, PathNode b, string key, string val);
|
||||
|
||||
/** Holds if `n` is a node in the graph of data flow path explanations. */
|
||||
predicate nodes(PathNode n, string key, string val);
|
||||
|
||||
/**
|
||||
* Holds if `(arg, par, ret, out)` forms a subpath-tuple, that is, flow through
|
||||
* a subpath between `par` and `ret` with the connecting edges `arg -> par` and
|
||||
* `ret -> out` is summarized as the edge `arg -> out`.
|
||||
*/
|
||||
predicate subpaths(PathNode arg, PathNode par, PathNode ret, PathNode out);
|
||||
}
|
||||
|
||||
private signature predicate provenanceSig(string model);
|
||||
|
||||
private module TranslateModels<
|
||||
@@ -79,7 +65,7 @@ private module TranslateModels<
|
||||
/** Transforms a `PathGraph` by printing the provenance information. */
|
||||
module ShowProvenance<
|
||||
interpretModelForTestSig/2 interpretModelForTest, PathNodeSig PathNode,
|
||||
PathGraphSig<PathNode> PathGraph>
|
||||
DF::PathGraphSig<PathNode> PathGraph>
|
||||
{
|
||||
private predicate provenance(string model) { PathGraph::edges(_, _, _, model) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user