Fixed the -- completely -- broken Sink query

This commit is contained in:
2025-09-04 23:32:50 -07:00
committed by =michael hohn
parent 28c40f9af3
commit 3b932164e5
5 changed files with 21 additions and 14 deletions

View File

@@ -1,16 +1,21 @@
/**
* Identify the sink: the 3rd argument to exec.Command(...), i.e., index 2.
* Uses AST/semantic matching via resolved call target and argument position.
*/
* @name Sink identification
* @description Sink identification
* @kind problem
* @id go/demo/sink
* @problem.severity warning
* Identify the sink: the 3rd argument to exec.Command(...), i.e., index 2.
* Uses AST/semantic matching via resolved call target and argument position.
*/
import go
/** A sink expression corresponding to the 3rd argument to exec.Command. */
predicate isSink(Expr e) {
exists(Call c, Function f |
f = c.getTarget() and
f.getName() = "Command" and
f.getDeclaringPackage().getName() = "exec" and
exists(CallExpr c |
c.getCalleeName() = "Command"
and
e = c.getArgument(2)
)
}