[JS] Mapping DataFlow::Node
to PrintAstNode
#8379
-
I am trying to build a data-structure combining information from both ASTs and Now I want to map the
codeql/javascript/ql/lib/semmle/javascript/PrintAst.qll Lines 160 to 171 in d3da790 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
As the libraries are right now you can't map from a But I don't see why you would use I also don't see the need for a data-structure that contains both newtype TMyAst =
TMyAstNode(ASTNode node) or
TMyDataFlowNode(DataFlow::Node node)
class MyAst extends TMyAst { .. }
class MyAstNode extends MyAst, TMyAstNode {...}
class MyDataFlowNode extends MyAst, TMyDataFlowNode {...} |
Beta Was this translation helpful? Give feedback.
-
I think of it as a different view of the same data.
That sounds like an OK solution.
There's a feature of the VSCode extension that I think you might find interesting (if you don't know it already). /**
* @name Unsafe dynamic method access
* @kind problem
* @id js/unsafe-dynamic-method-access
*/
import javascript
import semmle.javascript.security.dataflow.UnsafeDynamicMethodAccessQuery
import DataFlow::PathGraph as PathGraph // <- the `query predicate` must not be in the global scope, otherwise a `@kind problem` query errors out.
from Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, DataFlow::PathNode node
where cfg.hasFlowPath(source, sink) and PathGraph::nodes(node)
select node, "Is a node from a source to a sink" |
Beta Was this translation helpful? Give feedback.
I think of it as a different view of the same data.
The
TJSXAttributesNode
and theTJSXBodyElementsNode
classes just makes sure we have 2 print-nodes for some expressions.An
JSXElement
instance (an expression) is represented both by theJSXNodeNode
andJSXAttributesNode
classes inPrintAst.qll
.And I don't think you want the same thing to show up twice for your use.
That sounds like an OK solution.