You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because the dataflow node representing the sink (the call to fopen) is not an expression node, and so getNode().asExpr() is undefined.
As the documentation for asExpr says:
/**
* Gets the non-conversion expression corresponding to this node, if any.
* This predicate only has a result on nodes that represent the value of
* evaluating the expression. For data flowing _out of_ an expression, like
* when an argument is passed by reference, use `asDefiningArgument` instead
* of `asExpr`.
*
* If this node strictly (in the sense of `asConvertedExpr`) corresponds to
* a `Conversion`, then the result is the underlying non-`Conversion` base
* expression.
*/
So this is a node kind where asExpr is not defined but asDefiningArgument is defined. However in the context of the first column of a path-query, the only purpose is to specify an alert location, so it's better to just select the node: replace select sink.getNode().asExpr() with select sink.getNode() and everything works as you might hope.
Some other comments while I'm here:
I had to remove #include <malloc.h> from your sample code to compile it -- this is a nonstandard header; for malloc just import stdlib.h.
The lines isFlowSource(source.getNode(), _) and openSink(sink.getNode()) next to Flow::flowPath(source, sink) are redundant: that there is a flow path implies that the two ends of the path are a source and a sink respectively. They can be deleted.
from definitions Expr getenv, Expr fopen are unused and can be deleted.
test code:
fopen-flow-from-getenv.ql:
The text was updated successfully, but these errors were encountered: