[NO_KIND_SPECIFIED] error inspite of specifying @kind for this query #853
-
Hi, can anyone guide me on the correct @kind for this query to resolve the error: /**
* This is an automatically generated file
* @name v5
* @kind problem
* @problem.severity warning
* @id java/example/hello-world
*/
import java
import semmle.code.java.dataflow.DataFlow
predicate isSource(DataFlow::Node src) {
exists(Parameter p |
p.getName() in ["realName", "blabName", "username", "file", "command", "blabberUsername", "password", "remember", "target"] and
src.asParameter() = p
)
or
exists(MethodAccess access |
access.getMethod().getDeclaringType().getName() = "javax.servlet.http.HttpServletRequest" and
(
access.getMethod().hasName("getParameter") or
access.getMethod().hasName("getHeader") or
access.getMethod().hasName("getCookies")
) and
src.asExpr() = access
)
or
exists(MethodAccess cmdClassAccess |
cmdClassAccess.getMethod().getName() in ["forName", "newInstance"] and
src.asExpr() = cmdClassAccess
)
or
exists(MethodAccess methodAccess |
methodAccess.getMethod().getName() in ["processLogin", "showPasswordHint", "processRegister"] and
src.asExpr() = methodAccess
)
}
predicate isSink(DataFlow::Node snk) {
exists(MethodAccess fileAccess |
fileAccess.getMethod().getDeclaringType().getName() = "java.io.File" and
(
fileAccess.getMethod().hasName("renameTo") or
fileAccess.getMethod().hasName("new File")
) and
snk.asExpr() = fileAccess
)
or
exists(MethodAccess sqlMethod |
sqlMethod.getMethod().getDeclaringType().getName() = "java.sql.Statement" and
(
sqlMethod.getMethod().hasName("executeQuery") or
sqlMethod.getMethod().hasName("executeUpdate") or
sqlMethod.getMethod().hasName("execute")
) and
snk.asExpr() = sqlMethod
)
or
exists(BinaryExpr concatExpr |
(concatExpr.getLeftOperand() instanceof Literal or concatExpr.getRightOperand() instanceof Literal) and
snk.asExpr() = concatExpr
)
or
exists(MethodAccess cmdExec |
cmdExec.getMethod().getName() in ["exec", "start"] and
snk.asExpr() = cmdExec
)
or
exists(MethodAccess objectStreamAccess |
objectStreamAccess.getMethod().getDeclaringType().getName() = "java.io.ObjectInputStream" and
objectStreamAccess.getMethod().hasName("readObject") and
snk.asExpr() = objectStreamAccess
)
or
exists(MethodAccess formatAccess |
formatAccess.getMethod().getName() = "format" and
snk.asExpr() = formatAccess
)
}
from DataFlow::Node source, DataFlow::Node sink
where isSource(source) and isSink(sink)
select
source,
source.getEnclosingCallable().getBody().toString() + " is source; " +
sink.toString() + "; " +
sink.getEnclosingCallable().getBody().toString() + " is sink" Since the result of select clause has 2 columns: element, string, I'm confused as to why I am encountering an error. Select clauses for alert queries (@kind problem) consist of two ‘columns’, with the following structure: select element, string Select clauses for path queries (@kind path-problem) are crafted to display both an alert and the source and sink of an associated path graph. For more information, see “Creating path queries.” Select clauses for diagnostic queries (@kind diagnostic) and summary metric queries (@kind metric and @tags summary) have different requirements. For examples, see the diagnostic queries and the summary metric queries in the CodeQL repository. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That seems like a fine column structure for an Note that |
Beta Was this translation helpful? Give feedback.
That seems like a fine column structure for an
@kind problem
query. How are you trying to run this query that is producing that no-kind-specified error?Note that
@kind
like this is only necessary if you want to interpret the query to produce alerts in a format like SARIF. If you just want an arbitrary table, you can omit the@kind
, use a command likecodeql database run-queries
to execute the query, and then a command likecodeql bqrs decode
to view the "raw" output without needing it to represent an alert or diagnostic or similar.