Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf8462f

Browse files
committed
Python: Simplify chained configs
1 parent f87845b commit cf8462f

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

python/ql/src/experimental/Security-new-dataflow/CWE-022/ChainedConfigs12.qll

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,33 @@ import experimental.dataflow.TaintTracking
1212
import experimental.dataflow.TaintTracking2
1313

1414
/**
15-
* A `ControlFlowNode` that appears as a sink in Config1 and a source in Config2.
15+
* A `DataFlow::Node` that appears as a sink in Config1 and a source in Config2.
1616
*/
17-
private predicate crossoverNode(ControlFlowNode n) {
18-
exists(DataFlow::Node n1, DataFlow2::Node n2 |
19-
any(TaintTracking::Configuration t1).isSink(n1) and
20-
any(TaintTracking2::Configuration t2).isSource(n2) and
21-
n = n1.asCfgNode() and
22-
n = n2.asCfgNode()
23-
)
17+
private predicate crossoverNode(DataFlow::Node n) {
18+
any(TaintTracking::Configuration t1).isSink(n) and
19+
any(TaintTracking2::Configuration t2).isSource(n)
2420
}
2521

2622
/**
2723
* A new type which represents the union of the two sets of nodes.
2824
*/
2925
private newtype TCustomPathNode =
30-
Config1Node(DataFlow::PathNode node1) { not crossoverNode(node1.getNode().asCfgNode()) } or
31-
Config2Node(DataFlow2::PathNode node1) { not crossoverNode(node1.getNode().asCfgNode()) } or
32-
CrossoverNode(ControlFlowNode e) { crossoverNode(e) }
26+
Config1Node(DataFlow::PathNode node1) { not crossoverNode(node1.getNode()) } or
27+
Config2Node(DataFlow2::PathNode node1) { not crossoverNode(node1.getNode()) } or
28+
CrossoverNode(DataFlow::Node e) { crossoverNode(e) }
3329

3430
/**
3531
* A class representing the set of all the path nodes in either config.
3632
*/
3733
class CustomPathNode extends TCustomPathNode {
3834
/** Gets the PathNode if it is in Config1. */
3935
DataFlow::PathNode asNode1() {
40-
this = Config1Node(result) or this = CrossoverNode(result.getNode().asCfgNode())
36+
this = Config1Node(result) or this = CrossoverNode(result.getNode())
4137
}
4238

4339
/** Gets the PathNode if it is in Config2. */
4440
DataFlow2::PathNode asNode2() {
45-
this = Config2Node(result) or this = CrossoverNode(result.getNode().asCfgNode())
41+
this = Config2Node(result) or this = CrossoverNode(result.getNode())
4642
}
4743

4844
predicate hasLocationInfo(

0 commit comments

Comments
 (0)