mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Swift: Mathias's fix for the non-constant format example.
This commit is contained in:
@@ -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."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user