mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
21 lines
719 B
Plaintext
21 lines
719 B
Plaintext
/**
|
|
* @name Uncontrolled format string
|
|
* @description Finds calls to ``String.init(format:_:)`` where the format
|
|
* string is not a hard-coded string literal.
|
|
* @id swift/examples/simple-uncontrolled-format-string
|
|
* @tags example
|
|
*/
|
|
|
|
import swift
|
|
import codeql.swift.dataflow.DataFlow
|
|
|
|
from CallExpr call, Method method, DataFlow::Node sinkNode
|
|
where
|
|
call.getStaticTarget() = method and
|
|
method.hasQualifiedName("String", "init(format:_:)") and
|
|
sinkNode.asExpr() = call.getArgument(0).getExpr() and
|
|
not exists(StringLiteralExpr sourceLiteral |
|
|
DataFlow::localFlow(DataFlow::exprNode(sourceLiteral), sinkNode)
|
|
)
|
|
select call, "Format argument to " + method.getName() + " isn't hard-coded."
|