Skip to content

noob question, difference between DataFlow::Node and DataFlow::PathNode #138

Answered
74d ago
· 3 replies
Copy link

@hMihaiDavid hMihaiDavid

That basically,
what's the difference between DataFlow::Node and DataFlow::PathNode when analyzing data flow.

Thanks.

Replies

Have a look at https://help.semmle.com/QL/learn-ql/writing-queries/path-queries.html
TLDR: DataFlow::PathNodes are used when you use path queries.
Path queries allow you to see how taint flows (step-by-step) from node to node until it reaches the sink.
While in non path queries you would use DataFlow::Node and only get the node that represents the source and the sink, without any of the intermediate nodes.

@hMihaiDavid

Thanks.

Answer selected by jbj

@aschackmull aschackmull
Collaborator

The answer above is a great TL;DR, for the slightly longer explanation, read on:
When building a query, modelling something, thinking about data flow, etc. you'll want to use DataFlow::Node. In general these corresponds to all the parts of the code that can carry a value and therefore make up the nodes in a simple data-flow graph. When using data flow you'll e.g. need to specify sources and sinks as certain DataFlow::Nodes. DataFlow::PathNodes are not themselves directly useable for anything, but rather generated as an output of the data-flow library. When writing a path query the data-flow library will deliver the results in the form of a hasFlowPath(DataFlow::PathNode source, DataFlow::PathNode sink) predicate and a resulting graph that's used to build the paths in the form of import DataFlow::PathGraph. The reason that the library will give this output in terms of a different type is that PathNodes encode more information than just the Node (e.g. call contexts) in order to (among other things) match up call sites and returns properly in the generated PathGraph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
Beta
You can’t perform that action at this time.