Skip to content

Commit 49d4b14

Browse files
committed
python: Do not remove ChainedConfigs12.qll
since it was clearly already used. Add deprecation message instead.
1 parent 35c9307 commit 49d4b14

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* DEPRECATED -- use flow state instead
3+
*
4+
* This defines a `PathGraph` where sinks from `TaintTracking::Configuration`s are identified with
5+
* sources from `TaintTracking2::Configuration`s if they represent the same `ControlFlowNode`.
6+
*
7+
* Paths are then connected appropriately.
8+
*/
9+
10+
import python
11+
import semmle.python.dataflow.new.DataFlow
12+
import semmle.python.dataflow.new.DataFlow2
13+
import semmle.python.dataflow.new.TaintTracking
14+
import semmle.python.dataflow.new.TaintTracking2
15+
16+
/**
17+
* A `DataFlow::Node` that appears as a sink in Config1 and a source in Config2.
18+
*/
19+
private predicate crossoverNode(DataFlow::Node n) {
20+
any(TaintTracking::Configuration t1).isSink(n) and
21+
any(TaintTracking2::Configuration t2).isSource(n)
22+
}
23+
24+
/**
25+
* A new type which represents the union of the two sets of nodes.
26+
*/
27+
private newtype TCustomPathNode =
28+
Config1Node(DataFlow::PathNode node1) { not crossoverNode(node1.getNode()) } or
29+
Config2Node(DataFlow2::PathNode node2) { not crossoverNode(node2.getNode()) } or
30+
CrossoverNode(DataFlow::Node node) { crossoverNode(node) }
31+
32+
/**
33+
* A class representing the set of all the path nodes in either config.
34+
*/
35+
class CustomPathNode extends TCustomPathNode {
36+
/** Gets the PathNode if it is in Config1. */
37+
DataFlow::PathNode asNode1() {
38+
this = Config1Node(result) or this = CrossoverNode(result.getNode())
39+
}
40+
41+
/** Gets the PathNode if it is in Config2. */
42+
DataFlow2::PathNode asNode2() {
43+
this = Config2Node(result) or this = CrossoverNode(result.getNode())
44+
}
45+
46+
/**
47+
* Holds if this element is at the specified location.
48+
* The location spans column `startcolumn` of line `startline` to
49+
* column `endcolumn` of line `endline` in file `filepath`.
50+
* For more information, see
51+
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
52+
*/
53+
predicate hasLocationInfo(
54+
string filepath, int startline, int startcolumn, int endline, int endcolumn
55+
) {
56+
asNode1().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
57+
or
58+
asNode2().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
59+
}
60+
61+
/** Gets a textual representation of this element. */
62+
string toString() {
63+
result = asNode1().toString()
64+
or
65+
result = asNode2().toString()
66+
}
67+
}
68+
69+
/** Holds if `(a,b)` is an edge in the graph of data flow path explanations. */
70+
query predicate edges(CustomPathNode a, CustomPathNode b) {
71+
// Edge is in Config1 graph
72+
DataFlow::PathGraph::edges(a.asNode1(), b.asNode1())
73+
or
74+
// Edge is in Config2 graph
75+
DataFlow2::PathGraph::edges(a.asNode2(), b.asNode2())
76+
}
77+
78+
/** Holds if `n` is a node in the graph of data flow path explanations. */
79+
query predicate nodes(CustomPathNode n, string key, string val) {
80+
// Node is in Config1 graph
81+
DataFlow::PathGraph::nodes(n.asNode1(), key, val)
82+
or
83+
// Node is in Config2 graph
84+
DataFlow2::PathGraph::nodes(n.asNode2(), key, val)
85+
}

0 commit comments

Comments
 (0)