Swift: Mathias's fix for the non-constant format example.

This commit is contained in:
Geoffrey White
2023-05-03 14:29:39 +01:00
parent 1084d7ff0e
commit 2999b5fea1

View File

@@ -140,13 +140,13 @@ The following example finds calls to ``String.init(format:_:)`` where the format
import swift
import codeql.swift.dataflow.DataFlow
from CallExpr call, Method method, Expr sinkExpr
from CallExpr call, Method method, DataFlow::Node sinkNode
where
call.getStaticTarget() = method and
method.hasQualifiedName("String", "init(format:_:)") and
sinkExpr = call.getArgument(0).getExpr() and
sinkNode.asExpr() = call.getArgument(0).getExpr() and
not exists(StringLiteralExpr sourceLiteral |
DataFlow::localFlow(DataFlow::exprNode(sourceLiteral), DataFlow::exprNode(sinkExpr))
DataFlow::localFlow(DataFlow::exprNode(sourceLiteral), sinkNode)
)
select call, "Format argument to " + method.getName() + " isn't hard-coded."