Closed flyboss closed 1 week ago
Hi @flyboss,
For queries that specify the @kind problem
property, the second element of the select should always be a string. See https://codeql.github.com/docs/writing-codeql-queries/defining-the-results-of-a-query/ for further details.
Thank you for your immediate help!
I find the query has three problems:
query predicate nodes
must be removed. Otherwise, the query meets the same error.Now the query is:
/**
* This is an automatically generated file
* @name MyCG
* @kind problem
* @precision high
* @problem.severity warning
* @id javascript/example/my-cg
*/
import javascript
from DataFlow::InvokeNode call, Function caller, Function callee
where caller = call.getEnclosingExpr().getEnclosingFunction()
and callee = call.getACallee()
select call, "invoke"
It works.
May I ask another question? Why did #9458 add query predicate nodes
? Why does this statement have an impact on the select statement?
Why did #9458 add
query predicate nodes
?
Because the user is asking about producing at DOT file, and that requires information about nodes in addition to just the select.
Why does this statement have an impact on the select statement?
It doesn't. Note that no @kind
property is specified there, which means that the the restriction of the second element being a string does not apply.
The metadata tag @kind
is used to tell CodeQL how to interpret the data produced by a query. The most frequently used @kind
s are problem
and path-problem
. The problem
kind is for simple alerts and the selected data should have two columns: a location, and a text message. Actually the text message may contain $@
placeholders, and for each place holder there should be an additional location (link target) and text value (link text).
The select statement of a path-problem
query should select similar columns, except that it has 3 location columns before the text message, the first column is the alert location, and the other two are the begin and end locations of the flow paths. In addition the the select statement, a path-problem
requires two more query predicates
: edges
and nodes
that define the flow graph from which the displayed paths are picked.
Another kind is graph
which requires a query predicate nodes
and a query predicate edges
that define the nodes and edges of the graph.
Fun facts: internally a select
statement is roughly treated as query predicate #select(....)
and for (path-)problem
queries you can use query predicate problems(....)
instead of a select
statement.
Hi @flyboss,
I'm closing this issue. Besides the information provided by @jketema and @aibaars the following blog post explains path graphs to visualize a call graph for Java, but the example is translatable to JavaScript.
If you have any further questions, feel free to re-open the issue.
I want to get a call graph in JavaScript. I have found a solution in #9458 . But when I add query metadata to the query, for example
the vscode codeql extension meets the error:
After read the guide, I guess maybe my "select" has mistakes, so I also try 'select call, "call"', but I still meet the same error.
Can anyone help me? Thank you very much!