mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
Python: small test of local flow
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
*
|
||||
* To use global (interprocedural) data flow, extend the class
|
||||
* `DataFlow::Configuration` as documented on that class. To use local
|
||||
* (intraprocedural) data flow, call `DataFlow::localFlowStep*` with
|
||||
* arguments of type `DataFlow::Node`.
|
||||
* (intraprocedural) data flow, call `DataFlow::localFlow` or
|
||||
* `DataFlow::localFlowStep` with arguments of type `DataFlow::Node`.
|
||||
*/
|
||||
|
||||
import python
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
*
|
||||
* To use global (interprocedural) data flow, extend the class
|
||||
* `DataFlow::Configuration` as documented on that class. To use local
|
||||
* (intraprocedural) data flow, call `DataFlow::localFlowStep*` with
|
||||
* arguments of type `DataFlow::Node`.
|
||||
* (intraprocedural) data flow, call `DataFlow::localFlow` or
|
||||
* `DataFlow::localFlowStep` with arguments of type `DataFlow::Node`.
|
||||
*/
|
||||
|
||||
import python
|
||||
|
||||
@@ -8,4 +8,5 @@ module Private {
|
||||
|
||||
module Public {
|
||||
import DataFlowPublic
|
||||
import DataFlowUtil
|
||||
}
|
||||
|
||||
@@ -42,13 +42,15 @@ abstract class PostUpdateNode extends Node {
|
||||
abstract Node getPreUpdateNode();
|
||||
}
|
||||
|
||||
private newtype TReturnKind = TNormalReturnKind()
|
||||
|
||||
/**
|
||||
* A return kind. A return kind describes how a value can be returned
|
||||
* from a callable.
|
||||
* from a callable. For Python, this is simply a method return.
|
||||
*/
|
||||
abstract class ReturnKind extends string {
|
||||
/** Gets a textual representation of this position. */
|
||||
ReturnKind() { this = "ReturnKind" }
|
||||
class ReturnKind extends TReturnKind {
|
||||
/** Gets a textual representation of this return kind. */
|
||||
string toString() { result = "return" }
|
||||
}
|
||||
|
||||
/** A data flow node that represents a value returned by a callable. */
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Contains utility functions for writing data flow queries
|
||||
*/
|
||||
|
||||
import DataFlowPrivate
|
||||
import DataFlowPublic
|
||||
|
||||
/**
|
||||
* Holds if data flows from `nodeFrom` to `nodeTo` in exactly one local
|
||||
* (intra-procedural) step.
|
||||
*/
|
||||
predicate localFlowStep(Node nodeFrom, Node nodeTo) { simpleLocalFlowStep(nodeFrom, nodeTo) }
|
||||
|
||||
/**
|
||||
* Holds if data flows from `source` to `sink` in zero or more local
|
||||
* (intra-procedural) steps.
|
||||
*/
|
||||
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
|
||||
Reference in New Issue
Block a user